add dev level and get info pads working
This commit is contained in:
parent
7e75b665f5
commit
276c7c562b
10 changed files with 246 additions and 13 deletions
|
|
@ -1,3 +1,4 @@
|
|||
(local utils (require "src/utils.fnl"))
|
||||
(local beholder (require "libs/beholder"))
|
||||
(local color (require "src/colors.fnl"))
|
||||
(local levels (require "levels.fnl"))
|
||||
|
|
@ -25,9 +26,23 @@
|
|||
|
||||
(local width 19)
|
||||
(local height 15)
|
||||
(local player { :x 50 :y 50 :w 25 :h 25 :speed 80 :battery 100 :rot 0 :hitbox [50 50 width height] })
|
||||
(local player {
|
||||
:x 50 :y 50 :w 25 :h 25 :speed 80 :battery 100 :rot 0
|
||||
:hitbox [50 50 width height]
|
||||
:init-move false ; nudge the player at start of game to trigger starting collisions
|
||||
})
|
||||
|
||||
|
||||
(lambda handle-collisions [cols]
|
||||
(each [_ col (pairs cols)]
|
||||
(when col.other.on-hit (col.other:on-hit))
|
||||
(beholder.trigger "PLAYER.HIT" col.other)))
|
||||
|
||||
(fn player.update [self dt]
|
||||
(when (= self.init-move false)
|
||||
(set self.init-move true)
|
||||
(let [(x y cols len) (bump-world:move self self.x self.y bump-filter)]
|
||||
(handle-collisions cols)))
|
||||
(let [
|
||||
d-key (love.keyboard.isDown :d)
|
||||
a-key (love.keyboard.isDown :a)
|
||||
|
|
@ -45,6 +60,7 @@
|
|||
new-x (dir-fn self.x (* self.speed dt (math.cos self.rot)))
|
||||
new-y (dir-fn self.y (* self.speed dt (math.sin self.rot)))
|
||||
(x y cols len) (bump-world:move self new-x new-y bump-filter)]
|
||||
(handle-collisions cols)
|
||||
(set self.x x)
|
||||
(set self.y y))
|
||||
(if (> self.battery 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue