• 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
TGibson

Need some help with planning/organizing game structure

5 posts in this topic

Hi guys, first off sorry if this is in the wrong section. I'm new here and I consider myself a beginner, so I figured this would be the best spot. [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img]

I've done a few simple games in XNA and recently finished a Tetris clone in SFML, and each time I get about half-way through a project, my code begins to look like a cat was dancing on my keyboard and somehow produced working code.

I'm looking for some tips on how to organize my games to help reduce the spaghetti factor. My problem is that every time I sit down to plan out a structure on paper, I just get overwhelmed. Even with something as simple as my Tetris clone, I end up just saying screw it halfway through and wing it without any planning, and wouldn't you know it, it ends up being a mess. Everything is tightly coupled, and the code is just a headache to look at. I mean, the game is working, and I'm just glad to have actually [i]finished[/i] the game, but the code itself leaves a lot to be desired.

Do you guys have any pointers on how to break everything down and create a structure that's orderly, and where I'm able to add in a new feature without breaking too many things in the project?
0

Share this post


Link to post
Share on other sites
- identify your game entities
- think about responsibilities of each entity
- keep responsibility as narrow as possible
- do not introduce cyclic relations
- only communicate between entities through well defined interfaces
- only put required methods in the entity interfaces
- use interfaces to declare method parameters not specific implementations

- get several good books about software development and ... read them [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
1

Share this post


Link to post
Share on other sites
Thanks, just the stuff I'm looking for [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]. The first three points I try to keep in mind while coding, but the rest is new to me as I haven't really used interfaces or abstract classes much. I understand the basic concepts, but I've never actually [i]applied [/i]them. Time to get my hands dirty!

[quote name='6510' timestamp='1331711723' post='4921902']
- do not introduce cyclic relations
[/quote]

This is a totally new one for me, and my google-fu is failing me [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img]. Could you elaborate a little?

[quote name='6510' timestamp='1331711723' post='4921902']
- get several good books about software development and ... read them [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
[/quote]

I've actually got 3 books sitting in my closet right now that I plan on getting to soon (Pragmatic Programmer, Game Architecture & Design, and Game Engine Architecture). I've actually read through Pragmatic Programmer late 2010 - early 2011, and I plan on going through it next week while on spring break. The other two I got from a friend a while back and, while very interesting, are very heavy with content. I plan on maybe getting through them this summer before classes start back up.

I plan on picking up something geared more towards C++ in general soon, are there any recommendations?
0

Share this post


Link to post
Share on other sites
My tips are[list=1]
[*]Avoid cyclic relations, especially cyclic references. If the map has a reference to a tree, then don't let the tree have a reference to the map. If the player has a reference to a weapon, then don't let the weapon store a reference to the player. If the weapons logic needs to access the player data, then pass the player as a parameter to that method.
[*]Don't be afraid of rewriting and/or refactoring code when it becomes messy. Use some version control software like Subversion or Mercurial so that you can easily track changes and go back in case something goes wrong. For example, whenever you find yourself in a situation where you have code duplication, you should probably start refactoring.
[*]Don't use static variables or globals.
[*]I separate my engine subsystems in a stack-like structure, where each layer only knows about lower levels. At the bottom, I have my game logic, then my network logic and at the top, my presentation logic. In other words, the game logic knows nothing about graphics. The higher levels (ie the ui system) can register callbacks to the lower levels (game logic) for two-level communication though.

There are some serious pros and cons with this particular structure, the main advantages being that it's easy to serialize (save/load) and synchronize over network.
[*]Don't overuse inheritance/polymorphism. Lookup the Strategy pattern.
[*]Keep coding and learn the hard way. [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]
[/list]
0

Share this post


Link to post
Share on other sites
DvDmanDt just elaborated about cycles. That's very important to keep your code from turning into a chaotic unmaintainable monolith.
All his other points I would sign as well.
#5 is especially important, people often think of OO as mainly creating class hierachies. But object - not class - relationships are much more important.
0

Share this post


Link to post
Share on other sites
I've found the book, [url="http://www.amazon.com/First-Design-Patterns-Elisabeth-Freeman/dp/0596007124/ref=sr_1_1?s=books&ie=UTF8&qid=1331907479&sr=1-1"]Head First Design Patterns[/url], to be [u]very[/u] helpful in becoming familiar with various patterns and how/why to use them. The book is written using Java, but the concepts translate easily to other languages.
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