How to Plan? What to code first?

Started by
14 comments, last by markr 12 years, 6 months ago

My questions are this:
How do you create a game, and not get bogged down in the Object Oriented design?


Experience and careful preparation. Mostly experience though. After a while you realize (almost) everything boils down to a few common patterns.


Where do people normally start? What is the best thing to code first?
[/quote]

Error reporting.


Should I first get sprites drawn on screen and get them move?
[/quote]

Depends on the game, your general approach, and how you want to/need to work. I personally don't since the hard parts of a game aren't in the rendering.


Should I first create a good program flow, which will run the different states before anything else?
[/quote]

Depends on the game, your general approach, and how you want to/need to work. Unless there's a pile of game states and that's vital to success, I wouldn't.


When creating classes, When should I stop trying to make it better?
[/quote]

When it's good enough to solve the problem you're currently facing. If you're solving some mysterious future problem, you're making a classic error.


It is useful, but I guess I am just worried that if I create my game in a certain order, I may end up with critical implementations left out until the end, meaning a refactoring of a lot of code.
[/quote]

That's why one of the big things to come out of software development methodology recently is to implement the core of your app first. Get something working ASAP, even if it's ugly, even if it's incomplete or hacked up. You can identify critical issues earlier so that they cost less to fix. Then build incrementally off your working core.
Advertisement
I programmed a poker bot for one of my university projects. It could hook onto an online poker client, read the state of the game through a combination of pixel matching and OCR, and then used ANNs and targeted simulations to decide on the best action to take, and then click the appropriate button on screen. It took me about 3 months of programming to get it done.

Once I finished university, I decided to create a newer better poker bot. It was going to be amazing. This version would have a database to store previous hand histories, which could be used to create an individual ANN for each opponent it met, improving the accuracy of the opponent modelling. It would have a bot simulator, where bots could play each other at 500 hands a second, producing a nice graph and all the statistics you could need to see where their weaknesses / strengths were.

I spent the next 3 months designing it all. Classes, databases, all perfectly designed adhering to OO principles.

Then I started coding. Despite all my planning, problems popped up that I hadn't foreseen. No problem though, I'll just do a bit of a redesign. Designs were changed, classes removed, added, amended. Carry on coding. More problems. More redesigns.

In the end I spent more time designing than I did coding. It has been more than a year now, and my poker bot has less than half the functionality that my 3 month uni project had. I don't spend a huge amount of time programming - I have other responsibilities nowadays that I didn't have when I was a student - job, baby etc, but I think the real problem isn't lack of time, it is lack of motivation. I have spent so much time on the project, but have barely anything to show for it.

My advise - don't worry about design very much at all. Have a quick think about how the main parts will work together, and start coding. Dont worry about needing to rewrite code when things go wrong. The most important thing is to get coding and get something working to keep you motivated. Better a working program with terrible source code, than a great design and no program.
[color="#2B3730"]Aye, follow vharishankar's pieces of advice, IMHO it seems to be quite a business-like approach, suitable even for larger projects, where first the skeleton is implemented and details come after.
[color="#2B3730"]What DaveMS said is really interesting for me, ending up with so much design work, that motivation flies away...ohmy.gif
But the contrary is also true in real-world projects: insufficient design and/ or early implementation mistakes can lead to a super-huge unstable, unimproveable Code mass, which may be running, but also has some unforseen "features". This is how the game-maker tool Scirra's Construct Classic turned out to be, that's why they now need to code Construct 2 from scratch.

My experience comes. My last summer was spent with a 2d platformer creation and also Python, Pygame learning. The project, possibly similar to yours, was not a big one. I had no planing in mind, just started with moving sprites, then added detectable terrain (platforms), some stone-age level "pathfinding", some collision detection, and so on. One step will invoke the other, it is that easy when dealing with such a small-scale project. This really hadn't required any plan to worry about! I rewrote the OOP structure 1-2 times, but that was part of the learning, just lack of practice, which you still can't plan before with small experience.

so just do it! It's the funny learning time!
That was the time, the Golden Age, when C-64 and Amiga ruled!

I programmed a poker bot for one of my university projects. It could hook onto an online poker client, read the state of the game through a combination of pixel matching and OCR, and then used ANNs and targeted simulations to decide on the best action to take, and then click the appropriate button on screen. It took me about 3 months of programming to get it done.

Once I finished university, I decided to create a newer better poker bot. It was going to be amazing. This version would have a database to store previous hand histories, which could be used to create an individual ANN for each opponent it met, improving the accuracy of the opponent modelling. It would have a bot simulator, where bots could play each other at 500 hands a second, producing a nice graph and all the statistics you could need to see where their weaknesses / strengths were.

I spent the next 3 months designing it all. Classes, databases, all perfectly designed adhering to OO principles.

Then I started coding. Despite all my planning, problems popped up that I hadn't foreseen. No problem though, I'll just do a bit of a redesign. Designs were changed, classes removed, added, amended. Carry on coding. More problems. More redesigns.

In the end I spent more time designing than I did coding. It has been more than a year now, and my poker bot has less than half the functionality that my 3 month uni project had. I don't spend a huge amount of time programming - I have other responsibilities nowadays that I didn't have when I was a student - job, baby etc, but I think the real problem isn't lack of time, it is lack of motivation. I have spent so much time on the project, but have barely anything to show for it.

My advise - don't worry about design very much at all. Have a quick think about how the main parts will work together, and start coding. Dont worry about needing to rewrite code when things go wrong. The most important thing is to get coding and get something working to keep you motivated. Better a working program with terrible source code, than a great design and no program.


I perfectly understand this situation. It happens all the time when you try to approach a task with too much analysis. Paralysis by analysis, http://en.wikipedia....lysis_paralysis

I know the OOP is particularly vulnerable to this issue. I say this because I have a feeling that OOP was overemphasized in CS courses. So much so that I find that there are so many problems that DON'T fit into an object-oriented based model naturally and we programmers spend so much time trying to "fit" the problem into the solution we have already planned out. I think the approach at schools and colleges is too theoritical and technical.

The key, I think, is to realize that OO is just another model of problem solving in general and is not a magic bullet for every kind of programming task. Sometimes I think C++ is the biggest culprit in bringing in too much complexity to the OOP model and people spend too much time beautifying and dressing up their classes rather than make things work.

Also the "verb" problem always exists in OOP: should it be thisobject.performTaskOn (thatObject) or thatobject.performTaskOn (thisObject)?
-Well, I start almost always with placeholder rendering. I have to see what the program is doing. (but again, just some hacked together placeholder stuff)
-Then some basic (placeholder) input handling with some hacked game loop. I have to be able to modify, move around, interact with things (again, maybe just placeholder mechanics for debugging the input).
-Then comes some basic (placeholder) mechanics. Or maybe nearly-full-featured mechanics.

(debuging/testing after every single step!)

-Only after these, I start planning/designing (apart from the planning of implementation stuff of course). Usually, I don't overdo it. So I end up with a mess again, but WTF.

-Then I rewrite the whole thing, maybe reusing some pure functions from the first iteration of the program.

So, pretty much what Telastyn said (I guess...).


Usually I end up too exited about adding and adding new features to the first iteration, and then I never do any planning at all. This way I can get a working, polished (-looking) feature-rich application in no time (a few days to a month). With some impossible to fix bugs and flaws....
I work by making lists.

Make a list of things to do, with some criterion for knowing when one task is finished. Try to keep this list in logical order that things should be done, but of coursemeplay, you may reorder items later.

Example:

1. Get gfx initialisation, engine inintalisation code working
1. Write file format convert & write map loader
1. Write background renderer
1. Get object manager / engine working "enough"
1. Implement basic physics / gameplay
1. Implement object loader (from map file)
1. Implement some Things in the map (e.g. powerups)
1. Implement bad guys
1. Fix end-of-level, next level, player death etc
1. Tart up graphics
1. Create the shop for buying new weapons etc for next level
1. Add sounds etc
1. Further tart up graphics...

Then potentially divide tasks into subtasks. If you find that you're running out of time you can cancel tasks, or move them on to a lower priority list

Anyway, this is what I do every time I enter a LD48 or similar.

This topic is closed to new replies.

Advertisement