62 lines
1.1 KiB
Lua
62 lines
1.1 KiB
Lua
-- Collision groups:
|
|
-- 0x1 - walls
|
|
-- 0x2 - player
|
|
-- 0x4 - player bullets
|
|
-- 0x8 - enemies
|
|
-- 0x10 - enemy bullets
|
|
import "CoreLibs/object"
|
|
import "CoreLibs/graphics"
|
|
import "CoreLibs/sprites"
|
|
import "CoreLibs/timer"
|
|
import "kani"
|
|
|
|
local gfx <const> = playdate.graphics
|
|
|
|
local player = nil
|
|
local ui = nil
|
|
|
|
function setup()
|
|
ui = UI()
|
|
player = Kani(ui)
|
|
player:moveTo(16, 120)
|
|
player:addInputHandlers()
|
|
player:add()
|
|
ui:add()
|
|
|
|
makeWalls()
|
|
|
|
drawBackground()
|
|
end
|
|
|
|
function makeWalls()
|
|
makeWall(200, 0, 400, 1)
|
|
makeWall(0, 120, 1, 240)
|
|
makeWall(200, 240, 400, 1)
|
|
makeWall(400, 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:moveTo(x, y)
|
|
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()
|
|
gfx.sprite.update()
|
|
playdate.timer.updateTimers()
|
|
end
|
|
|
|
setup()
|