summaryrefslogtreecommitdiff
path: root/src/player.fnl
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-05-06 01:09:07 +0100
committerubq323 <ubq323@ubq323.website>2022-05-06 01:09:07 +0100
commit7e8a6f1b60d3d279a14f355e76e3b1e43c0e181a (patch)
treef72e40fdfedd67e00a267adf37cac0b754f78ffc /src/player.fnl
parent7dd3caa70e641d7c6f72390d39c77a7bf2544746 (diff)
more paralax, and wallsHEADtrunk
Diffstat (limited to 'src/player.fnl')
-rw-r--r--src/player.fnl19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/player.fnl b/src/player.fnl
index 53ceb59..702d466 100644
--- a/src/player.fnl
+++ b/src/player.fnl
@@ -4,7 +4,7 @@
(local C {})
(set C.__index C)
-(fn C.update [self dt ?world]
+(fn C.update [self dt world]
(let [speed (if (love.keyboard.isScancodeDown :lshift :rshift)
SPRINT-SPEED SPEED)
up (if (love.keyboard.isScancodeDown :w :up) 1 0)
@@ -13,9 +13,9 @@
right (if (love.keyboard.isScancodeDown :d :right) 1 0)
vy (- down up)
vx (- right left)
- sf (math.sqrt (+ (* vx vx) (* vy vy)))
- world (if ?world ?world
- {:move (fn move [_1 _2 tx ty] (values tx ty))})]
+ sf (math.sqrt (+ (* vx vx) (* vy vy)))]
+ ; world (if ?world ?world
+ ; {:move (fn move [_1 _2 tx ty] (values tx ty))})]
(when (not= sf 0)
(if (> vx 0) (set self.left false)
(< vx 0) (set self.left true))
@@ -23,13 +23,16 @@
vy (/ vy sf)
tx (+ self.x (* vx dt speed))
ty (+ self.y (* vy dt speed))
- (ax ay) (world:move :player tx ty)]
+ (ax ay) (if world
+ (world:move :player tx ty)
+ (values tx ty))]
(set self.x ax)
(set self.y ay)))))
(fn C.draw [self]
(love.graphics.push)
(love.graphics.translate self.x self.y)
+ (love.graphics.translate 15 15)
(if self.left
(love.graphics.scale -1 1))
(love.graphics.scale 0.1)
@@ -55,8 +58,10 @@
-(fn make []
- (let [s {:x 170 :y 150 :left false}]
+(fn make [?x ?y]
+ (let [x (or ?x 170)
+ y (or ?y 150)
+ s {: x : y :left false}]
(setmetatable s C)
s))