Jump to content
  • Advertisement
Sign in to follow this  
RandyJohn

Help With Design?

This topic is 4332 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently creating my first game using C# and XNA. It's a simple 2D bird's eye view shooter. It will eventually be mulitplayer via LAN hopefully, but for the moment it is still very basic. My problem is that I have got to a point where the design ad orientation of classes and the scope of functions and variables is very important. I was just looking to see if anyone could tell me (or point me toward a good resource) how I should organise the structures. I would like it such that each class (Player, Particle, Bullet etc.) had its own Update() and Render() functions for organizational purposes. At the moment my GameEngine class contains Lists of players and particles etc. but say in the Particle.Update() function I wanted to check if this had collided with a player and act accordingly. Well, the Particle class won't have access to the GameEngine class. What I need is a little tutorial or explanation of what is the easiest and most effective way of organising my data structures. The source code is at: http://rapidshare.com/files/3426858/TDS.rar I don't think you absolutely need the code as this is more of a generic game-making problem rather than a code problem, it's just if you want to look at the classes.

Share this post


Link to post
Share on other sites
Advertisement
My general approach is as follows: I associate an object with a hull and place it in a group (for instance a group of player ships, a group of rockets, a group of world geometry elements). Then, I associate a pair of groups with a resolution function. When a hull of the first group collides with a hull from the second group, I call the resolution function on the objects associated with each hull.

Then, I list all currently active collision pairs (the groups between which collisions are allowed to occur) and cleverly update the collision/non-collision status of every pair of hulls every frame.

Share this post


Link to post
Share on other sites
Whoa, hold up there hull? What is that? What do you mean by 'groups' and 'resolution function'? Could you explain in terms of classes?

Share this post


Link to post
Share on other sites
A hull is a shape: it can be a sphere, or a box, or a mesh. It also has a position. The object can alter its hull when it moves or changes shape. The most fundamental ability of a hull is detecting (or predicting) its collision with another hull (including normal vectors and, if necessary, elimination of overlaps).

A group is a list of (hull,object) pairs. In my application, it is a type-parametric class Group<T>, with its elements being (Hull*,T*) pairs

A resolution function is a function or functor with two arguments. I would associate resolve(T* a, U* b) with a Group<T> and Group<U>. Whenever a hull from the first group intersects a hull from the second group, the associated objects t and u are extracted from the groups, and resolve(t,u) is called.

Example of application: create a group of enemies and a group of player rockets. Enemies have a spherical hull, while rockets have a capsule hull (both are centered and oriented). The resolution function destroys the rocket, plays an explosion sound, and reduces the health level of the enemy.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!