• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
gchewood

Very general question about structuring of game classes.

7 posts in this topic

Ok so I have a physics heavy simulation that's being chiefly run in my main level class.

I then have various characters that inherit from a general 'unit' class (it's similar to a top down RTS). I'm struggling to see which approach is best/ will be best for future efficiency when it comes to having these units interact with the physics of the world.

 

1) Pass all of the relevant data into each units Update function and allow them to manipulate it from there.

 

2) Have the units update function return an integer or something that corresponds to a particular action which is then carred out in the main game class.

 

So one is helpful in that it allows the entirety of the unit's capability to be contained within the class file. The other is helpful in that you don't need to pass a huge selection of variables to the update each time and all of the physics can be handled from within the main class.

Thoughts and suggestions are welcome. Is there a clear benefit to one over the other here that I'm missing or is it just a matter of preference.

 

Thanks in advance.

0

Share this post


Link to post
Share on other sites

What kind of variables are you having to feed from the Main Game class to the Unit?  This sounds to me like it's indicative of a larger design problem.  Can you give a little bit more information on how your current system is set up, what is being passed between, and what is the relationship of the main level & the unit class.

0

Share this post


Link to post
Share on other sites

You might well be right that it's indicative of a larger design problem. I'm largely self taught so the usual design tends to fit a 'whatever happens to work' style. Although I will say that the rest seems to hang together quite neatly.

 

The variables needed to be fed to the units are a few lists of physics objects and an integer array that describes the status of the 'cells' in the game. At the moment it's working fine by using the other approach of having the units update method return an integer that corresponds with a particular action. Granted, that's obviously not the ideal way.

 

What would you suggest? Maybe have the main class implement an interface that handles all of the appropriate methods which can then be accessed by the units?

0

Share this post


Link to post
Share on other sites

Sorry for the delay.

 

Thanks for the advice L.Spiro. So maybe something like a 'Unit Manager' class that handles all of the behaviour and then has access to the physics engine?

That's almost what I'm doing at the moment, I just need to tidy it up and separate it a bit.

 

Thanks

0

Share this post


Link to post
Share on other sites

You might well be right that it's indicative of a larger design problem. I'm largely self taught so the usual design tends to fit a 'whatever happens to work' style. Although I will say that the rest seems to hang together quite neatly.

 

The variables needed to be fed to the units are a few lists of physics objects and an integer array that describes the status of the 'cells' in the game. At the moment it's working fine by using the other approach of having the units update method return an integer that corresponds with a particular action. Granted, that's obviously not the ideal way.

 

What would you suggest? Maybe have the main class implement an interface that handles all of the appropriate methods which can then be accessed by the units?

 

I'd like to add to this quote by including my personal methods when dealing with heavy simulations. I should preface this by stating that there are countless good methods.. but here is one object oriented approach:

 

I will typically have a unit manager / collection that contains a reference to all the current units in the game. I will also have a simulation class (or multiple simulation classes for different types of sims) that will request a pointer to a collection of specific units from the unit manager to act upon. The class, which has a global understanding of the current state of the units and game, takes ownership of updating the information contained in the unit class (speed, location, state) based on the simulation criteria within the simulation class. If you have multiple simulation steps (classes for different types of simulations), the simulation manager simply passes the relevant collection of units from one sub-system to another. 

0

Share this post


Link to post
Share on other sites

I've come to prefer an alternative approach where state for an entity is self contained in specific systems and essentially isn't "shared".  As a system is ticked in the main loop, it operates across a subset of entities (units) that have specific characteristics pertinent to that system.  As conditions are met during the system update, the system notifies other areas of the game using as series of listeners and passes whatever pieces of data is needed for that condition only.  Those callbacks could then take a series of actions themselves or perhaps alter the state of the entity by returning specific values and having the original system update behave accordingly.

 

The only tricky part I've found with such an alternative is making sure that as you create entities or modify them during game play (add or remove characteristics), that these systems are notified so that if an entity no longer qualifies, that it gets added/removed from it's internal list.

0

Share this post


Link to post
Share on other sites

I have a physics sub-system and the physics sub-system has it's own "primative" classes that you must construct your object out of.

 

A final game object, a 'boid', in the world ties together the data needed by each sub-system to create a coherent simulation of that object.
For efficiency purposes you might have the physics data itself stored in a structure inside the physics engine and the boid just references it.

That way the physics engine can perform passes over the entire game world structure of physics and use its own optimal spatial sorting.

(I opted for simplicity here and each boid owns it's data.)

 

I decide to go this way a long time ago with the observation that the optimal audio spatial sorting was markedly different than the optimal graphics sorting and obviously the data is completely different.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0