get player rendering
This commit is contained in:
parent
c4c33e4726
commit
c577295c3e
3 changed files with 51 additions and 27 deletions
|
|
@ -1,3 +1,4 @@
|
|||
(local beholder (require "libs/beholder"))
|
||||
(local colors (require "src/colors.fnl"))
|
||||
(local levels (require "levels.fnl"))
|
||||
(local assets (require "src/assets.fnl"))
|
||||
|
|
@ -16,6 +17,10 @@
|
|||
(. directions (+ (% section 8) 1)))
|
||||
|
||||
(local player { :x 50 :y 50 :w 25 :h 25 :speed 80 :battery 100 :rot 0 })
|
||||
|
||||
(fn player.update [self dt]
|
||||
(beholder.trigger "PLAYER.POS" self.x self.y))
|
||||
|
||||
(fn player.load [self level-key]
|
||||
(set self.battery 100)
|
||||
(set self.x (. levels :levels level-key :spawns :player-1 :x))
|
||||
|
|
@ -36,7 +41,7 @@
|
|||
}))
|
||||
)
|
||||
|
||||
(fn player.draw [self state]
|
||||
(fn player.draw50 [self]
|
||||
"draw player sprite and hitbox"
|
||||
(colors:reset-color)
|
||||
(love.graphics.draw
|
||||
|
|
@ -44,15 +49,16 @@
|
|||
(. self.quads (angle-to-direction player.rot))
|
||||
self.x self.y)
|
||||
;; draw player hitbox and direction line
|
||||
(when state.debug
|
||||
(colors:set-color :black)
|
||||
(love.graphics.rectangle "line" self.x self.y self.w self.h)
|
||||
(love.graphics.push)
|
||||
(let [ox (+ self.x (/ 25 2)) oy (+ self.y (/ 25 2))]
|
||||
(love.graphics.translate ox oy)
|
||||
(love.graphics.rotate self.rot)
|
||||
(love.graphics.line 0 0 35 0))
|
||||
(love.graphics.pop)))
|
||||
; (when state.debug
|
||||
; (colors:set-color :black)
|
||||
; (love.graphics.rectangle "line" self.x self.y self.w self.h)
|
||||
; (love.graphics.push)
|
||||
; (let [ox (+ self.x (/ 25 2)) oy (+ self.y (/ 25 2))]
|
||||
; (love.graphics.translate ox oy)
|
||||
; (love.graphics.rotate self.rot)
|
||||
; (love.graphics.line 0 0 35 0))
|
||||
; (love.graphics.pop))
|
||||
)
|
||||
|
||||
|
||||
player
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue