anaglym/tests/cratestack.lua
Josh Holtrop c26a3e7deb added Engine::getTextSize()
git-svn-id: svn://anubis/anaglym/trunk@164 99a6e188-d820-4881-8870-2d33a10e2619
2009-11-13 04:55:42 +00:00

49 lines
1.2 KiB
Lua

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_down_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
elseif (key == "m") then
ag.registerEventHandler(mouse_moves, "mouse_motion")
elseif (key == "n") then
ag.clearEventHandler("mouse_motion")
end
end
function mouse_moves(x, y, xrel, yrel)
ag.println("mouse_moves ", x, ", ", y)
end
function update_overlay_event()
ag.drawText("Hi there everyone!", 1, 0.7, 0, 16, 0, 0)
end