Trying to make worm/gravity game
Author 
Message 
anywho_ya

Posted: Tue May 04, 2004 2:34 pm Post subject: Trying to make worm/gravity game 


Hey there i was trying to do a game for an isu in school, but so far its crap. Its supposed to look like this game http://www.addictinggames.com/worm.html
but it doesnt work properly. I would add the code i have so far but i left it at school. It'd be great if you could help me out. Thanks 





Sponsor Sponsor



Tony

Posted: Tue May 04, 2004 2:54 pm Post subject: (No subject) 


code: 
View.Set("offscreenonly")
var mx, my, b : int
var x, y : int
x := round(maxx/2)
y:=maxy
loop
Mouse.Where (mx, my, b)
if b = 1 then
y += 5
else
y = 5
end if
cls
Draw.FillOval (x, y, 5, 5, red)
View.Update
if y < 0 then
y := 0
end if
if y > maxy then
y := maxy
end if
end loop


Tony's programming blog. DWITE  a programming contest. 




Cervantes

Posted: Tue May 04, 2004 2:56 pm Post subject: (No subject) 


making gravity is not difficult.
you have an x and y position of your worm. you also have a vx and vy values for your worm. these values are the x and y velocities of the worm. to make gravity, just make the dy value decrease by a certain amount each time the loop executes.
EXAMPLE CODE
code: 
setscreen ("offscreenonly")
var x, y : real
var vx, vy : real
x := 0
y := 100
vx := 1
vy := 3
loop
x += vx
y += vy
vy = 0.015
exit when y < 10
cls
drawfilloval (round (x), round (y), 5, 5, black)
View.Update
delay (10)
end loop







Cervantes

Posted: Tue May 04, 2004 3:03 pm Post subject: (No subject) 


jeeze tony, add a delay
anywho, to add gravity to tony's code...
code: 
setscreen ("offscreenonly")
var x, y : real
var vx, vy : real
x := 100
y := 100
vx := 0
vy := 3
var mx, my, mb : int
const gravity := 0.02
loop
Mouse.Where (mx, my, mb)
x += vx
y += vy
vy = gravity
if mb = 1 then
vy += 0.2
end if
cls
drawfilloval (round (x), round (y), 5, 5, black)
View.Update
delay (10)
exit when y < 10
end loop







anywho_ya

Posted: Tue May 04, 2004 3:09 pm Post subject: I get gravity 


Ya i pretty much get the gravity part of it, but the only thing i need is to like get the game to scroll past or sumthing like that ... and i aslo need bricks to move with the worm
thanks with the help so far though 





Cervantes

Posted: Tue May 04, 2004 3:42 pm Post subject: (No subject) 


well you need to randomly generate a maze that the player tries to get through. Bunch of ways to do that im sure. Then, once you've done that, every time through the loop move each object in the maze to the left (or right, but its left in the worms game on addictinggames.com). then check for a collision. shouldn't be that difficult. 





netninja

Posted: Wed May 19, 2004 9:57 pm Post subject: (No subject) 


hey, can somebody explain to me what it means when you do x += y
what the heck is += ?
By the way, nice gravity. 





jonos

Posted: Wed May 19, 2004 10:32 pm Post subject: (No subject) 


It's just short for x = x+y
ex:
x += 1 is x = x+1
x = 1 is x = x1
and there you have it. I'm probably wrong though. 





Sponsor Sponsor



netninja

Posted: Tue May 25, 2004 11:30 pm Post subject: (No subject) 


sounds reasonable, thanks alot. 






