• R/O
  • SSH

rulp: Commit

The main repository for rulp in Mercurial


Commit MetaInfo

Revision592642a7a3b1cdcf53b2a4ab6a80e6f1d3364b24 (tree)
Time2022-05-02 20:26:36
AuthorGiulio De Stasio <giuliods@user...>
CommiterGiulio De Stasio

Log Message

inverted rendering positions

Change Summary

Incremental Difference

diff -r 14b6e681c9c8 -r 592642a7a3b1 .hgignore
--- a/.hgignore Mon Apr 18 15:16:27 2022 +0200
+++ b/.hgignore Mon May 02 13:26:36 2022 +0200
@@ -9,3 +9,4 @@
99 *.rpm
1010 *~undo-tree~
1111 kick.lisp
12+TAGS
diff -r 14b6e681c9c8 -r 592642a7a3b1 core.lisp
--- a/core.lisp Mon Apr 18 15:16:27 2022 +0200
+++ b/core.lisp Mon May 02 13:26:36 2022 +0200
@@ -7,10 +7,12 @@
77 (defparameter *screen-width* 1024)
88 (defparameter *screen-height* 768)
99
10+;; apply to load and save
11+
1012 (defun main ()
1113 ;(bt:make-thread (lambda () (lobby:editor-gui))) ;; here bt-thread it is just used for execute ltk without troubles
1214 ;; for now it is disabled
13- (graphics:add-entity (make-instance 'layers:entity :icon "test.png" :size 2.0))
15+ (graphics:add-entity (make-instance 'layers:entity :icon "test.png" :size 1.0))
1416
1517 (bt:make-thread (lambda () (graphics:playground *screen-width* *screen-height* "Ru*** Lisp Playground")))
1618 )
diff -r 14b6e681c9c8 -r 592642a7a3b1 graphics/grid.lisp
--- a/graphics/grid.lisp Mon Apr 18 15:16:27 2022 +0200
+++ b/graphics/grid.lisp Mon May 02 13:26:36 2022 +0200
@@ -2,6 +2,12 @@
22
33 (defparameter +grid-span+ 70)
44
5+; these two functions can be edited when different grids will be added
6+(defun position-actor-to-view (a)
7+ (* a +grid-span+))
8+(defun position-view-to-actor (a)
9+ (/ a +grid-span+))
10+
511 (defparameter +letters-list+
612 '("A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M"
713 "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z"))
@@ -10,6 +16,16 @@
1016 (defun letter-cycle (n)
1117 (nth (mod n (length +letters-list+)) +letters-list+))
1218
19+(defun toggle-grid ()
20+ (if +is-grid+
21+ (setf +is-grid+ nil)
22+ (setf +is-grid+ t)))
23+
24+(defun toggle-grid-letters ()
25+ (if +is-grid-letters+
26+ (setf +is-grid-letters+ nil)
27+ (setf +is-grid-letters+ t)))
28+
1329 (defun make-grid (screen-width screen-height)
1430 (let ((x-iterations (/ screen-width +grid-span+))
1531 (y-iterations (/ screen-height +grid-span+)))
@@ -33,8 +49,8 @@
3349 (loop :for i :from 0 :to x-iterations
3450 :do (loop :for j :from 0 :to y-iterations
3551 :do (raylib:draw-text (format nil "~d~d" (letter-cycle i) j)
36- (+ (* i +grid-span+) 2)
37- (+ (* j +grid-span+) 2)
52+ (+ (position-actor-to-view i) 2)
53+ (+ (position-actor-to-view j) 2)
3854 30
3955 raylib:+lightgray+)))
4056 ))
diff -r 14b6e681c9c8 -r 592642a7a3b1 graphics/inputs.lisp
--- a/graphics/inputs.lisp Mon Apr 18 15:16:27 2022 +0200
+++ b/graphics/inputs.lisp Mon May 02 13:26:36 2022 +0200
@@ -1,6 +1,7 @@
11 (in-package :graphics)
22
33 (defparameter +pointer+ nil) ; this parameter check out which entity is selected
4+(defparameter +mode+ '+normal-mode+)
45
56 (defun select-pointer (mouse-x mouse-y)
67 (let* ((obj-list (map 'list #'(lambda (o) (car o)) +entities-list+))
@@ -33,12 +34,10 @@
3334 '(raylib:+mouse-right-button+ (move-entity
3435 (raylib:vector2-x mouse-position)
3536 (raylib:vector2-y mouse-position)))
36- '(raylib:+mouse-middle-button+ (toggle-grid-letters))))
37+ '(raylib:+mouse-middle-button+ (setf +mode+ '+menu-mode+))))
3738
3839 (defparameter +menu-mode+ (list
39- '(raylib:+mouse-left-button+ (format t "L"))
40- '(raylib:+mouse-right-button+ (format t "R"))
41- '(raylib:+mouse-middle-button+ (format t "M"))))
40+ '(raylib:+mouse-left-button+ (select-menu mouse-position))))
4241
4342 ;; This simple function check if the given stroke is pressed, then return's it if it is
4443 (defun use-mouse (stroke)
diff -r 14b6e681c9c8 -r 592642a7a3b1 graphics/view.lisp
--- a/graphics/view.lisp Mon Apr 18 15:16:27 2022 +0200
+++ b/graphics/view.lisp Mon May 02 13:26:36 2022 +0200
@@ -7,53 +7,47 @@
77 ;; grid variable to toggle in the repl
88 (defparameter +is-grid+ t)
99 (defparameter +is-grid-letters+ t)
10-
11-(defun toggle-grid ()
12- (if +is-grid+
13- (setf +is-grid+ nil)
14- (setf +is-grid+ t)))
15-
16-(defun toggle-grid-letters ()
17- (if +is-grid-letters+
18- (setf +is-grid-letters+ nil)
19- (setf +is-grid-letters+ t)))
10+(defparameter +camera-movement+ '(0 0))
2011
2112 ;; this is the de-facto main, it initialize and display the graphic items
2213 (defun playground (width height title &optional (fps 60) (debug-info nil))
2314 (defvar mouse-position nil)
24- (defvar mode +normal-mode+)
15+; (defvar mode +normal-mode+)
2516 (defvar camera (make-camera2d
2617 :offset (make-vector2 :x 0 :y 0)
2718 :target (make-vector2 :x 0 :y 0)
2819 :rotation 1.0
2920 :zoom 1.0))
3021 (raylib:with-window (width height title)
31- (raylib:set-target-fps fps)
32- (raylib:with-mode-2d (camera)
22+ (raylib:set-target-fps fps)
23+ (raylib:with-mode-2d (camera)
3324 (loop :while (not (raylib:window-should-close))
3425 :do
35- (setf mouse-position (raylib:get-mouse-position))
36- (loop :for stk :in mode
37- :do (use-mouse stk))
38- (raylib:with-drawing
39- (raylib:clear-background raylib:+black+)
40- ;; render grid and grid's letters
41- (when +is-grid+ (make-grid width height))
42- (when +is-grid-letters+ (make-grid-letters width height))
43- ;; render entities and planes
44- (render-planes)
45- (render-entities)
46- ;; display the pointer, this is actually contained in inputs.lisp
47- (when (numberp +pointer+)
48- (let* ((selected-entity (car (nth +pointer+ +entities-list+)))
49- (i-x (* (layers:entity-x selected-entity) +grid-span+))
50- (i-y (* (layers:entity-y selected-entity) +grid-span+)))
51- (raylib:draw-rectangle-lines i-x
52- i-y
53- (floor (* (layers:entity-size selected-entity) +grid-span+))
54- (floor (* (layers:entity-size selected-entity) +grid-span+))
55- raylib:+red+)))
56- ;; display debug informations if there's any
57- (when debug-info
58- (raylib:draw-text (format nil "D]: ~d" debug-info) 0 0 10 raylib:+lightgray+))
59- )))))
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+))
53+ )))))
diff -r 14b6e681c9c8 -r 592642a7a3b1 raylib/package.lisp
--- a/raylib/package.lisp Mon Apr 18 15:16:27 2022 +0200
+++ b/raylib/package.lisp Mon May 02 13:26:36 2022 +0200
@@ -361,6 +361,7 @@
361361 #:draw-ring-lines
362362 #:draw-rectangle
363363 #:draw-rectangle-rec
364+ #:draw-rectangle-v
364365 #:draw-rectangle-pro
365366 #:draw-rectangle-gradient-v
366367 #:draw-rectangle-gradient-h
diff -r 14b6e681c9c8 -r 592642a7a3b1 system.asd
--- a/system.asd Mon Apr 18 15:16:27 2022 +0200
+++ b/system.asd Mon May 02 13:26:36 2022 +0200
@@ -28,8 +28,8 @@
2828 :depends-on ("raylib")
2929 :components ((:file "package")
3030 (:file "inputs" :depends-on ("package"))
31-; (:file "menu" :depends-on ("package"))
31+ (:file "menu" :depends-on ("package"))
3232 (:file "render" :depends-on ("package"))
3333 (:file "grid" :depends-on ("package"))
34- (:file "view" :depends-on ("package" "grid" "render" "inputs"))))
34+ (:file "view" :depends-on ("package" "grid" "render" "inputs" "menu"))))
3535 (:file "core" :depends-on ("layers" "lobby" "graphics"))))
Show on old repository browser