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")
|
ag.import("std")
|
||||||
|
|
||||||
function newGame()
|
function newGame()
|
||||||
|
current_frame = 1
|
||||||
setupScore()
|
setupScore()
|
||||||
newFrame()
|
newFrame()
|
||||||
position_x = 0
|
position_x = 0
|
||||||
@ -170,7 +171,17 @@ function drawFrameScore(width, height, frame, fs)
|
|||||||
if (fs[ball] ~= -1) then
|
if (fs[ball] ~= -1) then
|
||||||
local ball_base_x = base_x + local_width - (1 + balls - ball) * ball_size + 7
|
local ball_base_x = base_x + local_width - (1 + balls - ball) * ball_size + 7
|
||||||
local ball_base_y = base_y + size - 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
|
if (fs["tot"] ~= -1) then
|
||||||
local w, h = ag.getTextSize(fs["tot"], 16)
|
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)
|
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
|
end
|
||||||
|
|
||||||
function key_down_event(key)
|
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
|
end
|
||||||
|
|
||||||
function mousebutton_down_event(button, x, y)
|
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
|
elseif (score[f][1] == -1 or score[f][2] == -1) then
|
||||||
break
|
break
|
||||||
elseif (score[f][1] + score[f][2] == 10) then -- spare
|
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
|
break
|
||||||
else
|
else
|
||||||
score[f]["tot"] = prevscore + 10 + score[f+1][1]
|
score[f]["tot"] = prevscore + 10 + score[nf][nb]
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
score[f]["tot"] = prevscore + score[f][1] + score[f][2]
|
score[f]["tot"] = prevscore + score[f][1] + score[f][2]
|
||||||
@ -338,17 +358,20 @@ function updateScore(pin_count)
|
|||||||
end
|
end
|
||||||
if (pin_count == 10 and current_frame < 10) then
|
if (pin_count == 10 and current_frame < 10) then
|
||||||
current_frame = current_frame + 1
|
current_frame = current_frame + 1
|
||||||
current_ball = 1
|
|
||||||
newFrame()
|
newFrame()
|
||||||
elseif (current_frame == 10) then
|
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
|
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()
|
gameOver()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
current_ball = current_ball + 1
|
current_ball = current_ball + 1
|
||||||
if (current_ball > 2) then
|
if (current_ball > 2) then
|
||||||
current_ball = 1
|
|
||||||
current_frame = current_frame + 1
|
current_frame = current_frame + 1
|
||||||
newFrame()
|
newFrame()
|
||||||
end
|
end
|
||||||
@ -356,6 +379,7 @@ function updateScore(pin_count)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function newFrame()
|
function newFrame()
|
||||||
|
current_ball = 1
|
||||||
resetPins()
|
resetPins()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user