• R/O
  • SSH

rulp: Commit

The main repository for rulp in Mercurial


Commit MetaInfo

Revisiona911308e9a5bb5f4d901dfe11722ffba78ee1a98 (tree)
Time2021-10-20 21:28:41
AuthorGiulio De Stasio <giuliods@user...>
CommiterGiulio De Stasio

Log Message

moved to raylib

Change Summary

Incremental Difference

diff -r c3ae3418f43e -r a911308e9a5b README
--- a/README Sat Apr 24 10:28:37 2021 +0200
+++ b/README Wed Oct 20 14:28:41 2021 +0200
@@ -1,84 +1,75 @@
1-RU*** roLeplay Playground
2-=====================
1+Ru*** roLeplay Playground
2+=========================
33
4-This is a playground for d20 system based sessions, it
5-display a digital tabletop for online roleplay sessions.
4+This is a virtual table for combats in d20 system (like Pathfinder
5+or Dungeons&Dragons. This is a rewamped version of the precedent
6+RuLP using raylib over sdl1.2.
67
7-Install
8+!!!
9+This version is still a work in progress. Many of the features have to
10+be implemented and functions be polished, It is not reccomended to be used
11+as end-user tool (yet).
12+
13+Suggestions are well accepted.
14+!!!
15+
16+Install
817 -------
918
10-RULP is written in LISP, use sdl1.2 and the steel bank common lisp
11-(SBCL) with lispbuilder-sdl and sdl-image, to use the programs you need
12-
13-* sbcl
14-* sdl1.2
15-* sdl1.2-image
16-
17-To compile the sources is also needed
18-
19-* sdl1.2-devel
20-* sdl1.2-image-devel
21-* lispbuilder-sdl
22-* lispbuilder-sdl-image
19+RuLP is written in Lisp using Raylib and the ffi library. As now there are
20+no compiled versions of the program but it is easy to install and use it
21+with the following tools:
2322
24-Packages' name change based on distro and package manager, it suggested to
25-search trough the repositories with the built-in search command or with the
26-online search engine
27-
28-LISP libraries can be downloaded and installed trough quicklisp. The software
29-and guide is available from https://www.quicklisp.org/beta, to install
30-specifically the libraries above just install quicklisp and then use
31-the commands
23+* raylib
24+* cl-raylib (by quicklisp or manually)
25+* ffi development libraries
26+* cffi (by quicklisp or manually)
27+* sbcl/clisp (clisp not tested, but should work)
3228
33-(ql:quickload "lispbuilder-sdl")
34-(ql:quickload "lispbuilder-sdl-image")
29+Raylib can be downloaded from their website https://raylib.com/, or
30+from any package manager in linux, chokolately from windows or
31+macports/homebrew from Mac. If downloaded trough these latter ways,
32+remember to install both raylib and the development version (usually
33+as raylib-devel or raylib-dev)
3534
36-lispbuilder-sdl seems to work with sbcl and not the gnu clisp, the issue can
37-be resolved debugging the sdl code as displayed by the clisp debugger. When
38-I'll resolve the problem (debugging lispbuilder or directly change the library)
39-I will upgrade the README and notify on the news.
35+the same as above for ffi, it can be downloaded from any package manager
36+and you need to download both the ffi and the developement version.
4037
41-rulp can be interpreted with sbcl using
38+cl-raylib and cffi can be downloaded with quicklisp, indications
39+about installation and usage are available on
40+https://www.quicklisp.org/beta. With quicklisp installed you
41+just need to execute
42+
43+(ql:quickload "cl-raylib")
44+(ql:quicklisp "cffi")
45+
46+with the lisp interpreter of choice.
47+
48+Now the program is ready to start and be used. Open a console/terminal
49+window in this folder and execute
4250
4351 $ sbcl --load rulp.lisp
4452
45-or compiled first with
46-
47-$ sbcl --load make.lisp
48-
49-and then execute rulp.
53+or load with your interpreter of choice
5054
51-The rulp.lisp file contain the layers and actors informations, it can be changed
52-to change background, grid, effects, actors and icons.
53-
54-When the gui for adding and removing actors and layers will be ready I will remove
55-this part in the README and update in the news
56-
57-The software will create a linux compatible binary (for now), it can be tweaked
58-to compile for virtually any machine editing the make.lisp file
5955
6056 Usage
6157 -----
6258
63-the keybinds are:
64-
65-up down left right: move the icon with the cursor on
66-space: move the cursor between icons
67-q: exit
68-
69-mouse left: select a specific actor
70-
71-More settings to be added
59+Mouse left: select a specific actor
60+Mouse right: move the selected actor
61+esc: quit
7262
73-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74-
75-Rulp is a beginning stage of development, and many things
76-have to be completed, don't consider this to be a usable or definitive
77-software, but just a early stage software I wanted to make public.
63+----------------------------------------------------------------------
7864
79-Why not a personal forge? Because when the software will be more mature this
80-early stages will still be available for the user.
65+Rulp is in a early stage of development, many things have to be
66+fixed and the general feeling is of a clunky and unintuitive program
67+that need tweaks to work properly.
8168
82-Critique is welcome and appreciated, I don't commit very often but I work on
83-background nontheless, so don't worry if there isn't any update in days (or weeks)
84-I just don't want to commit half done work.
69+This is not a final result, I want to make this more usable and cool
70+and I already have ideas on how to do that.
71+
72+Critique is welcome and appreciated, I don't push commits often, as
73+this is a spare time project and I don't have much spare time to begin
74+with. Even if there are few updates I work on the background on bug
75+fixes and features but I just don't want to commit half done work.
diff -r c3ae3418f43e -r a911308e9a5b WIP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/WIP Wed Oct 20 14:28:41 2021 +0200
@@ -0,0 +1,32 @@
1+# Appunti sul "work in progress" per rulp
2+
3+[X] - far partire il programma
4+[X] - leggere le s-expressions
5+[X] - creare un generatore di textures
6+[X] - creare una grammatica per le mappe
7+Genmap fatto
8+
9+[X] - creare un personaggio
10+[X] - farlo muovere
11+[X] - inserirlo in un entity file (oppure dentro il mapfile direttamente)
12+[X] - Creare un sistema per manipolare i personaggi
13+genent fatto
14+
15+[ ] - provare a far comunicare due programmi
16+[ ] - implementare rete
17+network fatto
18+
19+[ ] - oscurare parti di mappe con layers ad hoc
20+[ ] - far visualizzare questo layer soltanto ad alcuni personaggi
21+[ ] - implementare una grammatica
22+genvis fatto
23+
24+Sono soddisfatto
25+
26+Bug e pessime scritture da risolvere:
27++ troppi let e superscritture in giro per il codice, dovranno essere create funzioni che ne riducano l'uso e creino
28+ un astrazione tra i livelli e la visualizzazione
29++ ridimensionamento, ancora non va
30++ rimuovere i valori di griglia hardcoded "(grid 70)" che si trovano in giro (se necessario rendere grid generale e non un
31+ livello manualmente modificabile
32++ creare un sistema per editare le mappe (non voglio toccare il codice durante una sessione
\ No newline at end of file
diff -r c3ae3418f43e -r a911308e9a5b blank.lisp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blank.lisp Wed Oct 20 14:28:41 2021 +0200
@@ -0,0 +1,22 @@
1+;; Blank layer script
2+;; this file will be executed by rulp at the beginning (and through
3+;; drag and drop). All the elements that will be displayed in +layers+
4+;; will be displayed in the map
5+
6+(setf base-grid (make-instance 'grid-layer
7+ :grid-layer-span 70))
8+
9+(setf amanda (make-instance 'actor-layer
10+ :entity-layer-grid base-grid
11+ :entity-name "Amanda"))
12+
13+(setf (l-x amanda) 6)
14+(setf (l-y amanda) 3)
15+
16+(setq +layers+ (list
17+ (make-instance 'image-layer :source "board.png")
18+ base-grid
19+ (make-instance 'actor-layer
20+ :entity-layer-grid base-grid
21+ :entity-name "Barbuda")
22+ amanda))
diff -r c3ae3418f43e -r a911308e9a5b board.png
Binary file board.png has changed
diff -r c3ae3418f43e -r a911308e9a5b grafico.png
Binary file grafico.png has changed
diff -r c3ae3418f43e -r a911308e9a5b layers.lisp
--- a/layers.lisp Sat Apr 24 10:28:37 2021 +0200
+++ b/layers.lisp Wed Oct 20 14:28:41 2021 +0200
@@ -1,36 +1,13 @@
1-(require :lispbuilder-sdl)
2-(require :lispbuilder-sdl-image)
3-(load "actors.lisp")
4-
5-;(defgeneric layer-render (object))
6-;(defgeneric layer-load-surface (source object))
7-
8-(defgeneric render-surface (object &key surface))
1+(defgeneric render (object))
92 (defgeneric l-x (object))
103 (defgeneric l-y (object))
114 (defgeneric (setf l-x) (value object))
125 (defgeneric (setf l-y) (value object))
13-(defgeneric width (object))
14-(defgeneric height (object))
156
167 (defclass layer ()
17- ((name :accessor layer-name
18- :initarg :layer-name
19- :initform "unnamed"
20- :documentation "surface name, for identification purpose"
21- :type string)
22- (coordinate :accessor layer-coordinate
8+ ((coordinate :accessor layer-coordinate
239 :initarg :layer-coordinate
24- :initform (make-array '(2) :initial-contents '(0 0))
25- :documentation "coordinate of the layer, usually the display dimension"
26- :type simple-vector)
27- (dimension :accessor layer-dimension
28- :initarg :layer-dimension
29- :initform (make-array '(2) :initial-contents '(1000 750)))
30- (alpha :accessor layer-alpha
31- :initarg :layer-alpha
32- :initform 255
33- :documentation "layer opacity")))
10+ :initform (make-array '(2) :initial-contents '(0 0)))))
3411
3512 (defmethod l-x ((object layer))
3613 (aref (slot-value object 'coordinate) 0))
@@ -44,125 +21,61 @@
4421 (defmethod (setf l-y) (value (object layer))
4522 (setf (aref (slot-value object 'coordinate) 1) value))
4623
47-(defmethod width ((object layer))
48- (aref (slot-value object 'dimension) 0))
49-
50-(defmethod height ((object layer))
51- (aref (slot-value object 'dimension) 1))
52-
53-(defmethod render-surface ((object layer) &key surface)
54- (sdl:draw-box-* 0 0 50 50 :color sdl:*blue* :surface surface)
55- surface)
56-
57-
58-;; Starting specialized layers, avoid use directly layer unless as a test and
59-;; use the specialized layer below
60-
61-;; Image-layer
62-(defclass image-layer (layer)
63- ((source :accessor layer-source
64- :initarg :layer-source
65- :initform "board.bmp"
66- :documentation "source of the image-layer, this is converted in surface with render-surface"
67- :type string)))
68-
69-(defmethod draw-as-entity ((object image-layer))
70- (make-instance 'entity :entity-image-source (layer-source object)))
71-
72-(defmethod render-surface ((object image-layer) &key surface)
73- (sdl:blit-surface (sdl-image:load-image (layer-source object)) surface)
74- surface)
75-
76-
77-; Grid-layer
78-(defclass grid-layer (layer)
79- ((form :accessor layer-grid-form
80- :initarg :layer-grid-form
81- :initform 'square
82- :documentation "the form of the grid, actually only squared, in the future hexagonal and triangular")
83- (span :accessor layer-grid-span
84- :initarg :layer-grid-span
85- :initform 50
86- :documentation "the pixel span of the grid, it depend on the grid type but mainly it define the side length")
87- (color :accessor layer-grid-color
88- :initarg :layer-grid-color
89- :initform sdl:*black*
90- :documentation "the grid color")))
91-
92-(defmethod render-surface ((object grid-layer) &key surface)
93- (with-slots (span color)
94- object
95- (let ((horizontal-lines (floor (/ (width object) (layer-grid-span object))))
96- (vertical-lines (floor (/ (height object) (layer-grid-span object)))))
97- (loop for i from 1 to horizontal-lines
98- do (sdl:draw-line-* (* i span) 0 (* i span) (height object) :color color :surface surface))
99- (loop for j from 1 to vertical-lines
100- do (sdl:draw-line-* 0 (* j span) (width object) (* j span) :color color :surface surface))
101- ))
102- surface)
103-
10424
105-;; Actor-layer
106-;; This layer will be heavily modified to move from multiactor layer system to single actor
107-;; layer. This to have a non-modifying surface that can be deployed and moved, and thus
108-;; resolving the ram-hog bug
109-(defclass actor-layer (layer)
110- ((actor :accessor layer-actor
111- :initarg :layer-actor
112- :initform (make-instance 'actor)
113- :documentation "the actor to be displayed")
114- (grid :accessor layer-actor-grid
115- :initarg :actor-grid
116- :initform (make-instance 'grid-layer)
117- :documentation "the grid where the actors move")))
25+(defclass image-layer (layer)
26+ ((image-source :accessor image-source
27+ :initarg :source
28+ :initform "test.png")
29+ (image-mipmap :accessor image-mipmap
30+ :initarg :image-mipmap
31+ :initform nil)
32+ ))
11833
119-(defmethod render-surface ((object actor-layer) &key surface)
120- (with-slots (actor grid)
121- object
122- (let* ((grid-span (layer-grid-span grid))
123- (x-position (* (e-x actor) grid-span))
124- (y-position (* (e-y actor) grid-span))
125- (y-position-bottom (+ y-position grid-span)))
126- (sdl:draw-surface-at-* (sdl-image:load-image (entity-image-source actor)) x-position y-position :surface surface)
127- (sdl:draw-box-* x-position (- y-position-bottom 10) grid-span 10 :surface surface)
128-; (sdl:draw-string-solid-* "jjezz" 0 0 :surface surface)
129- ))
130- surface)
131-; | -> x-position
132-; y-position <- -+-------+ / grid-span
133-; | /O O\| |
134-; | \ ~ /| |
135-; |-------| |
136-; +-------+ -> x-position-bottom /
137-
138-
139-(defmethod l-x ((object actor-layer))
140- (* (e-x (layer-actor object)) (layer-grid-span (layer-actor-grid object))))
34+(defclass grid-layer (layer)
35+ ((span :accessor grid-layer-span
36+ :initarg :grid-layer-span
37+ :initform 70)))
14138
142-(defmethod l-y ((object actor-layer))
143- (* (e-y (layer-actor object)) (layer-grid-span (layer-actor-grid object))))
144-
145-(defmethod (setf l-x) (value (object actor-layer))
146- (setf (e-x (layer-actor object))
147- (/ value (layer-grid-span (layer-actor-grid object)))))
148-
149-(defmethod (setf l-y) (value (object actor-layer))
150- (setf (e-y (layer-actor object))
151- (/ value (layer-grid-span (layer-actor-grid object)))))
39+(defmethod grid-offset (value (object grid-layer))
40+ (* value (grid-layer-span object)))
15241
153-;; Chess-layer (letters and numbers on the side of the layer)
154-(defclass chess-layer (layer)
155- ((grid :accessor layer-chess-grid
156- :initarg :actor-grid
157- :initform (make-instance 'grid-layer)
158- :documentation "the grid where the letters will be generated")))
42+(defclass entity-layer (image-layer)
43+ ((display :accessor display
44+ :initarg :display
45+ :initform t)
46+ (grid :accessor entity-layer-grid
47+ :initarg :entity-layer-grid
48+ :initform (make-instance 'grid-layer))
49+ (size :accessor entity-layer-size
50+ :initarg :entity-layer-size
51+ :initform 1)))
15952
160-(defmethod render-surface ((object chess-layer) &key surface)
161- (with-slots (grid)
162- object
163- (let ((span (layer-grid-span (layer-chess-grid object))))
164- (loop for i from 0 to (/ (width object) span)
165- for j from 0 to (/ (height object) span)
166- do (sdl:draw-string-solid-* "q" (* i span) (* j span) :color sdl:*black* :surface surface))
167- ))
168- surface)
53+(defclass actor-layer (entity-layer)
54+ ((name :accessor entity-name
55+ :initarg :entity-name
56+ :initform "")
57+ (life :accessor life
58+ :initarg life
59+ :initform 0)
60+ (max-life :accessor max-life
61+ :initarg life
62+ :initform 0)))
63+
64+(defmethod actor-move-up ((object actor-layer))
65+ (setf (l-y object) (- (l-y object) 1)))
66+
67+(defmethod actor-move-down ((object actor-layer))
68+ (setf (l-y object) (+ (l-y object) 1)))
69+
70+(defmethod actor-move-left ((object actor-layer))
71+ (setf (l-x object) (- (l-x object) 1)))
72+
73+(defmethod actor-move-right ((object actor-layer))
74+ (setf (l-x object) (+ (l-x object) 1)))
75+
76+(defun compare (a b)
77+ (let ((a-x (aref a 0))
78+ (a-y (aref a 1))
79+ (b-x (aref b 0))
80+ (b-y (aref b 1)))
81+ (if (and (equal a-x b-x) (equal a-y b-y)) t nil)))
diff -r c3ae3418f43e -r a911308e9a5b rulp.lisp
--- a/rulp.lisp Sat Apr 24 10:28:37 2021 +0200
+++ b/rulp.lisp Wed Oct 20 14:28:41 2021 +0200
@@ -1,32 +1,142 @@
1-(load "sdl.lisp")
2-;(require "config.lisp")
3-
4-;;;; Now it is just necessary to add actors on this file, later I will add a more
5-;;;; easy interface to add and remove characters
6-
7-(defvar *actors* nil)
8-(defvar *layer-list* nil)
9-
10-(defun rulp-main ()
11- "RULP: main"
12- (format t "RU*** Lisp Playground (RULP)~%")
1+(require :cl-raylib)
2+(load "layers.lisp")
133
14- ;;; You can add actors here using the formula below or just creating a list of actors and
15- ;;; including it in the actor layer
16- ; (setf *actors* (add-to-list (make-instance 'actor) *actors*))
17- (setf *actors* (add-to-list (make-instance 'actor) *actors*))
18- (setf *actors* (add-to-list (make-instance 'actor) *actors*))
4+(defvar +layers+ nil)
5+(defvar screen-width 1000)
6+(defvar screen-height 750)
7+(defvar +pointer+ nil)
198
20- ;;; You can add layer here. The one below is the standard formula, but it can be changed.
21- ;;; send the layer list is elaborated top to bottom, so the first elements are the one below
22-; (setf *layer-list* (add-to-list (make-instance 'layer) *layer-list*))
23- (setf *layer-list* (add-to-list (make-instance 'image-layer) *layer-list*))
24- (setf *layer-list* (add-to-list (make-instance 'grid-layer) *layer-list*))
25-; (setf *layer-list* (add-to-list (make-instance 'chess-layer) *layer-list*))
26- (setf *layer-list* (add-to-list (make-instance 'actor-layer) *layer-list*))
27- (setf *layer-list* (add-to-list (make-instance 'actor-layer) *layer-list*))
289
29- (playground '(1000 750) *layer-list*)
10+;; This function, starting with the x and y position of the mouse, find the actor that is placed in there
11+;; and return the pointer of the special "actor-from-layers" list
12+(defun select-pointer (mouse-x mouse-y)
13+ (let* ((actors-from-layers (remove-if-not #'(lambda (x) (typep x 'actor-layer)) +layers+))
14+ (coordinate-list (map 'list #'(lambda (x) (layer-coordinate x)) actors-from-layers))
15+ (grid 70) ; this is an hardcoded variable that MUST be removed and replaced with a real grid one
16+ (mouse-on-grid-x (floor (/ mouse-x grid)))
17+ (mouse-on-grid-y (floor (/ mouse-y grid)))
18+ (mouse-on-grid-vec (make-array '(2) :initial-contents (list mouse-on-grid-x mouse-on-grid-y)))
19+ (return-pointer (position-if #'(lambda (x) (compare x mouse-on-grid-vec)) coordinate-list)))
20+ return-pointer))
21+
22+(defun move-actor (mouse-x mouse-y)
23+ (let* ((actors-from-layers (remove-if-not #'(lambda (x) (typep x 'actor-layer)) +layers+))
24+ (grid 70) ; this is an hardcoded variable that MUST be removed and replaced with a real grid one
25+ (mouse-on-grid-x (floor (/ mouse-x grid)))
26+ (mouse-on-grid-y (floor (/ mouse-y grid)))
27+ (mouse-on-grid-vec (make-array '(2) :initial-contents (list mouse-on-grid-x mouse-on-grid-y))))
28+ (setf (layer-coordinate (nth +pointer+ actors-from-layers)) mouse-on-grid-vec)))
29+
30+#|
31+Layer render implementation with raylib
32+They are here as this is the file with the
33+raylib imported, also this makes the layer
34+file easy to convert in another implementations
35+|#
36+
37+(defmethod render ((object layer))
38+ (raylib:draw-rectangle (l-x object) (l-y object) 20 20 raylib:+black+))
39+
40+(defmethod render ((object image-layer))
41+ (if (null (image-mipmap object))
42+ (setf (slot-value object 'image-mipmap) (raylib:load-texture (image-source object)))
43+ (raylib:draw-texture (image-mipmap object) (l-x object) (l-y object) raylib:+raywhite+)))
44+
45+(defmethod render ((object grid-layer))
46+ (with-slots (span)
47+ object
48+ (let ((horizontal-lines (floor (/ screen-width (grid-layer-span object))))
49+ (vertical-lines (floor (/ screen-height (grid-layer-span object)))))
50+ (loop for i from 1 to horizontal-lines
51+ do (raylib:draw-line (* i span) 0 (* i span) screen-height raylib:+lightgray+))
52+ (loop for j from 1 to vertical-lines
53+ do (raylib:draw-line 0 (* j span) screen-width (* j span) raylib:+lightgray+))
54+ )))
55+
56+
57+;; this render method doesn't resize images, it has to be implemented here or somewhere else
58+;; so it is not necessary to manually resize images to fit in here
59+(defmethod render ((object entity-layer))
60+ (let ((span (grid-layer-span (entity-layer-grid object))))
61+ (if (null (image-mipmap object))
62+ (setf (slot-value object 'image-mipmap) (raylib:load-texture (image-source object)))
63+ (raylib:draw-texture (image-mipmap object)
64+ (* span (l-x object))
65+ (* span (l-y object))
66+ raylib:+raywhite+))))
67+
68+
69+;(defmethod render ((object entity-layer))
70+; (let* ((span (grid-layer-span (entity-layer-grid object)))
71+; (dimension (* span (entity-layer-size object))))
72+; (if (null (image-mipmap object))
73+; (let* ((temp-img (raylib:load-image (image-source object)))
74+; (temp-img-res (raylib:image-resize 'temp-img dimension dimension)))
75+; (setf (slot-value object 'image-mipmap)
76+; (raylib:load-texture-from-image temp-img-res))
77+; (raylib:unload-image temp-img-res)
78+; (raylib:unload-image temp-img)))
79+; (raylib:draw-texture (image-mipmap object)
80+; (* span (l-x object))
81+; (* span (l-y object))
82+; raylib:+raywhite+)))
83+
84+(defmethod render ((object entity-layer))
85+ (let ((span (grid-layer-span (entity-layer-grid object))))
86+ (if (null (image-mipmap object))
87+ (setf (slot-value object 'image-mipmap) (raylib:load-texture (image-source object)))
88+ (raylib:draw-texture (image-mipmap object)
89+ (* span (l-x object))
90+ (* span (l-y object))
91+ raylib:+raywhite+)))
92+ (let* ((grid-span (grid-layer-span (entity-layer-grid object)))
93+ (x-position (* (l-x object) grid-span))
94+ (y-position (* (l-y object) grid-span))
95+ (y-position-bottom (+ y-position grid-span)))
96+ ;; Draw the name box
97+ (raylib:draw-rectangle x-position (- y-position-bottom 15) grid-span 15 raylib:+raywhite+)
98+ (raylib:draw-text (entity-name object) x-position (- y-position-bottom 15) 15 raylib:+black+)))
99+
100+#|
101+End render section
102+|#
103+
104+; This function should blank the screen and then eval/apply the s-expression put in the input.
105+(defun playground ()
106+ (raylib:with-drawing
107+ (raylib:clear-background raylib:+raywhite+)
108+; (raylib:draw-texture board 0 0 raylib:+raywhite+)
109+ (raylib:draw-text "Ru*** Lisp Playground" 400 365 20 raylib:+lightgray+)
110+ (map 'list #'render +layers+)
111+ (raylib:draw-fps 20 20)
112+ ;; Draw pointer
113+ (when (numberp +pointer+)
114+ ;; !! Reduce these let* around the code
115+ (let* ((actors-from-layers (remove-if-not #'(lambda (x) (typep x 'actor-layer)) +layers+))
116+ (actor-to-select (nth +pointer+ actors-from-layers))
117+ (actor-x (l-x actor-to-select))
118+ (actor-y (l-y actor-to-select))
119+ (actor-size (entity-layer-size actor-to-select))
120+ (grid (grid-layer-span (entity-layer-grid actor-to-select))))
121+ ;; Grammar to resolve, remove all the (* grid _) in the draw below
122+ (raylib:draw-rectangle-lines (* grid actor-x) (* grid actor-y) (* grid actor-size) (* grid actor-size) raylib:+red+)
123+ ))))
124+
125+(defun main ()
126+ (load "blank.lisp" :if-does-not-exist nil)
127+ (defvar mouse-position nil)
128+ (raylib:with-window (screen-width screen-height "Ru■■■ Lisp Playground")
129+ (raylib:set-target-fps 90)
130+ (loop
131+ (setf mouse-position (raylib:get-mouse-position)) ;; this is a structure (defstruct vector2 x y)
132+ (cond ((raylib:window-should-close)(return))
133+ ((raylib:is-mouse-button-pressed raylib:+mouse-left-button+)
134+ (setf +pointer+ (select-pointer (raylib:vector2-x mouse-position) (raylib:vector2-y mouse-position))))
135+ ((raylib:is-mouse-button-pressed raylib:+mouse-right-button+)
136+ (if (numberp +pointer+) ;; here you add the right mouse action when nothing is selected
137+ (move-actor (raylib:vector2-x mouse-position) (raylib:vector2-y mouse-position)))))
138+ (playground)
139+ ))
30140 (quit))
31141
32-(rulp-main)
142+(main)
diff -r c3ae3418f43e -r a911308e9a5b rulp_text.png
Binary file rulp_text.png has changed
diff -r c3ae3418f43e -r a911308e9a5b test.png
Binary file test.png has changed
Show on old repository browser