Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
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

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)

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 = x-1

and there you have it. I'm probably wrong though.

netninja

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

sounds reasonable, thanks alot.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 9 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: