think the bowling demo is good now...
git-svn-id: svn://anubis/anaglym/trunk@214 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
53c51f9382
commit
26a4b2c0e3
@ -2,6 +2,7 @@
|
||||
ag.import("std")
|
||||
|
||||
function newGame()
|
||||
current_frame = 1
|
||||
setupScore()
|
||||
newFrame()
|
||||
position_x = 0
|
||||
@ -170,7 +171,17 @@ function drawFrameScore(width, height, frame, fs)
|
||||
if (fs[ball] ~= -1) 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 (fs[ball] == 10) then -- strike
|
||||
ag.drawLine(1, 0.6, 0, ball_base_x, ball_base_y,
|
||||
ball_base_x + 10, ball_base_y + 10)
|
||||
ag.drawLine(1, 0.6, 0, ball_base_x, ball_base_y + 10,
|
||||
ball_base_x + 10, ball_base_y)
|
||||
elseif (ball == 2 and fs[1] + fs[2] == 10) then -- spare
|
||||
ag.drawLine(1, 0.6, 0, ball_base_x, ball_base_y,
|
||||
ball_base_x + 10, ball_base_y + 10)
|
||||
else
|
||||
ag.drawText(fs[ball], 1, 0.6, 0, 14, ball_base_x, ball_base_y)
|
||||
end
|
||||
if (fs["tot"] ~= -1) 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)
|
||||
@ -218,6 +229,14 @@ function update_overlay_event(width, height)
|
||||
end
|
||||
|
||||
function key_down_event(key)
|
||||
if (key == "g") then
|
||||
for i = 1, 9 do
|
||||
score[i][1] = i
|
||||
score[i][2] = 0
|
||||
end
|
||||
current_frame = 10
|
||||
newFrame()
|
||||
end
|
||||
end
|
||||
|
||||
function mousebutton_down_event(button, x, y)
|
||||
@ -327,10 +346,11 @@ function updateScore(pin_count)
|
||||
elseif (score[f][1] == -1 or score[f][2] == -1) then
|
||||
break
|
||||
elseif (score[f][1] + score[f][2] == 10) then -- spare
|
||||
if (score[f+1][1] == -1) then
|
||||
local nf, nb = getNextBall(f, 2)
|
||||
if (score[nf][nb] == -1) then
|
||||
break
|
||||
else
|
||||
score[f]["tot"] = prevscore + 10 + score[f+1][1]
|
||||
score[f]["tot"] = prevscore + 10 + score[nf][nb]
|
||||
end
|
||||
else
|
||||
score[f]["tot"] = prevscore + score[f][1] + score[f][2]
|
||||
@ -338,17 +358,20 @@ function updateScore(pin_count)
|
||||
end
|
||||
if (pin_count == 10 and current_frame < 10) then
|
||||
current_frame = current_frame + 1
|
||||
current_ball = 1
|
||||
newFrame()
|
||||
elseif (current_frame == 10) then
|
||||
if ((current_ball == 1 and pin_count == 10)
|
||||
or (current_ball == 2 and score[10][1] + score[10][2] == 10)) then
|
||||
resetPins()
|
||||
end
|
||||
current_ball = current_ball + 1
|
||||
if ((current_ball == 3 and (score[10][1] + score[10][2]) < 10) or (current_ball == 4)) then
|
||||
if ((current_ball == 3 and (score[10][1] + score[10][2]) < 10)
|
||||
or (current_ball == 4)) then
|
||||
gameOver()
|
||||
end
|
||||
else
|
||||
current_ball = current_ball + 1
|
||||
if (current_ball > 2) then
|
||||
current_ball = 1
|
||||
current_frame = current_frame + 1
|
||||
newFrame()
|
||||
end
|
||||
@ -356,6 +379,7 @@ function updateScore(pin_count)
|
||||
end
|
||||
|
||||
function newFrame()
|
||||
current_ball = 1
|
||||
resetPins()
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user