Rework collision code for future features.
This commit is contained in:
parent
f6ae85dcb1
commit
bb25e255a3
5 changed files with 27 additions and 29 deletions
26
src/main.lua
26
src/main.lua
|
@ -1,9 +1,9 @@
|
|||
-- Collision groups:
|
||||
-- 0x1 - walls
|
||||
-- 0x1 - top and bottom walls
|
||||
-- 0x2 - player
|
||||
-- 0x4 - player bullets
|
||||
-- 0x8 - enemies
|
||||
-- 0x10 - enemy bullets
|
||||
-- 0x4 - enemies
|
||||
-- 0x8 - side walls
|
||||
-- 0x10 - bullets
|
||||
import "CoreLibs/object"
|
||||
import "CoreLibs/graphics"
|
||||
import "CoreLibs/sprites"
|
||||
|
@ -30,15 +30,15 @@ function setup()
|
|||
enemy:add()
|
||||
|
||||
enemy = Ebi()
|
||||
enemy:moveTo(300, 50)
|
||||
enemy:moveTo(270, 50)
|
||||
enemy:add()
|
||||
|
||||
enemy = Ebi()
|
||||
enemy:moveTo(300, 100)
|
||||
enemy:moveTo(280, 100)
|
||||
enemy:add()
|
||||
|
||||
enemy = Ebi()
|
||||
enemy:moveTo(300, 150)
|
||||
enemy:moveTo(290, 150)
|
||||
enemy:add()
|
||||
|
||||
enemy = Ebi()
|
||||
|
@ -51,18 +51,18 @@ function setup()
|
|||
end
|
||||
|
||||
function makeWalls()
|
||||
makeWall(200, 0, 400, 1)
|
||||
makeWall(0, 120, 1, 240)
|
||||
makeWall(200, 240, 400, 1)
|
||||
makeWall(400, 120, 1, 240)
|
||||
makeWall(200, 0, 400, 1, 0x1)
|
||||
makeWall(0, 120, 1, 240, 0x8)
|
||||
makeWall(200, 240, 400, 1, 0x1)
|
||||
makeWall(400, 120, 1, 240, 0x8)
|
||||
end
|
||||
|
||||
function makeWall(x, y, w, h)
|
||||
function makeWall(x, y, w, h, mask)
|
||||
local wall = gfx.sprite.new()
|
||||
wall:setSize(w, h)
|
||||
wall:setCollideRect(0, 0, wall:getSize())
|
||||
wall:moveTo(x, y)
|
||||
wall:setGroupMask(0x1)
|
||||
wall:setGroupMask(mask)
|
||||
wall:add()
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue