parameters:*rulp-version*
parameters:*rulp-system*
parameters:*rulp-arch*)
-; (graphics:playground *screen-width* *screen-height* name)
+ (load "init.lisp" :if-does-not-exist nil)
+ ;; (graphics:playground *screen-width* *screen-height* name)
(bt:make-thread (lambda () (graphics:playground *screen-width* *screen-height* name)))
; (gui:lobby)
)
+;;;; Ru*** roLeplay Playground virtual tabletop
+;;;; Copyright (C) 2022 Zull
+;;;;
+;;;; This program is free software: you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License as published by
+;;;; the Free Software Foundation, either version 3 of the License, or
+;;;; (at your option) any later version.
+;;;;
+;;;; This program is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;;; GNU General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(in-package :core)
+
+
;; posso usare le hash piuttosto che interpretarlo sul momento. Infatti creerò un metodo che
;; analizza json e lo traduce in una tabella hash e una funzione che prende la hash e crea
;; l'oggetto tramite i metodi standard.
;; (gethash 'key a) ; recupera la hash con chiave key, questa è settable
(defun parse-list (linput)
(if (listp (car linput))
- (loop :for l :in linput
- :do
- (parse-list l))
- (FORMAT t "TEXT IS ~A, ~A AND ~A~%" (CAR LINPUT) (CADR LINPUT) (CADDR LINPUT)) ; devi ricordanti che i campi non sono (a b c) ma sono ((a1 . a2) (b1 . b2) (c1 . c2))
- ))
+ (loop :for l :in linput
+ :do
+ (parse-list l))
+ (FORMAT t "TEXT IS ~A, ~A AND ~A~%" (CAR LINPUT) (CADR LINPUT) (CADDR LINPUT)) ; devi ricordanti che i campi non sono (a b c) ma sono ((a1 . a2) (b1 . b2) (c1 . c2))
+ ))
(defun decompose-alist (alist search-list)
(apply 'concatenate 'list
(:documentation "given x y and the button pressed it do actions"))
(defmethod activate (x y pressed (p plane))
- (loop :for key :in *keybinds*
+ (loop :for key :in *mouse-keybinds*
:do
(when (sdl2:mouse-state-p (eval (car key)))
(apply (cadr key) `(,x ,y ,p))
(defpackage :graphics
(:use :cl :layers)
(:export
- playground
+ playground +plane+
))
(in-package :graphics)
(defparameter +mouse-button-right+ 3)
(defparameter +mouse-button-middle+ 2)
-(defparameter *keybinds* (list
- '(+mouse-button-left+ select-pointer)
- '(+mouse-button-right+ move-entity)
- )
+(defparameter *mouse-keybinds* (list
+ '(+mouse-button-left+ select-pointer)
+ '(+mouse-button-right+ move-entity)
+ )
"this is a list of actions connected to mouse presses, this can be edited
here if needed"
)
font-surface)))
(sdl2:free-surface font-surface)
font-texture))
- (setf +plane+ (make-instance 'plane :image (truename "media/board.tga")))
- (setf (entities-list +plane+) (list (make-instance 'entity)))
(sdl2:with-event-loop (:method :poll)
(:quit () t)
+ (:keyup (:keysym keysym)
+ (when (sdl2:scancode= (sdl2:scancode-value keysym) :scancode-q)
+ (format t "pressed q~%")))
(:mousebuttondown (:x x :y y :state state)
(activate x y state +plane+))
(:idle ()
))
(defmethod create-entity ((m model))
+ "create an entity from the standard model"
(let* ((return-entity m))
- (change-class return-entity 'entity)
- return-entity))
+ (make-instance 'entity
+ :name (name m)
+ :movement (movement m)
+ :size (size m)
+ :interactions (interactions m))))
(defmethod screen-destination ((s screen) (p t))
(sdl2:make-rect (x s) (y s) (width s) (height s))
)
+
+(defmethod screen-purge ((s screen))
+ "purge screens video data. This data is automatically generated during rendering"
+ (sdl2:destroy-texture (texture s))
+ (sdl2:free-surface (surface s)))
--- /dev/null
+;;;; Ru*** roLeplay Playground virtual tabletop
+;;;; Copyright (C) 2022 Zull
+;;;;
+;;;; This program is free software: you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License as published by
+;;;; the Free Software Foundation, either version 3 of the License, or
+;;;; (at your option) any later version.
+;;;;
+;;;; This program is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;;; GNU General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+(defpackage :script
+ (:use :cl :graphics :layers))
+
+(in-package :script)
+
+(defun active-plane ()
+ graphics:+plane+)
+
+(defun (setf active-plane) (value)
+ (setf graphics:+plane+ value))
+
+(defun entities ()
+ (entities-list graphics:+plane+))
+
+(defun (setf entities) (value)
+ (if (listp value)
+ (setf (entities-list graphics:+plane+) value)
+ (error "(setf entities) error: given symbol is not a list")))
+
+(defun add-entity (entity)
+ "add an entity into the active plane"
+ (push entity graphics:+plane+))
+
+(defun remove-entity (number)
+ "remove the nth entity from the active plane"
+ (screen-purge (nth number (entities-list graphics:+plane+)))
+ (setf (nth number (entities-list graphics:+plane+)) nil)
+ (remove nil (entities-list graphics:+plane+)))
+
+(defparameter *plane-list* nil)
+
+(defun new-plane (image)
+ "create a new plane and add it to the plane list"
+ (let ((gen-plane (make-instance 'plane :image image)))
+ (push gen-plane *plane-list*)
+ gen-plane))
+
+(defun remove-plane (number)
+ "remove the nth plane from the plane list"
+ (screen-purge (nth number *plane-list*))
+ (setf (nth number *plane-list*) nil)
+ (setf *plane-list* (remove nil *plane-list*)))
+
+(defun list-planes ()
+ "list the content in the plane list"
+ *plane-list*)
;;;; GNU General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU General Public License
-;;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+;;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(asdf:defsystem "rulp"
:description "Ru*** roLeplay Playground: a digital table for roleplay games"
; :components ((:file "package")
; (:file "skeleton")))
(:file "package" :depends-on ("graphics"))
+ (:file "script" :depends-on ("graphics"))
(:file "data" :depends-on ("package" "parameters"))
(:file "core" :depends-on ("package" "parameters"))))