• R/O
  • SSH

rulp: Commit

The main repository for rulp in Mercurial


Commit MetaInfo

Revision1aeae3aacfcd7f322333fd67a0805b139a9aab09 (tree)
Time2022-05-15 05:44:15
AuthorGiulio De Stasio <giuliods@user...>
CommiterGiulio De Stasio

Log Message

Moved to SDL2

Change Summary

Incremental Difference

diff -r f1cbf8d801a5 -r 1aeae3aacfcd README
--- a/README Mon May 02 13:27:33 2022 +0200
+++ b/README Sat May 14 22:44:15 2022 +0200
@@ -19,7 +19,8 @@
1919
2020 Also the software uses sdl2 and ltk libraries for display graphics.
2121
22-* raylib-devel
22+* sdl2-devel
23+* sdl2_image-devel
2324 * tcl
2425 * tk
2526 * quicklisp
diff -r f1cbf8d801a5 -r 1aeae3aacfcd core.lisp
--- a/core.lisp Mon May 02 13:27:33 2022 +0200
+++ b/core.lisp Sat May 14 22:44:15 2022 +0200
@@ -1,19 +1,18 @@
1-(defpackage :core
2- (:use :cl :bt-semaphore)
3- (:export main))
4-
51 (in-package :core)
62
7-(defparameter *screen-width* 1024)
8-(defparameter *screen-height* 768)
3+(defparameter *screen-width* 1000)
4+(defparameter *screen-height* 750)
95
106 ;; apply to load and save
117
128 (defun main ()
139 ;(bt:make-thread (lambda () (lobby:editor-gui))) ;; here bt-thread it is just used for execute ltk without troubles
1410 ;; for now it is disabled
15- (graphics:add-entity (make-instance 'layers:entity :icon "test.png" :size 1.0))
11+; (graphics:add-plane (make-instance 'layers:plane :image (truename "media/board.tga")))
1612
17- (bt:make-thread (lambda () (graphics:playground *screen-width* *screen-height* "Ru*** Lisp Playground")))
13+; (graphics:add-entity (make-instance 'layers:entity :img-path (truename "media/test.png") :size 1))
14+
15+ (graphics:playground 1000 750 "Rulp")
16+; (bt:make-thread (lambda () (graphics:playground *screen-width* *screen-height* "Ru*** Lisp Playground")))
1817 )
1918 ;; "Ru■■■ Lisp Playground"
diff -r f1cbf8d801a5 -r 1aeae3aacfcd graphics/grid.lisp
--- a/graphics/grid.lisp Mon May 02 13:27:33 2022 +0200
+++ b/graphics/grid.lisp Sat May 14 22:44:15 2022 +0200
@@ -1,12 +1,14 @@
11 (in-package :graphics)
22
33 (defparameter +grid-span+ 70)
4+(defparameter +is-grid+ t)
5+(defparameter +is-grid-letters+ t)
46
57 ; these two functions can be edited when different grids will be added
68 (defun position-actor-to-view (a)
79 (* a +grid-span+))
810 (defun position-view-to-actor (a)
9- (/ a +grid-span+))
11+ (floor (/ a +grid-span+)))
1012
1113 (defparameter +letters-list+
1214 '("A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M"
@@ -26,21 +28,24 @@
2628 (setf +is-grid-letters+ nil)
2729 (setf +is-grid-letters+ t)))
2830
29-(defun make-grid (screen-width screen-height)
31+(defun make-grid (renderer screen-width screen-height &optional (r 0) (g 0) (b 0) &key (a 255))
3032 (let ((x-iterations (/ screen-width +grid-span+))
3133 (y-iterations (/ screen-height +grid-span+)))
34+ (sdl2:set-render-draw-color renderer r g b a)
3235 (loop :for i :from 0 :to x-iterations
33- :do (raylib:draw-line (* i +grid-span+)
34- 0
35- (* i +grid-span+)
36- screen-height
37- raylib:+lightgray+))
36+ :do (sdl2:render-draw-line renderer
37+ (* i +grid-span+)
38+ 0
39+ (* i +grid-span+)
40+ screen-height
41+ ))
3842 (loop :for j :from 0 :to y-iterations
39- :do (raylib:draw-line 0
40- (* j +grid-span+)
41- screen-width
42- (* j +grid-span+)
43- raylib:+lightgray+))
43+ :do (sdl2:render-draw-line renderer
44+ 0
45+ (* j +grid-span+)
46+ screen-width
47+ (* j +grid-span+)
48+ ))
4449 ))
4550
4651 (defun make-grid-letters (screen-width screen-height)
diff -r f1cbf8d801a5 -r 1aeae3aacfcd graphics/inputs.lisp
--- a/graphics/inputs.lisp Mon May 02 13:27:33 2022 +0200
+++ b/graphics/inputs.lisp Sat May 14 22:44:15 2022 +0200
@@ -3,6 +3,11 @@
33 (defparameter +pointer+ nil) ; this parameter check out which entity is selected
44 (defparameter +mode+ '+normal-mode+)
55
6+(defparameter +mouse-button-left+ 1)
7+(defparameter +mouse-button-right+ 3)
8+(defparameter +mouse-button-middle+ 2)
9+
10+#|
611 (defun select-pointer (mouse-x mouse-y)
712 (let* ((obj-list (map 'list #'(lambda (o) (car o)) +entities-list+))
813 (placement-list (map 'list #'(lambda (o) (layers:placement o)) obj-list))
@@ -15,31 +20,42 @@
1520 :do
1621 (when (layers:compare mouse-pos object-placement)
1722 (setf +pointer+ n)))))
23+|#
24+
25+(defun select-pointer (mouse-x mouse-y)
26+ (let ((mouse-point (sdl2:make-rect mouse-x mouse-y 10 10)))
27+ (loop :for obj :in +entities-list+
28+ :for n :from 0 :to (length +entities-list+)
29+ :do
30+ (setf +pointer+ nil)
31+ (when (sdl2:has-intersect mouse-point
32+ (layers:screen-dest obj +grid-span+))
33+ (setf +pointer+ n))
34+ )))
35+;; cl-sdl2 doesn't support point-in-rect, which checks if a point is inside a rect, but there
36+;; is has-intersect which check if two or more rectangles collide.
1837
1938 (defun move-entity (mouse-x mouse-y)
2039 (when (numberp +pointer+)
21- (let* ((obj-list (map 'list #'(lambda (o) (car o)) +entities-list+))
22- (i-x (floor mouse-x +grid-span+))
23- (i-y (floor mouse-y +grid-span+))
24- (object (nth +pointer+ obj-list)))
25- (setf (layers:entity-x object) i-x)
26- (setf (layers:entity-y object) i-y))))
40+ (let* ((i-x (position-view-to-actor mouse-x))
41+ (i-y (position-view-to-actor mouse-y))
42+ (object (nth +pointer+ +entities-list+)))
43+ (setf (layers:x object) i-x)
44+ (setf (layers:y object) i-y)
45+ )))
2746
2847 ;; this list is the bind list, it contain all the keys and mouse presses that are available
2948 ;; with the function they do
3049 (defparameter +normal-mode+ (list
31- '(raylib:+mouse-left-button+ (select-pointer
32- (raylib:vector2-x mouse-position)
33- (raylib:vector2-y mouse-position)))
34- '(raylib:+mouse-right-button+ (move-entity
35- (raylib:vector2-x mouse-position)
36- (raylib:vector2-y mouse-position)))
37- '(raylib:+mouse-middle-button+ (setf +mode+ '+menu-mode+))))
50+ '(+mouse-button-left+ select-pointer)
51+ '(+mouse-button-right+ move-entity)
52+ ))
53+ ; '(+mouse-button-middle+ (setf +mode+ '+menu-mode+))))
3854
3955 (defparameter +menu-mode+ (list
4056 '(raylib:+mouse-left-button+ (select-menu mouse-position))))
4157
4258 ;; This simple function check if the given stroke is pressed, then return's it if it is
43-(defun use-mouse (stroke)
44- (when (raylib:is-mouse-button-pressed (eval (car stroke)))
45- (eval (cadr stroke))))
59+(defun use-mouse (x y stroke)
60+ (when (sdl2:mouse-state-p (eval (car stroke)))
61+ (apply (cadr stroke) (list x y))))
diff -r f1cbf8d801a5 -r 1aeae3aacfcd graphics/package.lisp
--- a/graphics/package.lisp Mon May 02 13:27:33 2022 +0200
+++ b/graphics/package.lisp Sat May 14 22:44:15 2022 +0200
@@ -6,3 +6,8 @@
66 add-plane remove-plane-nth
77 add-entity remove-entity-nth
88 ))
9+
10+(in-package :graphics)
11+
12+(defparameter +planes-list+ nil)
13+(defparameter +entities-list+ nil)
diff -r f1cbf8d801a5 -r 1aeae3aacfcd graphics/render.lisp
--- a/graphics/render.lisp Mon May 02 13:27:33 2022 +0200
+++ b/graphics/render.lisp Sat May 14 22:44:15 2022 +0200
@@ -1,58 +1,86 @@
11 (in-package :graphics)
22
3-;; it should be moved somewhere else when finalizing
4-;; if the number is out of scope it does nothing
5-(defun remove-nth (n lis)
6- (if (zerop n) (cdr lis)
7- (if lis (cons (car lis) (remove-nth (- n 1) (cdr lis)))
8- nil)))
3+;; functions for the two parameters
4+;;(defun add-entity (entity)
5+;; (setf +entities-list+ (append +entities-list+ (list (list entity))))
6+;; (setf (layers:entity-surface entity) (load-surface (layers:entity-icon entity))))
97
10-;; this can be expanded in a scene class which contain the layer list and the entities.
11-(defparameter +planes-list+ nil)
12-(defparameter +entities-list+ nil)
8+(defun load-surface (image)
9+ (sdl2-image:load-image image))
1310
1411 (defun add-entity (entity)
15- (setf +entities-list+ (append +entities-list+ (list (list entity 'nil)))))
12+ (push entity +entities-list+))
1613
1714 (defun remove-entity-nth (n)
15+ (sdl2:free-surface (layers:model-surface (nth n +entities-list+)))
16+ (sdl2:destroy-texture (layers:screen-texture (nth n +entities-list+)))
1817 (setf +entities-list+ (remove-nth n +entities-list+)))
1918
2019 (defun add-plane (plane)
21- (setf +planes-list+ (append +planes-list+ (list (list plane 'nil)))))
20+ (push plane +planes-list+))
2221
2322 (defun remove-plane-nth (n)
23+ (sdl2:free-surface (layers:plane-surface (nth n +planes-list+)))
24+ (sdl2:destroy-texture (layers:screen-texture (nth n +entities-list+)))
2425 (setf +planes-list+ (remove-nth n +planes-list+)))
2526
26-;; for now it just uses +entities-list+, in the future it should parsed for multiple scene to work
27+; replace render-copy with a non key version (useful to pass with apply)
28+(defun apply-texture (renderer texture &optional (srcrect nil) (destrect nil))
29+ (sdl2:render-copy renderer texture :source-rect srcrect :dest-rect destrect))
2730
28-(defun render-planes ()
31+#|
32+(defun render-planes (renderer)
2933 (loop :for x :in +planes-list+
3034 :do
31- (if (null (cadr x))
32- (setf (cadr x) (layers:show (car x)))
33- (when (layers:plane-is-display (car x))
34- (raylib:draw-texture (cadr x)
35- (layers:plane-x (car x))
36- (layers:plane-y (car x))
37- raylib:+raywhite+))
38- )))
35+ (when (layers:plane-is-display (car x))
36+ (let* ((plane (car x)))
37+ (unless (layers:plane-is-done plane)
38+ (setf (layers:plane-is-done plane) t)
39+ (setf (cdr x) (list
40+ (sdl2:create-texture-from-surface renderer (layers:plane-surface plane))
41+ (sdl2:make-rect 0
42+ 0
43+ (layers:plane-width plane)
44+ (layers:plane-height plane))
45+ (sdl2:make-rect (layers:plane-x plane)
46+ (layers:plane-y plane)
47+ (layers:plane-width plane)
48+ (layers:plane-height plane))
49+ )))
50+ (apply 'apply-texture (cons renderer (cdr x)))
51+ ))))
52+|#
53+;; these two need to be joined in a single function with arbitrary-nested-list explorator
54+;; (which already exists)
55+;;
56+;; !!! plane-surface and model-surface differs, remember to refactor or combine the two
57+(defun render-planes (renderer)
58+ (loop :for x :in +planes-list+
59+ :do
60+ (unless (layers:screen-texture x)
61+ (setf (layers:screen-texture x)
62+ (sdl2:create-texture-from-surface renderer
63+ (layers:plane-surface x))))
64+ (when (layers:screen-displayp x)
65+ (sdl2:render-copy renderer
66+ (layers:screen-texture x)
67+ :source-rect (layers:screen-source x)
68+ :dest-rect (layers:screen-dest x +grid-span+))
69+ )))
3970
40-(defun render-entities ()
71+(defun render-entities (renderer)
4172 (loop :for x :in +entities-list+
4273 :do
43- (if (null (cadr x))
44- (setf (cadr x) (layers:show (car x)))
45- (when (layers:entity-is-display (car x))
46- (raylib:draw-texture-ex (cadr x)
47- (make-vector2
48- :x (* (layers:entity-x (car x)) +grid-span+)
49- :y (* (layers:entity-y (car x)) +grid-span+))
50- (layers:entity-rotation (car x))
51- (/ (* (layers:entity-size (car x)) +grid-span+)
52- (layers:entity-icon-dimension (car x)))
53- raylib:+raywhite+))
54- )))
55-
74+ (unless (layers:screen-texture x)
75+ (setf (layers:screen-texture x)
76+ (sdl2:create-texture-from-surface renderer
77+ (layers:model-surface x))))
78+ (when (layers:screen-displayp x)
79+ (sdl2:render-copy renderer
80+ (layers:screen-texture x)
81+ :source-rect (layers:screen-source x)
82+ :dest-rect (layers:screen-dest x +grid-span+))
83+ )))
5684
5785 ;; check if cadr is null -> if cadr is null eval show and save -> else load
5886
diff -r f1cbf8d801a5 -r 1aeae3aacfcd graphics/view.lisp
--- a/graphics/view.lisp Mon May 02 13:27:33 2022 +0200
+++ b/graphics/view.lisp Sat May 14 22:44:15 2022 +0200
@@ -1,53 +1,46 @@
11 (in-package :graphics)
22 #| -------------------------------------------
33 | This file manipulate the window and the
4- | raylib/sdl initialization.
4+ | sdl initialization.
55 | -------------------------------------------
66 |#
7-;; grid variable to toggle in the repl
8-(defparameter +is-grid+ t)
9-(defparameter +is-grid-letters+ t)
10-(defparameter +camera-movement+ '(0 0))
117
12-;; this is the de-facto main, it initialize and display the graphic items
8+(defmacro with-playground ((window renderer &key (title "RuLP") (width 740) (height 480)) &body body)
9+ `(sdl2:with-window (,window :title title :w width :h height :flags '(:resizable))
10+ (sdl2:with-renderer (,renderer ,window :index -1 :flags '(:accelerated :presentvsync)) ;later add delta
11+ (sdl2-image:init '(:png :jpg))
12+;; (sdl2-ttf:init)
13+ ,@body
14+;; (sdl2-ttf:quit)
15+ (sdl2-image:quit)
16+ )))
17+
1318 (defun playground (width height title &optional (fps 60) (debug-info nil))
14- (defvar mouse-position nil)
15-; (defvar mode +normal-mode+)
16- (defvar camera (make-camera2d
17- :offset (make-vector2 :x 0 :y 0)
18- :target (make-vector2 :x 0 :y 0)
19- :rotation 1.0
20- :zoom 1.0))
21- (raylib:with-window (width height title)
22- (raylib:set-target-fps fps)
23- (raylib:with-mode-2d (camera)
24- (loop :while (not (raylib:window-should-close))
25- :do
26- (setf mouse-position (raylib:get-mouse-position))
27- (loop :for stk :in (eval +mode+)
28- :do (use-mouse stk))
29- (raylib:with-drawing
30- (raylib:clear-background raylib:+black+)
31- ;; render planes
32- (render-planes)
33- ;; render grid and grid's letters
34- (when +is-grid+ (make-grid width height))
35- (when +is-grid-letters+ (make-grid-letters width height))
36- ;; render entities
37- (render-entities)
38- ;; display the pointer, this is actually contained in inputs.lisp
39- (when (numberp +pointer+)
40- (let* ((selected-entity (car (nth +pointer+ +entities-list+)))
41- (i-x (* (layers:entity-x selected-entity) +grid-span+))
42- (i-y (* (layers:entity-y selected-entity) +grid-span+)))
43- (raylib:draw-rectangle-lines i-x
44- i-y
45- (floor (* (layers:entity-size selected-entity) +grid-span+))
46- (floor (* (layers:entity-size selected-entity) +grid-span+))
47- raylib:+red+)))
48- (when (eq +mode+ '+menu-mode+)
49- (display-menu mouse-position))
50- ;; display debug informations if there's any
51- (when debug-info
52- (raylib:draw-text (format nil "D]: ~d" debug-info) 0 0 10 raylib:+lightgray+))
19+ (sdl2:with-init (:video)
20+ (with-playground (window renderer :title title :width width :height height)
21+;; (let *font* ((sdl2-ttf:open-font "media/IBMPlex.ttf" 20))
22+;; here the list must be created
23+ (add-plane (make-instance 'layers:plane))
24+ (add-entity (make-instance 'layers:entity :img-path (truename "media/test.png")))
25+ (sdl2:with-event-loop (:method :poll)
26+ (:quit () t)
27+ (:mousebuttondown (:x x :y y :state state)
28+ (loop :for s :in (eval '+normal-mode+) ;hardcoded
29+ :do (use-mouse x y s)))
30+ (:idle ()
31+ (sdl2:render-clear renderer)
32+ ;; everything section
33+ (render-planes renderer)
34+ (when +is-grid+ (make-grid renderer width height 255 255 255))
35+ ;; (when +is-grid-letters+ (make-grid-letters width height))
36+ (render-entities renderer)
37+ ;; pointer section
38+ (when +pointer+
39+ (sdl2:set-render-draw-color renderer 128 250 33 255)
40+ ;; this need to be adjusted to grid
41+ (sdl2:render-draw-rect renderer (layers:screen-dest (nth +pointer+ +entities-list+) +grid-span+)))
42+ ;; clear renderer
43+ (sdl2:set-render-draw-color renderer 0 0 0 155)
44+ (sdl2:render-present renderer)
5345 )))))
46+;;)
diff -r f1cbf8d801a5 -r 1aeae3aacfcd layers/entities.lisp
--- a/layers/entities.lisp Mon May 02 13:27:33 2022 +0200
+++ b/layers/entities.lisp Sat May 14 22:44:15 2022 +0200
@@ -1,48 +1,17 @@
11 (in-package :layers)
22
3-(defgeneric show (e))
4-(defgeneric placement (e))
5-
6-;; compare 2 arrays
7-(defun compare (a b)
8- (let ((ret t))
9- (loop :for i :across a
10- :for j :across b
11- :do
12- (when (not (equal i j)) (setf ret nil)))
13- ret))
14-
15-(defclass entity ()
16- ((x :accessor entity-x
17- :initarg :x
18- :initform 0)
19- (y :accessor entity-y
20- :initarg :y
21- :initform 0)
22- (name :accessor entity-name
3+(defclass entity (model screen)
4+ ((name :accessor entity-name
235 :initarg :name
24- :initform "no name")
25- (icon :accessor entity-icon
26- :initarg :icon
27- :initform "test.png")
28- (icon-dim :accessor entity-icon-dimension
29- :initarg :icon-dimension
30- :initform 400.0) ;; this assumes images are originally 400x400, to revision
31- (display :accessor entity-is-display
32- :initarg :display
33- :initform t)
6+ :type string
7+ :initform "noname")
348 (size :accessor entity-size
359 :initarg :size
36- :initform 1.0)
37- (rotation :accessor entity-rotation
38- :initarg :rotation
39- :initform 1.0)))
10+ :type integer
11+ :initform 1)))
4012
41-(defmethod show ((e entity))
42- (let* ((ret (raylib:load-texture (entity-icon e))))
43- ret))
44-
45-(defmethod placement ((e entity))
46- (let ((x (slot-value e 'x))
47- (y (slot-value e 'y)))
48- (make-array '(2) :initial-contents (list x y))))
13+(defmethod screen-dest ((e entity) &optional grid)
14+ (sdl2:make-rect (* grid (x e))
15+ (* grid (y e))
16+ (* grid (entity-size e))
17+ (* grid (entity-size e))))
diff -r f1cbf8d801a5 -r 1aeae3aacfcd layers/package.lisp
--- a/layers/package.lisp Mon May 02 13:27:33 2022 +0200
+++ b/layers/package.lisp Sat May 14 22:44:15 2022 +0200
@@ -1,8 +1,12 @@
11 (defpackage :layers
22 (:use :cl :raylib)
3- (:export entity show placement ;; entity functions
4- entity-x entity-y entity-name entity-icon entity-is-display
5- entity-size entity-icon-dimension entity-rotation
6- plane plane-x plane-y image-plane plane-is-display
3+ (:export screen x y w h #|(setf x) (setf y) (setf w) (setf h)|# screen-source screen-dest
4+ screen-texture screen-coordinate screen-dimension screen-displayp screen-rotation
5+ model model-img-path model-surface
6+ entity entity-name entity-size entity-renderer
7+ ;; planes are not updated
8+ plane plane-x plane-y plane-is-display plane-is-done plane-surface plane-image
9+ plane-width plane-height
10+ plane-format
711 compare
812 ))
diff -r f1cbf8d801a5 -r 1aeae3aacfcd layers/planes.lisp
--- a/layers/planes.lisp Mon May 02 13:27:33 2022 +0200
+++ b/layers/planes.lisp Sat May 14 22:44:15 2022 +0200
@@ -1,28 +1,84 @@
11 (in-package :layers)
22
3-(defgeneric show (p))
3+(defclass plane (screen)
4+ ((img-path :accessor plane-img-path
5+ :initarg :img-path
6+ :initform (truename "media/board.tga"))
7+ (surface :reader plane-surface)))
8+;; plane-surface and model-surface do the same thing but they have two different name,
9+;; refactor before continue with arbitrary-nested-lists
10+
11+(defmethod initialize-instance :after ((p plane) &rest args)
12+ (setf (slot-value p 'surface) (sdl2-image:load-image (plane-img-path p)))
13+ (setf (w p) (sdl2:surface-width (plane-surface p)))
14+ (setf (h p) (sdl2:surface-height (plane-surface p))))
15+
16+#|
17+;(defgeneric show (p))
18+
19+(defgeneric plane-x (p)) ; give the x in the board
20+(defgeneric plane-y (p)) ; give the y in the board
21+;(defgeneric plane-surface-x (p)) ; give the x from the surface
22+;(defgeneric plane-surface-y (p)) ; give the y from the surface
23+(defgeneric plane-width (p))
24+(defgeneric plane-height (p))
25+
26+(defgeneric plane-format (rend p)) ; create a list of all elements for sdl2:render-copy
27+(defgeneric plane-rect-source (rend p))
28+(defgeneric plane-rect-destination (rend p))
429
530 ;; this is a generic plane which define basic arguments
631 ;; and let other planes inherit them.
732 (defclass plane ()
8- ((x :accessor plane-x
9- :initarg :x
10- :initform 0)
11- (y :accessor plane-y
12- :initarg :y
13- :initform 0)
33+ ((coordinate :accessor plane-coordinate
34+ :initarg :coordinate
35+ :initform (make-array '(2) :initial-contents '(0 0)))
1436 (display :accessor plane-is-display
1537 :initarg :display
16- :initform t)))
17-
18-(defmethod show ((p plane))
19- (raylib:draw-rectangle 0 0 100 100 raylib:+black+)
20- nil)
21-
22-(defclass image-plane (plane)
23- ((image :accessor plane-image
38+ :initform t)
39+ (done :accessor plane-is-done
40+ :initform nil)
41+ (surface :accessor plane-surface
42+ :initarg :surface
43+ :initform nil)
44+; (alpha :accessor plane-alpha
45+; :initarg :alpha
46+; :initform 255)
47+ (image :accessor plane-image
2448 :initarg :image)))
2549
26-(defmethod show ((p image-plane))
27- (let* ((ret (raylib:load-texture (plane-image p))))
28- ret))
50+(defmethod plane-x ((p plane))
51+ (aref (slot-value p 'coordinate) 0))
52+
53+(defmethod plane-y ((p plane))
54+ (aref (slot-value p 'coordinate) 1))
55+
56+(defmethod (setf plane-x) (value (p plane))
57+ (setf (aref (slot-value p 'coordinate) 0) value))
58+
59+(defmethod (setf plane-y) (value (p plane))
60+ (setf (aref (slot-value p 'coordinate) 1) value))
61+
62+(defmethod plane-width ((p plane))
63+ (if (plane-surface p)
64+ (sdl2:surface-width (plane-surface p))
65+ 0 ; later see if throw an error is necessary
66+ ))
67+
68+(defmethod plane-height ((p plane))
69+ (if (plane-surface p)
70+ (sdl2:surface-height (plane-surface p))
71+ 0 ; later see if throw an error is necessary
72+ ))
73+
74+;; this method generate a list which can be passed through sdl2:render-copy
75+(defmethod plane-format (rend (p plane))
76+ (setf (plane-is-done p) t) ; set the plane as rendered and ready to be used
77+ (list
78+ (sdl2:create-texture-from-surface rend (plane-surface p))
79+ ; srcrectangle
80+ ; destrectangle
81+ ; angle
82+ ; flip
83+ ))
84+|#
diff -r f1cbf8d801a5 -r 1aeae3aacfcd system.asd
--- a/system.asd Mon May 02 13:27:33 2022 +0200
+++ b/system.asd Sat May 14 22:44:15 2022 +0200
@@ -6,8 +6,12 @@
66 :build-operation "program-op"
77 :build-pathname "rulp"
88 :entry-point "core:main"
9- :depends-on ("cffi-libffi" "alexandria" "ltk" "bordeaux-threads" "bt-semaphore")
10- :components ((:module "raylib"
9+; :depends-on ("sdl2" "cffi-libffi" "alexandria" "ltk" "bordeaux-threads" "bt-semaphore")
10+ :depends-on ("sdl2" "sdl2-image" "cffi-libffi" "alexandria" "ltk")
11+ :components ((:module "geometry"
12+ :serial t
13+ :components ((:file "package")))
14+ (:module "raylib"
1115 :serial t
1216 :components ((:file "package")
1317 (:file "library")
@@ -18,6 +22,8 @@
1822 :depends-on ("raylib")
1923 :serial t
2024 :components ((:file "package")
25+ (:file "screens")
26+ (:file "models")
2127 (:file "planes")
2228 (:file "entities")))
2329 (:module "lobby"
@@ -32,4 +38,6 @@
3238 (:file "render" :depends-on ("package"))
3339 (:file "grid" :depends-on ("package"))
3440 (:file "view" :depends-on ("package" "grid" "render" "inputs" "menu"))))
35- (:file "core" :depends-on ("layers" "lobby" "graphics"))))
41+ (:file "package" :depends-on ("layers" "lobby" "graphics"))
42+ (:file "core" :depends-on ("package"))
43+ (:file "data" :depends-on ("package"))))
Show on old repository browser