summaryrefslogtreecommitdiff
path: root/src/player.fnl
diff options
context:
space:
mode:
Diffstat (limited to 'src/player.fnl')
-rw-r--r--src/player.fnl21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/player.fnl b/src/player.fnl
index a429282..68d4f27 100644
--- a/src/player.fnl
+++ b/src/player.fnl
@@ -1,9 +1,11 @@
-(local player { :x 250 :y 250 })
-
(local SPEED 170)
(local SPRINT-SPEED 280)
-(fn player.move [self dt world]
+(local C {})
+(set C.__index C)
+
+(fn C.update [self dt ?world]
+ (print ((. (require :vendor.fennel) :view) self))
(let [speed (if (love.keyboard.isScancodeDown :lshift :rshift)
SPRINT-SPEED SPEED)
up (if (love.keyboard.isScancodeDown :w :up) 1 0)
@@ -12,7 +14,9 @@
right (if (love.keyboard.isScancodeDown :d :right) 1 0)
vy (- down up)
vx (- right left)
- sf (math.sqrt (+ (* vx vx) (* vy vy)))]
+ sf (math.sqrt (+ (* vx vx) (* vy vy)))
+ world (if ?world ?world
+ {:move (fn move [_2 tx ty] (values tx ty))})]
(when (not= sf 0)
(let [vx (/ vx sf)
vy (/ vy sf)
@@ -22,8 +26,13 @@
(tset self :x ax)
(tset self :y ay)))))
-(fn player.draw [self]
+(fn C.draw [self]
(love.graphics.setColor 0.91 0.62 0)
(love.graphics.rectangle :fill self.x self.y 10 10))
-player
+(fn make []
+ (let [s {:x 170 :y 150}]
+ (setmetatable s C)
+ s))
+
+{: make}