• R/O
  • SSH

rulp: Commit

The main repository for rulp in Mercurial


Commit MetaInfo

Revision54ad4ac56910fdb8d52a86e0c6b6d8df01c11d0d (tree)
Time2021-04-24 16:51:48
AuthorGiulio De Stasio <giuliods@user...>
CommiterGiulio De Stasio

Log Message

redone mouse control with new actor system

Change Summary

Incremental Difference

diff -r 1c574e873ddf -r 54ad4ac56910 SPECS
--- a/SPECS Fri Apr 23 15:54:33 2021 +0200
+++ b/SPECS Sat Apr 24 09:51:48 2021 +0200
@@ -1,23 +1,68 @@
11 RULP specification - How RULP works
2-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33
4-This document will contain all the information about the
5-mechanic behind rulp, just to comprehend more the mess that
6-is the code.
4+This document will contain all the information about
5+the mechanic behind rulp, just to comprehend more
6+the mess that is the code.
77
88
99 blit-surface, load-image and draw-surface-at
10---------------------------------------------
10+----------------------------------------------------
1111 A important point in the developing of the program:
1212
1313 blit-surface, load-image and draw-surface-at are
14-the most cpu heavy operations in the program, meanwhile
15-a idle cycle work with just 8%, using one of those
16-force the program to execute functions that pump the
17-cpu usage up to 20%. The usage is not linear, in fact
18-using more than one blit-surface or draw-surface-at in a
19-single idle cycle keep the cpu usage to circa 20%.
14+the most cpu heavy operations in the program,
15+meanwhile a idle cycle work with just 8%, using one
16+of those force the program to execute functions that
17+pump the cpu usage up to 20%. The usage is not
18+linear, in fact using more than one blit-surface or
19+draw-surface-at in a single idle cycle keep the cpu
20+usage to circa 20%.
2021
21-The program should be developed in a way blit-surface and
22-draw-surface-at are used the least amount of times and
23-possibly 0 on idle.
22+The program should be developed in a way blit-surface
23+and draw-surface-at are used the least amount of
24+times and possibly 0 on idle.
25+
26+Spaces, the actor space and the layer standard space
27+----------------------------------------------------
28+Some object threat space in different ways. The RULP
29+structure and mathematics is developed in the actor
30+space, part of the actor package (actually non
31+present). This space is actually the vectorial
32+space Z^2, where the coordinates are saved as two
33+ordinate integers.
34+
35+This coordinates are separate from the one visualized
36+on screen and are the one viewable and setfable with
37+entity-coordinate and the couple e-x and e-y (this
38+two are handler to get and modify the singular
39+coordinate without having to get the whole array and
40+modify it).
41+
42+Entity and actors are saved in this system and is
43+actually indipendent from the grid.
44+
45+Actors are saved into actors layers which convert
46+the actor coordinate into the pixel coordinate based
47+on the grid used. This system actually make possible
48+to generate different style and dimensions of grids
49+mantaining an abstraction in term of position in the
50+grid.
51+
52+The layers
53+----------------------------------------------------
54+Layers are special classes, based on the layer class,
55+that abstract object that are displayed on screen.
56+Layers generally define just one generic (render-layer)
57+that translate the abstraction into actual sdl code
58+drawed on a imported surface. This surface should be
59+considered blank or newly every time this function
60+is executed.
61+
62+Also is worth mention this function can cause the
63+ram hog bug, this should be used few times during
64+the whole program execution, surfaces and images
65+developed in this section often are not garbage
66+collected. If you want to implement a layer with
67+multiple things in it, is suggested to split all the
68+layers or to make attention on the ram usage.
diff -r 1c574e873ddf -r 54ad4ac56910 sdl.lisp
--- a/sdl.lisp Fri Apr 23 15:54:33 2021 +0200
+++ b/sdl.lisp Sat Apr 24 09:51:48 2021 +0200
@@ -38,16 +38,17 @@
3838 ((eql e :sdl-key-down)(actor-move-down pointed-actor))
3939 ((eql e :sdl-key-space)(setf pointer (mod (+ 1 pointer) (length actor-layer-list)))))))
4040 (setf *renderize* t))
41-; (:mouse-button-down-event (:x s-x :y s-y)
42-; (let* ((actor-layer-list (remove-if-not #'(lambda (x) (typep x 'actor-layer)) layer-list))
43-; (coordinate-list (map 'list #'(lambda (x) (entity-coordinate (layer-actor x))) (layer-actors actor-layer-list)))
44-; (grid 50)
45-; (pointer-actor-x (floor (/ s-x grid)))
46-; (pointer-actor-y (floor (/ s-y grid)))
47-; (pointer-coordinate (make-array '(2) :initial-contents (list pointer-actor-x pointer-actor-y))))
48-; (setf pointer (position-if #'(lambda (x) (compare x pointer-coordinate)) coordinate-list))
49-; (if (not pointer) (setf pointer 0)))
50-; (setf *renderize* t))
41+ (:mouse-button-down-event (:x s-x :y s-y)
42+ (let* ((actor-layer-list (remove-if-not #'(lambda (x) (typep x 'actor-layer)) layer-list))
43+ (coordinate-list (map 'list #'(lambda (x) (entity-coordinate (layer-actor x))) actor-layer-list))
44+ (grid 50)
45+ (actual-pointer pointer)
46+ (point-to-find-x (floor (/ s-x grid)))
47+ (point-to-find-y (floor (/ s-y grid)))
48+ (point-to-find-coo (make-array '(2) :initial-contents (list point-to-find-x point-to-find-y))))
49+ (setf pointer (position-if #'(lambda (x) (compare x point-to-find-coo)) coordinate-list))
50+ (if (not pointer) (setf pointer actual-pointer)))
51+ (setf *renderize* t))
5152 (:idle ()
5253 (when *renderize*
5354 (sdl:clear-display sdl:*black*)
Show on old repository browser