ball movement
Author |
Message |
uknowhoiam
|
Posted: Tue Apr 14, 2009 4:45 pm Post subject: ball movement |
|
|
If you release left arrow or right arrow, the ball will directly go straight down, but i want it to move smoothly to the direction its going in after the button has been released
Can anyone help me?
Turing: | [syntax= View.Set ("graphics:650;400,offscreenonly")
var ballx, bally, xpos, xpos2, ypos, gravity : real
var line, Colour, face : int
var keys : array char of boolean
Colour := 119
face := 255
line := 50
ballx := line + maxx - 100
bally := line
xpos := 2
ypos := 8
gravity := . 25
procedure Player
drawfilloval (round (ballx ), round (bally ), 10, 10, Colour ) %body
drawoval (round (ballx ), round (bally ), 10, 10, face ) %body outline
drawfilloval (round (ballx ) - 3, round (bally ) + 2, 1, 1, face ) %left eye
drawfilloval (round (ballx ) + 3, round (bally ) + 2, 1, 1, face ) %right eye
drawfillarc (round (ballx ), round (bally ) - 2, 2, 4, 180, 360, face ) %smile
end Player
procedure ball_move
ballx + = xpos
end ball_move
procedure ball_move2
ballx - = xpos
end ball_move2
loop
Player
View.Update
delay (10)
cls
bally + = ypos
ypos - = gravity
if bally <= 15 then
ypos := 10 - gravity
end if
if ballx > maxx + 10 then
ballx := - 10
end if
if ballx < - 10 then
ballx := maxx + 10
end if
Input.KeyDown (keys )
if keys (KEY_RIGHT_ARROW) then
ball_move
end if
if keys (KEY_LEFT_ARROW) then
ball_move2
end if
end loop
|
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
uknowhoiam
|
Posted: Tue Apr 14, 2009 5:10 pm Post subject: RE:ball movement |
|
|
nvm i got it to work  |
|
|
|
|
 |
|
|