Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Overall design strategy.  (Read 920 times)
0 Members and 1 Guest are viewing this topic.
Offline QuicK

Junior Member





« Posted 2014-04-22 01:01:50 »

I've gotten to the point where I'm fairly comfortable with lwjgl, however; my issue is that when I start a new project, I have issues deciding where to put everything in the overall structure.

ie: I don't know where to put certain rendering methods to make everything easier on myself.

Are there any design structure articles or references that might be of use to me?

or do you guys have any suggestions on how to plan out the structure of the game?
Offline Longarmx
« Reply #1 - Posted 2014-04-22 02:21:26 »

One of the problems that I have when I code is that I think I have to get everything right the first time. Just remember that if you put a method in a class, it's not permanent. If you realize that you don't like where a method is, then change it. Also, remember about what that method is going to have to access. Can you just pass in parameters, or does it always need to access instance variables?

I've heard that writing out your structure on a piece of paper is very beneficial (ex. boxes are classes, lines are methods); and although I've never tried it (I probably should), it sounds like it would keep me from having to refactor a lot in the early stages of development. Basically start with a main class Then, you can draw lines to other classes based on how that main class should access them.

Really, I think it's just an iterative process. You start with something that 'works', then you make into something that you like to use.

Offline Gibbo3771
« Reply #2 - Posted 2014-04-22 08:41:17 »

I tend to use Lucid Chart, it is a free but limited flow chart creator.

I find it quite useful when designing basic structure, I have used it quite heavily when dealing with complicated logic in classes, to keep track of each stage of the code and minimize errors.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline StrideColossus
« Reply #3 - Posted 2014-04-22 08:58:55 »

Couple of techniques for organising your 'thinking':

Nouns and verbs: If you're starting a new project or a new feature in your game categorise your ideas into classes (the nouns) and methods (the verbs), a simple UML diagram will help you organise your thoughts - or it helps me anyway.

MVC (Model-View-Controller): Another way to work out where to put everything is to categorise your code using the MVC design pattern, quick summary: the model is the state of your game (entities, events, etc), the controller(s) manipulate the model (player actions, animations, game AI, etc) and the view is the representation of the model to the player (scene graph, UI, etc).

Cohesion: A good way to check that you're organising your code as best as you can (and it will never be perfect) is to consider how concise each chunk of code is, i.e. does it have a straight-forward purpose? is the 'API' of that code clear and simple?  If the answer is no then you might want to reconsider the design, break that class up, etc.  A good test is whether that code can be easily unit-tested, if you find that it's complicated to test then the code is probably a bit messy.

Just some random thoughts off the top of my head, hope it helps.

- stride
Offline trollwarrior1
« Reply #4 - Posted 2014-04-22 09:21:29 »

My take on this topic:
* Is your room 24/7 clean? No.
* Do you clean your room everyday? No.
* Do you clean your room every weekend or something like that? Yes.

Logic:
Just slam the code in the same class. Once you can see that you need to move it somewhere, do it. There is no point in structuring the code if you don't feel like it. If you code is perfectly readable without structuring it, whats the point of doing so?
Offline Gibbo3771
« Reply #5 - Posted 2014-04-22 10:42:39 »

My take on this topic:
* Is your room 24/7 clean? No.
* Do you clean your room everyday? No.
* Do you clean your room every weekend or something like that? Yes.

Logic:
Just slam the code in the same class. Once you can see that you need to move it somewhere, do it. There is no point in structuring the code if you don't feel like it. If you code is perfectly readable without structuring it, whats the point of doing so?

I agree with most of this however I don't believe that just "slamming" it in a class without thinking it through.

Imo you should at least have a basic idea of what is going where, a couple to note are:

  • Somewhere in your program that you can easily access resources, such as sprites and sounds, as moving it later can be utterly devastating
  • A basic way of handling your programs states, if you get this out of the way at first, it helps a ton later, even if you only have 1 state to start with

However for everthing else, just go for it. You can chop it up into chunks later.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline loom_weaver

JGO Coder


Medals: 17



« Reply #6 - Posted 2014-04-22 11:46:16 »

I don't create complicated design docs etc. because my project is a solo one.

However, I try not to sit down and program unless I have a clear mind and conceptually have a plan of action of what I'm trying to do.

This often requires multiple hours of not being in front of the computer, going for a walk, or some other activity to encourage the subconscious.

With a clear mind I can sit down and bang out a feature in an hour or so.  Without one, I can sit in front of the computer all day and whatever comes out is pure crap.

And to answer the OP's questions: get it working first and then refactor until you can stand the smell.  It's pretty much impossible to plan something you don't yet know how to do.
Offline Grunnt

JGO Wizard


Medals: 70
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #7 - Posted 2014-04-22 12:03:34 »

There's no single good way to structure your game. It depends on the type of game you are making and your personal preferences. As other suggested, the best way to learn this is by doing it. Make a couple of small games (like tetris or breakout), read up a bit on game design and things will start to fall into place.

Some good approaches to structuring game code are the mentioned Model-View Controller approach, or the entity system approach, e.g. used by Artemis. However, you will most likely notice that while these approaches are helpful, they are nearly impossible to follow strictly.

Sites like GameDev.net or Gamasutra also have a lot of articles on this. Learn by doing and reading.

Offline QuicK

Junior Member





« Reply #8 - Posted 2014-04-22 20:29:31 »

Thank you everyone for the responses! You've all given me some stuff to think about, and hopefully I can use this to get my head in a different state of mind while creating future programs.

One follow-up question though:

Some of you mentioned certain standard program models such as the model-view-controller approach, and the entity structure.

What are some other common structures that I could research to get a basis to work from?
Offline Grunnt

JGO Wizard


Medals: 70
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #9 - Posted 2014-04-23 06:25:49 »

Only thing I can think of is to learn the concepts behind Object Oriented Programming well. If you understand and can apply MVC, entity systems and OOP you are already ahead of most (game) developers.

Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (44 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (62 views)
2014-09-21 02:42:18

BurntPizza (32 views)
2014-09-21 01:30:30

moogie (39 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!