add reverse tire movment
This commit is contained in:
parent
449145cf20
commit
8d4745832d
1 changed files with 17 additions and 9 deletions
|
|
@ -133,20 +133,28 @@ while 1 do love.event.push('stdin', io.read('*line')) end") :start))
|
||||||
(love.graphics.rectangle "line" collider.x collider.y collider.width collider.height))))
|
(love.graphics.rectangle "line" collider.x collider.y collider.width collider.height))))
|
||||||
|
|
||||||
(fn love.update [dt]
|
(fn love.update [dt]
|
||||||
; rotate player
|
; move / rotate player
|
||||||
(if (and (love.keyboard.isDown :d) (not (love.keyboard.isDown :a)))
|
|
||||||
(tset player :rot (+ player.rot (* dt 2))))
|
|
||||||
|
|
||||||
(if (and (love.keyboard.isDown :a) (not (love.keyboard.isDown :d)))
|
|
||||||
(tset player :rot (- player.rot (* dt 2))))
|
|
||||||
|
|
||||||
(if (or (love.keyboard.isDown :a) (love.keyboard.isDown :d))
|
|
||||||
(let [
|
(let [
|
||||||
new-x (+ player.x (* player.speed dt (math.cos player.rot)))
|
d (love.keyboard.isDown :d)
|
||||||
new-y (+ player.y (* player.speed dt (math.sin player.rot)))
|
a (love.keyboard.isDown :a)
|
||||||
|
e (love.keyboard.isDown :e)
|
||||||
|
q (love.keyboard.isDown :q)]
|
||||||
|
|
||||||
|
(case [d a e q]
|
||||||
|
[true false false false] (tset player :rot (+ player.rot (* dt 2)))
|
||||||
|
[false true false false] (tset player :rot (- player.rot (* dt 2)))
|
||||||
|
[false false true false] (tset player :rot (- player.rot (* dt 2)))
|
||||||
|
[false false false true] (tset player :rot (+ player.rot (* dt 2)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(if (or d a e q)
|
||||||
|
(let [
|
||||||
|
dir-fn (if (or d a) #(+ $1 $2) #(- $1 $2))
|
||||||
|
new-x (dir-fn player.x (* player.speed dt (math.cos player.rot)))
|
||||||
|
new-y (dir-fn player.y (* player.speed dt (math.sin player.rot)))
|
||||||
(x y) (bump-world:move player new-x new-y)]
|
(x y) (bump-world:move player new-x new-y)]
|
||||||
(tset player :x x)
|
(tset player :x x)
|
||||||
(tset player :y y)))
|
(tset player :y y))))
|
||||||
|
|
||||||
;; Update camera to follow player (keep player centered on screen)
|
;; Update camera to follow player (keep player centered on screen)
|
||||||
(tset camera :x (- player.x (/ screen.canvas-w 2)))
|
(tset camera :x (- player.x (/ screen.canvas-w 2)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue