Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Many Balls bouncing
Author Message
Paul

Posted: Sun Feb 15, 2004 10:53 pm   Post subject: Many Balls bouncing

Can anyone show me an easy way to have many balls bouncing around in a box, preferably without using alot of different variables and not alot of flashing?

Homer_simpson

Posted: Sun Feb 15, 2004 11:26 pm   Post subject: (No subject)

check out my particle enegine with physics post...
Cervantes

Posted: Mon Feb 16, 2004 3:52 pm   Post subject: (No subject)

Well I think he wants something simpler than that
You need to learn to use arrays. If you can't understand them from this code and from the help file and any tutorials on here (You'll get it from all those I'm sude) PM me or ask in this thread.

 code: var howmany : int put "How many balls? : " .. get howmany var x, y, dx, dy : array 1 .. howmany of int for i : 1 .. howmany     dx (i) := Rand.Int (-4, 4)     dy (i) := Rand.Int (-4, 4)     x (i) := maxx div 2     y (i) := maxy div 2 end for setscreen ("offscreenonly") cls loop     cls     for k : 1 .. howmany         x (k) += dx (k)         y (k) += dy (k)         Draw.FillOval (x (k), y (k), 5, 5, brightred)     end for     View.Update     delay (5) end loop
zylum

Posted: Mon Feb 16, 2004 4:03 pm   Post subject: (No subject)

you forgot to add the bit of code which checks whether the ball has reached the screen...

 code: x (k) += dx (k) y (k) += dy (k) if x (k) < 0 or x (k) > maxx then     dx (k) *= -1 end if if y (k) < 0 or y (k) > maxy then     dx (k) *= -1 end if
Cervantes

Posted: Mon Feb 16, 2004 4:08 pm   Post subject: (No subject)

Paul is a very compitent programmer who can do that himself...
All he needed to know was how to use an array.
we64

Posted: Mon Feb 16, 2004 6:37 pm   Post subject: (No subject)

I changed it based on Cervantes' code... Now it really bouncing around screen...
 code: var howmany : int put "How many balls? : " .. get howmany var x, y, dx, dy : array 1 .. howmany of int for i : 1 .. howmany     dx (i) := Rand.Int (-4, 4)     dy (i) := Rand.Int (-4, 4)     x (i) := maxx div 2     y (i) := maxy div 2 end for setscreen ("offscreenonly") cls loop     cls     for k : 1 .. howmany         x (k) += dx (k)         y (k) += dy (k)         Draw.FillOval (x (k), y (k), 5, 5, brightred)         if x (k) >= maxx or x (k) <= 0 then             dx (k) := -dx (k)         elsif y (k) >= maxy or y (k) <= 0 then             dy (k) := -dy (k)         end if     end for     View.Update     delay (5) end loop
Paul

Posted: Mon Feb 16, 2004 6:46 pm   Post subject: (No subject)

Hehe, thanks, this kinda looks like the other guy's explosion don't you think? And if you use over 100 balls, it looks vaguely 3Dish.
jonos

Posted: Mon Feb 16, 2004 6:51 pm   Post subject: (No subject)

we64's thing looks crazy. its like a kaliedoscope. +bits

jonos edit:
nm, bits thing isn't workin.

Cervantes

Posted: Mon Feb 16, 2004 7:02 pm   Post subject: (No subject)

....
jonos why are you trying to give we64 bits for merging code that I wrote with a snippet that zylum wrote?

anyways here is a game that I made using thoughtful's collision from his pool tutorial.

its not nearly done but w/e just for fun
Paul

Posted: Mon Feb 16, 2004 7:06 pm   Post subject: (No subject)

Very nice, bahaha, you slow ninja's will never catch me. Grr... it took 10 of them. Have you realized that the player can't reach the corners?
Cervantes

Posted: Mon Feb 16, 2004 7:08 pm   Post subject: (No subject)

yes I have I did that to prevent those cheap players from hiding in the corner. Takes a long time for you to die when you hide in the corners
jonos

Posted: Mon Feb 16, 2004 7:10 pm   Post subject: (No subject)

i believe that i can give bits who anyone who i think deserves them, and my opinion on who deserves them does not have to be the same as your. i liked what he did with it, so i thought that i would give him bits.
Cervantes

Posted: Mon Feb 16, 2004 7:15 pm   Post subject: (No subject)

Jonos you are totally entitled to you're opinion and your beliefs.
As for my beliefs oh who deserves bits, I think no one here. That's really and truly not a hard program to make

But while you're enjoying your freedom of opinion allow me to enjoy mine: le cut... le paste.
jonos

Posted: Mon Feb 16, 2004 7:26 pm   Post subject: (No subject)

the code was not difficult compared to your skill level, but to mine it was.
Paul

Posted: Mon Feb 16, 2004 7:33 pm   Post subject: (No subject)

No, I don't think the code is difficult, or complicated, it just takes experience plus intelligence to come up with it
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 2  [ 29 Posts ]
Goto page 1, 2  Next
 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: