Computer Science Canada

Gravity Help

Author:  belarussian [ Wed Dec 16, 2009 10:02 pm ]
Post subject:  Gravity Help

GRAVITY HELP


View.Set ("graphics:1024;768,nobuttonbar,nocursor,offscreenonly")
Draw.Fill (512, 384, black, green)
Draw.ThickLine (512, 1, 512, 344, 3, grey)

procedure drawSlime (x, y, color1, coloreye, radius : int)
Draw.FillArc (x, y, radius, radius, 0, 180, color1)
if x > (maxx div 2) then
Draw.FillOval (x - (radius div 2), y + (radius div 2), 5, 5, white)
Draw.FillOval (x - (radius div 2), y + (radius div 2), 2, 2, coloreye)
elsif x < (maxx div 2) then
Draw.FillOval (x + (radius div 2), y + (radius div 2), 5, 5, white)
Draw.FillOval (x + (radius div 2), y + (radius div 2), 2, 2, coloreye)
end if
end drawSlime





var moveslime1 : array char of boolean
var moveslime2 : array char of boolean
var x1 : int := 256
var x2 : int := 768
var y1 : int := 1
var y2 : int := 1
var radius : int := 75

drawSlime (x1, y1, green, brightblue, radius)
drawSlime (x2, y2, green, brightblue, radius)
loop
Input.KeyDown (moveslime1)
if moveslime1 (KEY_RIGHT_ARROW) and (x1 + radius) < 502 then
drawSlime (x1, y1, black, black, radius + 2)
x1 += 10
drawSlime (x1, y1, green, brightblue, radius)
Draw.ThickLine (512, 1, 512, 344, 3, grey)
elsif moveslime1 (KEY_LEFT_ARROW) and (x1 - radius) > 1 then
drawSlime (x1, y1, black, black, radius + 2)
x1 -= 10
drawSlime (x1, y1, green, brightblue, radius)
Draw.ThickLine (512, 1, 512, 344, 3, grey)
elsif moveslime1 (KEY_UP_ARROW) and y1 = 1 then
drawSlime (x1, y1, black, black, radius + 2)
y1 += radius
drawSlime (x1, y1, green, brightblue, radius)
end if

if y1 = radius + 1 then
y1 -= 1
end if

delay (20)
View.Update
end loop





GRAVITY NO WORK

Author:  yumrum [ Sat Dec 19, 2009 10:21 pm ]
Post subject:  Re: Gravity Help

I would make everything a little more clear
use the outline and use the proper coding to make ur program visibly better

Author:  Zasalamel [ Sun Dec 20, 2009 2:46 pm ]
Post subject:  Re: Gravity Help

you need a y velocity variable (as a real) then where you would add to the players y position you would add 1 to y velocity then below add an if statement like so:
Turing:

if Y_Velocity > 0 then
X_Yelocity -= 0.5 %(Gravity)
end if

Then you need a statement relating the velocity to the position
Turing:

Y_Position += Y_Velocity


I am going to write a tutorial for realistic movement later this week check it out if you need more help.
its started at http://compsci.ca/v3/viewtopic.php?p=201589&no=1#201589


: