Jump to content

  • Log In with Google      Sign In   
  • Create Account


MrTwiggy

Member Since 05 Apr 2011
Offline Last Active Jun 22 2012 04:41 PM
-----

Topics I've Started

A workable structure for physics?

05 April 2011 - 07:42 PM

Note: I realize after writing thing, it is quite long. And I tend to ramble at some parts, so sorry for that.

Hey, there! First off, I wasn't sure whether this should be in 'Math and Physics' or 'For Beginners'. Because, I am a beginner and this is sort of a beginner question, but it's related closely to physics and math. If this isn't the right area, please feel free to move it, and I apologize.

Anywho, onto the situation. I'm a student in currently finishing my 11th year of Highschool. I've taken one introductory course into CS (c++) and have quite a bit of my own time learning about programming in general, and focusing mainly on C# and the XNA framework, which is a great starting point IMO. I'm part of a team that makes Indie Games for the Xbox 360, but I work with a more experienced programmer who helps me, and oversees my work. I'm planning on attending university (Carleton University to be exact, but it's not really well-known, and it's in Canada. So you probably haven't heard of it :P ) and getting my Honours degree in Computer Science, with a specialization in Game Development (Which I was careful to be sure it wasn't some flimsy degree centered on game design just to make easy cash from prey.) Although, I'm beginning to realize I am off course. Anyways, I'm currently in my first course of Physics, so my knowledge on the subject is fairly limited. I have a basic understanding forces and Newton's three laws.

I understand normal forces, free-body diagrams, the effects and force of gravity, net-force, friction (Static and kinetic) and velocity-related stuff. I realize that likely seems like very little to most of you, especially those who have minored or majored in physics already. But, that's what I have to work with. I was hoping to get some basic knowledge of how I can implent fairly standard and basic physics into games that I would be creating (likely with the XNA framework). The only problem is, I'm not sure how to structure everything. I mean, I COULD go out there and find some sort of physics engine, but those are typically extremely complex and long, and do far more than I need it to. And since I'm so relatively new to programming, I have a hard time reading, understanding and grasping other peoples' concepts and ideas for programming and their code. So I want to do my own. It wouldn't have much, it would not have particle systems and squishy stuff or whatever, xD. Just mainly a collision detection system, with friction, gravity, and all that stuff for players to move and collide with the world and objects.

I realize that I could probably do this with 'magic', which I have done before. But it's typically VERY bug-prone, and it just doesn't feel right. So I've decided to try and build a system that implements atleast semi-realistic physics in terms of forces, gravity and opposing motion (walls and the such). However, I'm not really sure how to implement those things into code.

I sort of have an idea for the end result of movement. I could have a net-force object on the player, for example, that is an object of a seperate class, that holds it's scalar force in Newtons, and it's direction in degrees or something, which would have it's own function to translate that into a vector quantity that can be added to the player's position that roughly translates into that net-force of movement. However, the trouble I am having understand, is how to use collision detection and force-transferrence. Stuff like, applying gravity to the players net-force, using collision detection and normal forces that oppose force of gravity and whatever else.

Upon further thinking, I suppose perhaps I could do something like this. I would have the player's net-force object. Then when I detect a collision between, say, the floor, I would calculate the force of gravity (perhaps with a method in the player class that returns the force of gravity) and then have a function in the floor object that determines the normal force and adds it to the players net-force? I'm not really sure, and I'm sort of lost. Maybe I'm over my head, and should stick to magic until I'm done atleast my first semester of physics. Or if anyone has any other suggestions or ideas, I'd love to hear it.

Anywho, thanks for reading all of this, if you did. I appreciate any comments or feedback that are constructive in some way.

-Ty

PARTNERS