aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interactive
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2024-12-14 12:29:29 -0800
committercolin <colin@cicadas.surf>2024-12-14 12:29:29 -0800
commit543704f0f54cbb1de78754ad8a323c482ab6829c (patch)
tree7528c0105516a2a2800e432de9f4f1a6c3fe506e /src/interactive
parent3a2217263d581be9a7f629b10d75aa8e3d581890 (diff)
Loop style nitsHEADmain
Diffstat (limited to 'src/interactive')
-rw-r--r--src/interactive/canvas.lisp13
-rw-r--r--src/interactive/frameset.lisp50
-rw-r--r--src/interactive/interactive.lisp5
-rw-r--r--src/interactive/sprite.lisp15
4 files changed, 42 insertions, 41 deletions
diff --git a/src/interactive/canvas.lisp b/src/interactive/canvas.lisp
index f4b2b74..2accb8a 100644
--- a/src/interactive/canvas.lisp
+++ b/src/interactive/canvas.lisp
@@ -75,13 +75,12 @@
(,g (aref ,px 1))
(,b (aref ,px 2))
(,a (aref ,px 3)))
- (loop for ,x from (if ,lv ,lv 0) below (if ,rv ,rv (pixel-width ,pxs)) do
- (loop for ,y from (if ,bv ,bv 0) below (if ,tv ,tv (pixel-height ,pxs))
- do (progn
- (setf ,px (adjust-array ,px 4
- :displaced-to (pixels-data ,pxs)
- :displaced-index-offset (pixel-offset ,x ,y ,pxs)))
- ,@body)))))))
+ (loop :for ,x :from (if ,lv ,lv 0) :below (if ,rv ,rv (pixel-width ,pxs)) :do
+ (loop :for ,y :from (if ,bv ,bv 0) :below (if ,tv ,tv (pixel-height ,pxs)) :do
+ (setf ,px (adjust-array ,px 4
+ :displaced-to (pixels-data ,pxs)
+ :displaced-index-offset (pixel-offset ,x ,y ,pxs)))
+ ,@body))))))
(defun clear-canvas (canvas &key (r 0) (g 0) (b 0) (a 255))
(with-pixels-rect (x y pr pg pb pa) (canvas)
diff --git a/src/interactive/frameset.lisp b/src/interactive/frameset.lisp
index 65762c7..c6abb4b 100644
--- a/src/interactive/frameset.lisp
+++ b/src/interactive/frameset.lisp
@@ -36,21 +36,21 @@
(incf (frameset-next-time target) (frameset-wait-time target)))))
(defmethod cleanup ((frameset frameset))
- (loop for frame across (frameset-frames frameset) do (cleanup frame)))
+ (loop :for frame :across (frameset-frames frameset) :do (cleanup frame)))
(defmethod initialize-instance :after ((fs frameset) &key)
(add-handler fs #'check-advance-frameset-index)
(with-slots (index sequence count frames x y scale-x scale-y rotation) fs
(setf index 0
count (length sequence))
- (loop for frame across frames
- when frame
- do (setf (unit-in-scene-p frame) fs
- (x frame) x
- (y frame) y
- (scale-x frame) scale-x
- (scale-y frame) scale-y
- (rotation frame) rotation))))
+ (loop :for frame :across frames
+ :when frame
+ :do (setf (unit-in-scene-p frame) fs
+ (x frame) x
+ (y frame) y
+ (scale-x frame) scale-x
+ (scale-y frame) scale-y
+ (rotation frame) rotation))))
(defun current-frame-unit (fs)
"Returns the unit be currently displaayed as the animation's frame."
@@ -63,16 +63,16 @@
(macrolet
((def-frameset-accessors (&rest accessor-names)
(let ((defs
- (loop for accessor-name in accessor-names
- collect
+ (loop :for accessor-name :in accessor-names
+ :collect
`(defmethod ,accessor-name ((fs frameset))
(,accessor-name (current-frame-unit fs)))
- collect
+ :collect
`(defmethod (setf ,accessor-name) (newval (fs frameset))
- (loop for frame across (frameset-frames fs)
- when frame
- do (setf (,accessor-name frame) newval))
+ (loop :for frame :across (frameset-frames fs)
+ :when frame
+ :do (setf (,accessor-name frame) newval))
newval))))
`(progn ,@defs))))
@@ -86,16 +86,16 @@
(let* ((asset-names
(remove-duplicates sequenced-assets :test #'equal))
(images
- (loop for name in asset-names
- collect
+ (loop :for name :in asset-names
+ :collect
(make-instance
- 'image
- :texture (get-asset name :asset-args asset-args))))
+ 'image
+ :texture (get-asset name :asset-args asset-args))))
(sequence
- (loop for name in sequenced-assets
- collect (position name asset-names :test #'equal))))
+ (loop :for name :in sequenced-assets
+ :collect (position name asset-names :test #'equal))))
(make-instance
- 'frameset
- :frames (make-array (length images) :initial-contents images)
- :sequence (make-array (length sequence) :initial-contents sequence)
- :wait-time (/ 1000.0 fps))))
+ 'frameset
+ :frames (make-array (length images) :initial-contents images)
+ :sequence (make-array (length sequence) :initial-contents sequence)
+ :wait-time (/ 1000.0 fps))))
diff --git a/src/interactive/interactive.lisp b/src/interactive/interactive.lisp
index 74a22d1..8355329 100644
--- a/src/interactive/interactive.lisp
+++ b/src/interactive/interactive.lisp
@@ -12,8 +12,9 @@
(defun remove-all-handlers (interactive)
(loop
- for type in '(keydown keyup mousedown mouseup mousemotion mousewheel focus blur perframe)
- do (remove-handler interactive type)))
+ :for type
+ :in '(keydown keyup mousedown mouseup mousemotion mousewheel focus blur perframe)
+ :do (remove-handler interactive type)))
(defmethod cleanup :after ((ob interactive))
(remove-all-handlers ob))
diff --git a/src/interactive/sprite.lisp b/src/interactive/sprite.lisp
index dd9b2a1..c212418 100644
--- a/src/interactive/sprite.lisp
+++ b/src/interactive/sprite.lisp
@@ -15,8 +15,9 @@
(defmethod initialize-instance :after ((sprite sprite) &key)
(with-slots (framesets frameset-key) sprite
- (loop for (name fs . more) on framesets by #'cddr
- do (setf (unit-in-scene-p fs) sprite))
+ (loop :for (name fs . more) :on framesets :by #'cddr :do
+ (setf (unit-in-scene-p fs) sprite))
+
(unless frameset-key
(setf frameset-key (first framesets)))))
@@ -30,15 +31,15 @@
(macrolet
((def-sprite-accessors (&rest accessor-names)
(let ((defs
- (loop for accessor-name in accessor-names
- collect
+ (loop :for accessor-name :in accessor-names
+ :collect
`(defmethod ,accessor-name ((sprite sprite))
(,accessor-name (current-frameset sprite)))
- collect
+ :collect
`(defmethod (setf ,accessor-name) (newval (sprite sprite))
- (loop for (key fs . more) on (sprite-framesets sprite) by #'cddr
- do (setf (,accessor-name fs) newval))
+ (loop :for (key fs . more) :on (sprite-framesets sprite) :by #'cddr
+ :do (setf (,accessor-name fs) newval))
newval))))
`(progn ,@defs))))