Initial implementation of player and bullets.
This commit is contained in:
parent
2341e8711f
commit
8d87364afb
6 changed files with 157 additions and 9 deletions
45
src/main.lua
45
src/main.lua
|
@ -1,18 +1,53 @@
|
|||
-- Collision groups:
|
||||
-- 0x1 - walls
|
||||
-- 0x2 - player
|
||||
-- 0x4 - player bullets
|
||||
-- 0x8 - enemies
|
||||
-- 0x10 - enemy bullets
|
||||
import "CoreLibs/object"
|
||||
import "CoreLibs/graphics"
|
||||
import "CoreLibs/sprite"
|
||||
import "CoreLibs/sprites"
|
||||
import "CoreLibs/timer"
|
||||
import "kani"
|
||||
|
||||
local gfx <const> = playdate.graphics
|
||||
|
||||
function setup()
|
||||
local player = nil
|
||||
|
||||
function setup()
|
||||
player = Kani()
|
||||
player:moveTo(16, 120)
|
||||
player:addInputHandlers()
|
||||
player:add()
|
||||
makeWalls()
|
||||
drawBackground()
|
||||
end
|
||||
|
||||
function makeWalls()
|
||||
makeWall(200, 0, 400, 1)
|
||||
makeWall(0, 120, 1, 240)
|
||||
makeWall(200, 0, 400, 1)
|
||||
makeWall(0, 120, 1, 240)
|
||||
end
|
||||
|
||||
function makeWall(x, y, w, h)
|
||||
local wall = gfx.sprite.new()
|
||||
wall:setSize(w, h)
|
||||
wall:setCollideRect(0, 0, wall:getSize())
|
||||
wall:setGroupMask(0x1)
|
||||
wall:add()
|
||||
end
|
||||
|
||||
function drawBackground()
|
||||
local backgroundImage = gfx.image.new(400, 240, gfx.kColorWhite)
|
||||
gfx.sprite.setBackgroundDrawingCallback(
|
||||
function(x, y, width, height)
|
||||
backgroundImage:draw(0, 0)
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
function playdate.update()
|
||||
|
||||
|
||||
playdate.timer.updateTimers()
|
||||
gfx.sprite.update()
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue