37 lines
1.0 KiB
Lua
37 lines
1.0 KiB
Lua
|
|
function init()
|
|
local levels = 7
|
|
local crate = ag.loadModel("crate", 0.5)
|
|
local offset = 0.5
|
|
crate:setPosition(0, 0, offset + levels + 0.5)
|
|
for level = 2, levels do
|
|
for x = 1, level do
|
|
local c = crate:clone()
|
|
c:setPosition(x - 0.5 - level/2,
|
|
0, offset + levels - level + 1.5)
|
|
end
|
|
end
|
|
|
|
local ground = ag.loadStaticModel("crate", 10)
|
|
ground:setPosition(0, 0, -10)
|
|
ag.setCamera(levels/2, -2*levels, levels, 0, 0, levels/2, 0, 0, 1)
|
|
camx, camy, camz, cx, cy, cz = ag.getCamera()
|
|
|
|
ball = ag.loadModel("checkerball")
|
|
ball:setPosition(2*camx - cx, 2*camy - cy, 2*camz - cz)
|
|
end
|
|
|
|
function mousebutton_down_event(button)
|
|
local function button1()
|
|
local newball = ball:clone()
|
|
newball:setPosition(camx, camy, camz)
|
|
force = 10000
|
|
newball:addForce(force * (cx-camx),
|
|
force * (cy-camy),
|
|
force * (cz-camz))
|
|
end
|
|
if (button == 1) then
|
|
button1()
|
|
end
|
|
end
|