working on bowling demo
git-svn-id: svn://anubis/anaglym/trunk@207 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
81738dec8a
commit
ce734b2ef0
@ -26,7 +26,7 @@ function setupStars()
|
||||
local dist = 500
|
||||
for i = 1, 500 do
|
||||
local rx = math.random() * math.pi * 2
|
||||
local ry = (math.random() - 0.5) * math.pi
|
||||
local ry = (math.random() - 0.5) * math.pi * 0.8
|
||||
local x = dist * math.cos(ry) * math.cos(rx)
|
||||
local y = dist * math.cos(ry) * math.sin(rx)
|
||||
local z = dist * math.sin(ry)
|
||||
@ -36,6 +36,22 @@ function setupStars()
|
||||
ag.endList()
|
||||
end
|
||||
|
||||
function setupScore()
|
||||
current_frame = 1
|
||||
current_ball = 1
|
||||
score = {}
|
||||
for i = 1, 10 do
|
||||
local s = {}
|
||||
s[1] = 0
|
||||
s[2] = 0
|
||||
s["tot"] = 0
|
||||
if (i == 10) then
|
||||
s[3] = 0
|
||||
end
|
||||
score[i] = s
|
||||
end
|
||||
end
|
||||
|
||||
function init_event()
|
||||
lane = ag.loadModelStatic("bowling_lane")
|
||||
local minx, miny, minz, maxx, maxy, maxz = lane:getAABB()
|
||||
@ -51,9 +67,53 @@ function init_event()
|
||||
reference_pin:setPosition(0, 0, lane_bottom - maxz - 0.1)
|
||||
resetPins()
|
||||
setupStars()
|
||||
setupScore()
|
||||
ag.setCamera(0, -10, 5, 0, 20, 0)
|
||||
end
|
||||
|
||||
function update_event()
|
||||
ag.callList(stars)
|
||||
end
|
||||
|
||||
function drawFrameScore(width, height, frame, fs)
|
||||
local size = 60
|
||||
local ball_size = 24
|
||||
local local_width = size
|
||||
if (frame == 10) then
|
||||
local_width = 80
|
||||
end
|
||||
local base_x = size / 2 + size * (frame - 1)
|
||||
local base_y = height - size / 2 - size
|
||||
ag.drawRect(1, 0.6, 0, local_width, size, base_x + local_width / 2, base_y + size / 2)
|
||||
ag.drawRect(1, 0.6, 0, ball_size, ball_size, base_x + local_width - ball_size / 2, base_y + size - ball_size / 2)
|
||||
if (frame == 10) then
|
||||
ag.drawRect(1, 0.6, 0, ball_size, ball_size, base_x + local_width - ball_size * 1.5, base_y + size - ball_size / 2)
|
||||
end
|
||||
|
||||
local balls = 2
|
||||
if (frame == 10) then
|
||||
balls = 3
|
||||
end
|
||||
for ball = 1, balls do
|
||||
-- if ((frame < current_frame) or (frame == current_frame and ball < current_ball)) then
|
||||
local ball_base_x = base_x + local_width - (1 + balls - ball) * ball_size + 7
|
||||
local ball_base_y = base_y + size - ball_size + 7
|
||||
ag.drawText(fs[ball], 1, 0.6, 0, 14, ball_base_x, ball_base_y)
|
||||
-- if (frame < current_frame and fs["tot"] ~= 0) then
|
||||
local w, h = ag.getTextSize(fs["tot"], 16)
|
||||
ag.drawText(fs["tot"], 1, 0.6, 0, 16, base_x + local_width - 10 - w, base_y + 10)
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
end
|
||||
|
||||
function drawScore(width, height)
|
||||
ag.drawText("Score:", 1, 0.6, 0, 16, 30, height - 25)
|
||||
for i = 1, 10 do
|
||||
drawFrameScore(width, height, i, score[i])
|
||||
end
|
||||
end
|
||||
|
||||
function update_overlay_event(width, height)
|
||||
drawScore(width, height)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user