Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Gravity
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
b89




PostPosted: Sun Apr 24, 2005 3:32 pm   Post subject: Gravity

I have tried quadratic functions in my codes but i cant seem to get it right.
Can you (anyone) give me a code that makes artificial gravity?
thnx
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Sun Apr 24, 2005 4:05 pm   Post subject: (No subject)

Let's think about this...

What is gravity? It is a force that continually acts on all bodies, drawing them together. The only substantial gravity you need worry about is the one keeping your computer upon its table right now.
So, we assume that the only observable effects of gravity will act in a single direction, for our convenience 'down'.

To simulate gravity, you'll need to be able to manipulate variables efficiently, and have a basic concept of vectors.
Since gravity only acts downwards, it will only ever affect the y-velocity vector.
Say you draw an oval at coordinates (x, y). Initially, its y-velocity is 0. So, it stays perfectly still. Gravity is continuously acting on it, so it immediately begins to move downwards.
It's usually easier to represent this using negative velocity. So, your y-velocity changes to -0.1, then -0.2, -0.3, -0.4, etc etc.
The change in velocity is linear, but the resulting change in position is exponential. (Quadratic is a special case of exponential).
Your job is to translate this idea into code, keeping in mind that your oval/object will be drawn according to its positional variables (x and y), while its velocity variables will simply be used to determine where it will be drawn the next time it is drawn.
Got it?

Check in Source Code, I'm pretty sure there's a bunch of examples there.
Andy




PostPosted: Sun Apr 24, 2005 8:05 pm   Post subject: (No subject)

actually... gravity is nothing but bent space time lines... the space time is bent around all massive bodies
Delos




PostPosted: Sun Apr 24, 2005 9:14 pm   Post subject: (No subject)

According to a certain Psych prof at my uni, gravity doesn't exist. It's simply a theory that works particularly well...and he'll spend extended periods of time dropping a pen in front of his class, trying to prove his point (I guess he's hoping that if he does it enough times, gravity will just get tired and leave him alone)...
Either way dodge, I'm pretty sure that OOT would not be able to handle "space time lines"...Laughing
Bacchus




PostPosted: Sun Apr 24, 2005 9:20 pm   Post subject: (No subject)

well gravity wont get tired, but it can turn a blind eye. in that sense you can accually learn to fly. first you have to throw yourself at the ground and righht at the moment before impact you need something to suddenly grab you attention away from falling thus causing you to miss the ground and start hovering above it. once you mind goes back to falling to the ground gravity will suddenly turn it attention abck to you and cause you to crash. just think about greek olive oil Smile
b89




PostPosted: Mon Apr 25, 2005 7:41 pm   Post subject: (No subject)

yeh i solved my problem. All I needed to do was to change the value that I get from a real number into an intiger. I did it by simply using div
Thanks anyways... Laughing

Actually I still dont got it...does anyone know how to draw a porabula with drawdot?
md




PostPosted: Mon Apr 25, 2005 10:26 pm   Post subject: (No subject)

Bacchus wrote:
well gravity wont get tired, but it can turn a blind eye. in that sense you can accually learn to fly. first you have to throw yourself at the ground and righht at the moment before impact you need something to suddenly grab you attention away from falling thus causing you to miss the ground and start hovering above it. once you mind goes back to falling to the ground gravity will suddenly turn it attention abck to you and cause you to crash. just think about greek olive oil Smile


Strait from the hitch hikers guide, but it's true! all you need to do in order to fly is jump and miss the earth Razz
Bacchus




PostPosted: Tue Apr 26, 2005 6:43 pm   Post subject: (No subject)

yes! omg i cant wait for the movie, hopefully they dont ruin it.

but if you want to make gravity, just look under tutorials
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: