60 lines
1.6 KiB
Lua
60 lines
1.6 KiB
Lua
|
|
ag.import("std")
|
|
|
|
function resetPins()
|
|
local head_x = 0
|
|
local head_y = 15
|
|
local spacing = 0.7
|
|
for i = 1, 10 do
|
|
if (pins[i] ~= nil) then
|
|
pins[i]:destroy()
|
|
end
|
|
end
|
|
local n = 1
|
|
for row = 0, 4 do
|
|
for j = 0, row do
|
|
pins[n] = reference_pin:clone()
|
|
pins[n]:setPosition(head_x - row * spacing / 2 + j * spacing,
|
|
head_y + 0.866 * spacing * row,
|
|
1 - pin_minz)
|
|
end
|
|
end
|
|
end
|
|
|
|
function setupStars()
|
|
stars = ag.startList()
|
|
local dist = 500
|
|
for i = 1, 500 do
|
|
local rx = math.random() * math.pi * 2
|
|
local ry = (math.random() - 0.5) * math.pi
|
|
local x = dist * math.cos(ry) * math.cos(rx)
|
|
local y = dist * math.cos(ry) * math.sin(rx)
|
|
local z = dist * math.sin(ry)
|
|
local size = math.random(1, 6)
|
|
ag.drawPoint(size, 1, 1, 1, x, y, z)
|
|
end
|
|
ag.endList()
|
|
end
|
|
|
|
function init_event()
|
|
lane = ag.loadModelStatic("bowling_lane")
|
|
local minx, miny, minz, maxx, maxy, maxz = lane:getAABB()
|
|
local lane_bottom = minz
|
|
pins = {}
|
|
reference_pin = ag.loadModel("bowling_pin", 1.0/4.3)
|
|
minx, miny, minz, maxx, maxy, maxz = reference_pin:getAABB()
|
|
pin_minz = minz
|
|
pin_maxz = maxz
|
|
local box = ag.createBoxStatic(1, 1, 0.1)
|
|
box:setColor(0, 0, 0)
|
|
box:setPosition(0, 0, lane_bottom - (maxz - minz) - 0.4)
|
|
reference_pin:setPosition(0, 0, lane_bottom - maxz - 0.1)
|
|
resetPins()
|
|
setupStars()
|
|
ag.setCamera(0, -10, 5, 0, 20, 0)
|
|
end
|
|
|
|
function update_event()
|
|
ag.callList(stars)
|
|
end
|