Page 1 of 1
Physics Project
Posted: Mon Jun 29, 2009 4:55 pm
by dandymcgee
This is my first OpenGL application, and was created as my Final Exam project for my high school Physics I class. It consists of two distinct parts: A small game, and a sort of sandbox simulation. Although it's not terribly complicated I put a good deal of effort into make the code as neat as possible and it earned me an A+ for my final.
As far as efficiency.. well you can determine that for yourselves. It does crash periodically for unknown reasons, but I don't plan to update it any further.
This archive contains the PowerPoint I presented for the class, both executables, & full source ( including the Code::Blocks project files ).
DOWNLOAD
Controls:
Game - Q, W, E for NW, N, and NE respectively. (Must re-open application to start again)
Simulation - Keys surrounding "S" non-inclusive (Q, W, E, A, D, Z, X, C). I'm sure you can figure out what directions they correspond to.
You can also click with the left mouse button in the simulation to set the object's position.
All source code is freely available for whatever use you see fit, but you are not authorized to claim any significantly sized unaltered portion as your own.
Feedback is welcome.
Re: Physics Project
Posted: Mon Jun 29, 2009 5:31 pm
by gordon
Impressive work. I had a quick glimpse at the source and it has some useful stuff in it. Thanks, will help me with my learning.
Re: Physics Project
Posted: Tue Jun 30, 2009 4:55 pm
by RyanPridgeon
Nice one! I'm working on something similar for my Computing coursework
Re: Physics Project
Posted: Sat Jul 04, 2009 8:18 am
by Bludklok
This is outstanding work. I did a C++ program for science final in freshman year of high school but no where near as complex as this.
Re: Physics Project
Posted: Sat Jul 04, 2009 11:42 am
by RyanPridgeon
How come the x force reads 0 when you are decelerating horizontally?
Re: Physics Project
Posted: Sat Jul 04, 2009 11:46 am
by Netwatcher
Liked the fact that the gravity isn't 10 or 9.8... it's exactly 9.81 :D ( I hate approximations)
you made the points in the helicopter game to be added every few milliseconds, when I hit a button the program is "delayed" and I get the point only after a while... you should put it on a different thread or average the FPS (ofc you're not gonna do it NOW, I'm just saying...).
And the keystroke checking; you did a switch statement or else if... so I can't press up & left, and if I do I will just fall down because the up key isn't checked.(the NE, SE, SW and NW keys doesn't work right for some reason)
and it also finds out when I press irrelevant keys (such as the "k" key or the "o" key )
Other then that >Great work :D
Re: Physics Project
Posted: Sat Jul 04, 2009 2:32 pm
by dandymcgee
@RyanPridgeon:
RyanPridgeon wrote:How come the x force reads 0 when you are decelerating horizontally?
I know technically friction is a force and should probably be considered when calculating "force", but the "force" you see being displayed in my properties list is technically only the net applied force (ie. when you press a key you apply a force as well as gravity which is constantly applying force).
@NetWatcher:
Netwatcher wrote:Liked the fact that the gravity isn't 10 or 9.8... it's exactly 9.81 :D ( I hate approximations)
I tried to make it as accurate as possible.
Netwatcher wrote:you made the points in the helicopter game to be added every few milliseconds, when I hit a button the program is "delayed" and I get the point only after a while... you should put it on a different thread or average the FPS (ofc you're not gonna do it NOW, I'm just saying...).
If you only move along one axis (ie. bouncing vertically) your points go up VERY slow on purpose. Otherwise it's based on velocity (more velocity = more points). Also take note that the score variable is a float being cast to an int before being displayed, so if it's going up slowly enough the number you see won't change until it gets far enough to be rounded up instead of down.
Netwatcher wrote:And the keystroke checking; you did a switch statement or else if... so I can't press up & left, and if I do I will just fall down because the up key isn't checked.(the NE, SE, SW and NW keys doesn't work right for some reason)
Again, in the game this was completely on purpose to add to the difficulty level. You can only apply force NW, N, or NE in the game and I'm not sure what you mean about keys not working?
Netwatcher wrote:and it also finds out when I press irrelevant keys (such as the "k" key or the "o" key )
What do you mean by "It finds out"?
@Everyone else:
Thank you guys for your compliments, they're much appreciated. Feel free to hack at the source, it's far from professional but I believe it's neat enough and commented well enough for you to get the basic gist of what's going on.
(Note: You may want to avoid trying to understand the block comments of debug code, most of it is irrelevant and I just never happened to delete it.)
Re: Physics Project
Posted: Sat Jul 04, 2009 3:16 pm
by Netwatcher
dandymcgee wrote:@RyanPridgeon:
RyanPridgeon wrote:How come the x force reads 0 when you are decelerating horizontally?
I know technically friction is a force and should probably be considered when calculating "force", but the "force" you see being displayed in my properties list is technically only the net applied force (ie. when you press a key you apply a force as well as gravity which is constantly applying force).
@NetWatcher:
Netwatcher wrote:Liked the fact that the gravity isn't 10 or 9.8... it's exactly 9.81 :D ( I hate approximations)
I tried to make it as accurate as possible.
Netwatcher wrote:you made the points in the helicopter game to be added every few milliseconds, when I hit a button the program is "delayed" and I get the point only after a while... you should put it on a different thread or average the FPS (ofc you're not gonna do it NOW, I'm just saying...).
If you only move along one axis (ie. bouncing vertically) your points go up VERY slow on purpose. Otherwise it's based on velocity (more velocity = more points). Also take note that the score variable is a float being cast to an int before being displayed, so if it's going up slowly enough the number you see won't change until it gets far enough to be rounded up instead of down.
Netwatcher wrote:And the keystroke checking; you did a switch statement or else if... so I can't press up & left, and if I do I will just fall down because the up key isn't checked.(the NE, SE, SW and NW keys doesn't work right for some reason)
Again, in the game this was completely on purpose to add to the difficulty level. You can only apply force NW, N, or NE in the game and I'm not sure what you mean about keys not working?
Netwatcher wrote:and it also finds out when I press irrelevant keys (such as the "k" key or the "o" key )
What do you mean by "It finds out"?
@Everyone else:
Thank you guys for your compliments, they're much appreciated. Feel free to hack at the source, it's far from professional but I believe it's neat enough and commented well enough for you to get the basic gist of what's going on.
(Note: You may want to avoid trying to understand the block comments of debug code, most of it is irrelevant and I just never happened to delete it.)
I mean, if I press "up" and "k" nothing will happen because I pressed "K"
about the other E,Q,C and Z keys... they are alright It's just that It's not as big of a movement as the other directions.
I just comment what I think... didn't realize some of these were actually part of the game.
I feel stupid
Re: Physics Project
Posted: Sat Jul 04, 2009 9:47 pm
by dandymcgee
Netwatcher wrote:
I mean, if I press "up" and "k" nothing will happen because I pressed "K"
about the other E,Q,C and Z keys... they are alright It's just that It's not as big of a movement as the other directions.
I just comment what I think... didn't realize some of these were actually part of the game.
I feel stupid
Well I'm not sure how much you know about vectors, but that is exactly what the forces in this application are. When you apply a force of 120N NW you're actually dividing it among the X and Y axis, AND going against gravity. This might be what's causing you to see it as a lesser effect.
As far as input, this project was the very first programming project I've done with an actual deadline (and therefore probably the first project I've actually completed). I didn't have time to make it idiot-proof, so pressing the wrong keys will in fact result in a performance penalty.
Don't feel stupid, I appreciate the feedback!
Re: Physics Project
Posted: Sun Jul 05, 2009 1:12 am
by Netwatcher
dandymcgee wrote:Netwatcher wrote:
I mean, if I press "up" and "k" nothing will happen because I pressed "K"
about the other E,Q,C and Z keys... they are alright It's just that It's not as big of a movement as the other directions.
I just comment what I think... didn't realize some of these were actually part of the game.
I feel stupid
Well I'm not sure how much you know about vectors, but that is exactly what the forces in this application are. When you apply a force of 120N NW you're actually dividing it among the X and Y axis, AND going against gravity. This might be what's causing you to see it as a lesser effect.
That's exactly what I meant.
And god am so glad I'm done with my High-school & College physics