adding delete key to cratestack.lua - something is not working though :)
git-svn-id: svn://anubis/anaglym/trunk@104 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
6b5d200863
commit
9473b592e4
@ -1,16 +1,36 @@
|
||||
|
||||
crates = {}
|
||||
|
||||
levels = 5
|
||||
crate = ag.loadModel("crate", 0.5)
|
||||
crates[1] = crate
|
||||
offset = 0.5
|
||||
crate:setPosition(0, 0, offset + levels + 0.5)
|
||||
cratenum = 1
|
||||
for level = 2, levels do
|
||||
for x = 1, level do
|
||||
local c = crate:clone()
|
||||
c:setPosition((x - 1) * 1.5 - (level * 1.5 - 0.5)/2 + 0.5,
|
||||
0, offset + levels - level + 1.5)
|
||||
cratenum = cratenum + 1
|
||||
crates[cratenum] = c
|
||||
end
|
||||
end
|
||||
|
||||
ground = ag.loadStaticModel("crate", 10)
|
||||
ground:setPosition(0, 0, -10)
|
||||
ag.setCamera(2, -12, 8, 0, 0, 2, 0, 0, 1)
|
||||
|
||||
function key_pressed_event(key)
|
||||
if (key == "d") then
|
||||
if (cratenum >= 1) then
|
||||
local idx = math.random(cratenum)
|
||||
crates[idx]:destroy()
|
||||
for i = idx, cratenum - 1 do
|
||||
crates[i] = crates[i + 1]
|
||||
end
|
||||
crates[cratenum] = nil
|
||||
cratenum = cratenum - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user