working on bowling demo
git-svn-id: svn://anubis/anaglym/trunk@209 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
bf2485ced5
commit
2aee3daba6
@ -72,14 +72,41 @@ function init_event()
|
|||||||
resetPins()
|
resetPins()
|
||||||
setupStars()
|
setupStars()
|
||||||
setupScore()
|
setupScore()
|
||||||
ag.setCamera(0, -10, 5, 0, 20, 0)
|
position_x = 0
|
||||||
|
target_x = 0
|
||||||
game_state = "waiting"
|
game_state = "waiting"
|
||||||
|
last_update_time = ag.elapsedTime()
|
||||||
end
|
end
|
||||||
|
|
||||||
function update_event()
|
function update_event()
|
||||||
|
ag.setCamera(position_x, -10, 5, target_x, 20, 0)
|
||||||
|
local now = ag.elapsedTime()
|
||||||
|
if (ag.isKeyDown("a") or ag.isKeyDown("left")) then
|
||||||
|
position_x = position_x - (now - last_update_time) / 300
|
||||||
|
if (position_x < -2) then
|
||||||
|
position_x = -2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if (ag.isKeyDown("d") or ag.isKeyDown("right")) then
|
||||||
|
position_x = position_x + (now - last_update_time) / 300
|
||||||
|
if (position_x > 2) then
|
||||||
|
position_x = 2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
last_update_time = now
|
||||||
|
|
||||||
ag.callList(stars)
|
ag.callList(stars)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mouse_motion_event(x, y, xrel, yrel)
|
||||||
|
target_x = target_x + xrel / 100
|
||||||
|
if (target_x < -2) then
|
||||||
|
target_x = -2
|
||||||
|
elseif (target_x > 2) then
|
||||||
|
target_x = 2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function drawFrameScore(width, height, frame, fs)
|
function drawFrameScore(width, height, frame, fs)
|
||||||
local size = 60
|
local size = 60
|
||||||
local ball_size = 24
|
local ball_size = 24
|
||||||
@ -146,6 +173,8 @@ end
|
|||||||
function launchBall()
|
function launchBall()
|
||||||
game_state = "launched"
|
game_state = "launched"
|
||||||
launch_time = ag.elapsedTime()
|
launch_time = ag.elapsedTime()
|
||||||
|
bowling_ball = reference_ball:clone()
|
||||||
|
bowling_ball:setPosition(position_x, -10, 4)
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawPowerBar(width, height)
|
function drawPowerBar(width, height)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user