init
This commit is contained in:
38
player/player.lua
Normal file
38
player/player.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
local Player = {}
|
||||
|
||||
|
||||
|
||||
Player.x = (1920 / 2) - 500
|
||||
Player.y = (1080 / 2)
|
||||
Player.scale = 5
|
||||
Player.offset_x = 0
|
||||
Player.offset_y = 25
|
||||
|
||||
Player.direction = 0
|
||||
|
||||
Player.spriteSheet = love.graphics.newImage("assets/Sprites/flame_dude_dark_94x64.png")
|
||||
Player.grid = Anim8.newGrid(94, 64, Player.spriteSheet:getWidth(), Player.spriteSheet:getHeight())
|
||||
Player.animations = {}
|
||||
Player.animations.idle = Anim8.newAnimation(Player.grid("1-6", 1), 0.2)
|
||||
Player.animations.right = Anim8.newAnimation(Player.grid("1-6", 2), 0.1)
|
||||
Player.collider = World:newCollider("Polygon", { 100, 100, 100 + 40, 80, 100 + 40, 100 + 80, 100, 100 + 80 })
|
||||
Player.collider:setFixedRotation(true)
|
||||
|
||||
|
||||
function Player:update(dt, state)
|
||||
if state == 0 then
|
||||
self.animations.idle:update(dt)
|
||||
else
|
||||
self.animations.right:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
function Player:draw(state)
|
||||
if state == 0 then
|
||||
self.animations.idle:draw(self.spriteSheet, self.x, self.y, nil, self.scale, nil, self.offset_x, self.offset_y)
|
||||
else
|
||||
self.animations.right:draw(self.spriteSheet, self.x, self.y, nil, self.scale, nil, self.offset_x, self.offset_y)
|
||||
end
|
||||
end
|
||||
|
||||
return Player
|
||||
Reference in New Issue
Block a user