added player sprite
This commit is contained in:
BIN
assets/images/player.aseprite
Normal file
BIN
assets/images/player.aseprite
Normal file
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 511 B |
@@ -1,5 +1,6 @@
|
||||
local LoveNode = require 'src.utils.love_node'
|
||||
local vector = require 'packages.vector-light'
|
||||
local anim8 = require 'packages.anim8'
|
||||
|
||||
|
||||
local Player = {}
|
||||
@@ -14,7 +15,7 @@ function Player.new(startX, startY, game)
|
||||
self.stats.moveSpeed = 75
|
||||
|
||||
self.size = {}
|
||||
self.size.w, self.size.h = 12, 12 -- self.texture:getDimensions()
|
||||
self.size.w, self.size.h = 12, 10
|
||||
|
||||
self.pos = {}
|
||||
self.pos.x = startX + ((TILE_SIZE - self.size.w) / 2)
|
||||
@@ -27,6 +28,13 @@ function Player.new(startX, startY, game)
|
||||
self.isLightOn = false
|
||||
|
||||
self.texture = love.graphics.newImage 'assets/images/player.png'
|
||||
local g = anim8.newGrid(self.size.w, self.size.h, self.texture:getDimensions())
|
||||
self.animations = {}
|
||||
self.animations.right = anim8.newAnimation(g('1-2', 1), 0.5)
|
||||
self.animations.left = anim8.newAnimation(g('3-4', 1), 0.5)
|
||||
self.animations.up = anim8.newAnimation(g('5-6', 1), 0.5)
|
||||
self.animations.down = anim8.newAnimation(g('7-8', 1), 0.5)
|
||||
self.animations.current = self.animations.down
|
||||
|
||||
self.game = game
|
||||
self.game.world:add(self, self.pos.x, self.pos.y, self.size.w, self.size.h)
|
||||
@@ -54,6 +62,18 @@ function Player:update(dt)
|
||||
return 'slide'
|
||||
end
|
||||
)
|
||||
|
||||
if futureVelX > 0 then
|
||||
self.animations.current = self.animations.right
|
||||
elseif futureVelX < 0 then
|
||||
self.animations.current = self.animations.left
|
||||
end
|
||||
if futureVelY > 0 then
|
||||
self.animations.current = self.animations.down
|
||||
elseif futureVelY < 0 then
|
||||
self.animations.current = self.animations.up
|
||||
end
|
||||
|
||||
self.pos.x, self.pos.y = newPlayerPosX, newPlayerPosY
|
||||
|
||||
for i = 1, len do
|
||||
@@ -66,6 +86,8 @@ function Player:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
self.animations.current:update(dt)
|
||||
|
||||
if self.game.input:pressed 'action' then
|
||||
self.isLightOn = not self.isLightOn
|
||||
self.game.effect:setLightShader(self.isLightOn)
|
||||
@@ -73,9 +95,7 @@ function Player:update(dt)
|
||||
end
|
||||
|
||||
function Player:draw()
|
||||
-- love.graphics.draw(self.texture, self.pos.x, self.pos.y)
|
||||
love.graphics.setColor(0.31, 0.61, 0.76)
|
||||
love.graphics.rectangle('fill', self.pos.x, self.pos.y, self.size.w, self.size.h)
|
||||
self.animations.current:draw(self.texture, self.pos.x, self.pos.y)
|
||||
end
|
||||
|
||||
function Player:getPos() return self.pos.x, self.pos.y end
|
||||
|
||||
7
todo.md
7
todo.md
@@ -4,11 +4,6 @@
|
||||
|
||||
# backlog
|
||||
|
||||
- [ ] Fix CRT bubble effect (doesn't like RS displays)
|
||||
- [ ] Try replacing the Moonshine scan-line effect with the custom shader (or delete it)
|
||||
- [ ] Create player sprite
|
||||
- Make a mouse sprite for the player
|
||||
|
||||
# in progress
|
||||
|
||||
- [ ] Create a local leaderboard to see who clears maze in the lowest amount of time
|
||||
@@ -43,3 +38,5 @@
|
||||
- [x] Added menu art
|
||||
- [x] Create a siren sprite
|
||||
- [x] Make the maze end after 5 solves, with progressive difficulty (9x9 no enemies, increase size + enemy count each stage)
|
||||
- [x] Create player sprite
|
||||
- Make a mouse sprite for the player
|
||||
|
||||
Reference in New Issue
Block a user