OSDN Git Service

core.lisp: created cli interface and json maps
[rulp/rulp.git] / graphics / render.lisp
index 927f421..0447bf7 100644 (file)
         (cons (car list) (remove-nth (1- k) (cdr list)))
        )))
 
-(defun make-grid (width height span)
+(defun make-grid (span)
   "create a square grid"
-  (loop :for i :from 0 :to width :by span
-        :do (sdl2:render-draw-line *renderer* i 0 i height))
-  (loop :for j :from 0 :to height :by span
-        :do (sdl2:render-draw-line *renderer* 0 j width j)))
+  (loop :for i :from 0 :to *window-width* :by span
+        :do (sdl2:render-draw-line *renderer* i 0 i *window-height*))
+  (loop :for j :from 0 :to *window-height* :by span
+        :do (sdl2:render-draw-line *renderer* 0 j *window-width* j)))
+
+(defun find-on-plane (x y plane)
+  "find the entity in real-coordinates (x,y) in plane"
+  (let ((mouse-point (sdl2:make-rect (- x 2) (- y 2) 2 2))
+        (entities (entities-list plane)))
+    (loop :for entity :in entities
+          :do (when (sdl2:has-intersect mouse-point
+                                        (screen-destination entity plane))
+                entity))))