How Do You Plan?

Started by
12 comments, last by Heath 11 years, 6 months ago
I was thinking. Right now I'm getting into some bigger projects (For me, at least :), and as I said in my other post, I felt that I wasn't structuring my code correct. But right now, I believe I need to have some kind of pre-visualization process. There can't be anymore "Just start programming and go with it" because I have to go between file 1 and file 2 all the time, and eventually it all becomes spaghetti code. So, how do you Plan, or pre-visualize your projects. Do you go through any steps, and if so, what are they? Are there certain things you include in the process because, from experience, they help? Please share how you manage to keep the "Big Picture", as I've heard it said ;)

I'm a game programmer and computer science ninja !

Here's my 2D RPG-Ish Platformer Programmed in Python + Pygame, with a Custom Level Editor and Rendering System!

Here's my Custom IDE / Debugger Programmed in Pure Python and Designed from the Ground Up for Programming Education!

Want to ask about Python, Flask, wxPython, Pygame, C++, HTML5, CSS3, Javascript, jQuery, C++, Vimscript, SFML 1.6 / 2.0, or anything else? Recruiting for a game development team and need a passionate programmer? Just want to talk about programming? Email me here:

hobohm.business@gmail.com

or Personal-Message me on here !

Advertisement
Assume I want to create a game for example 'MotherLoad': http://www.miniclip..../motherload/en/

I write down everything I need. In this case:
- Tileable sprites for the dirt, copper, tin, etc
- sprite of a vehicle
- Bitmaps for buildings
- Bitmaps for menu's when your vehicle comes closes to a building
- Sounds
- Day/Night -> Bitmap of a sun that moves in a circle.

Ok I got kinda the basics. After this I draw on a piece of paper what classes I'll need and link them.

class main; // entry point of the application
class Window; class System; class Graphics; // will be created in the main.cpp
class Bitmap; class Sound; class Text; // stores handles to the images, fonts, etc
class Vehicle; // this will store an object of Bitmap for your vehicle.
class GameState; // will keep a state ( static int m_GameState = STATE_IN_GAME; // or STATE_MENU_MODE; such things.
class Game; // this will create all game objects, sounds, etc. Also checks collisions.
class Level; // contains information how the level looks like
class LevelProp; // props like dirt, copper, etc. Can be a virtual class and support sub-classes.

Linking I do with drawing arrows from class to class.

Still don't have any code.
Now I think "What possible methods can the classes contain?"
I give 1 example:

class Bitmap
{
public:
Bitmap(string path); // Loads an image from a file
~Bitmap();

Bitmap* GetBitmap();

void SetAnimationRect(RECT bounds);
RECT GetAnimationRect();

void StartAnimation(int from = 0);
void StopAnimation();
void PauseAnimation();
void SetAnimationSpeed(int speed);
void IncreaseAnimationSpeed(int speedDelta);
void DecreaseAnimationSpeed(int speedDelta);

void Render(int posX, int posY); // The position can also be stored and called with a method: SetPosition(int posX, posY);

private:
HBITMAP m_hBitmap;
RECT m_Bounds;
int m_AnimationCounter, m_AnimationSpeed;
};


Of course this class sucks. laugh.png It was just an example so don't copy that one. wink.png

And in case you are wondering, why not painting(Photoshop) and typing instead of drawing(on paper) and writing?
Answer: You only need to have a basic idea for your whole game. So don't waste time with with PS or Notebook.. Drawing & Writing goes allot faster.


~EngineProgrammer
Software design a tricky process, mostly guided by experience (primarily meaning "avoid ways in which you have screwed up previous designs").

The first thing I try to do is identify what the core of the project is, and thinking about how to attack that. I try to put together a prototype of that part pretty quickly (so in some sense I start programming early on, but in a very focused way). For this first prototype, all non-core parts of the program are either dummy versions or missing completely. This exercise often will result in a much better idea on how to implement the core part of the project, without wasting too much effort in the wrong direction. The rest of the parts will often just fall into place.




If you have a particular project in mind, perhaps we can give you some pointers on how to divide it up in chunks, where we would start, etc.
I get the idea I want in my head. This very often (for anything more than a day's work) requires not being at a computer, stuck doing some mundane task. Driving, shaving, waiting for the dogs to do their business, falling asleep... whatever. A whiteboard sometimes helps, but isn't required. A peer to bounce ideas off of can help and quicken the process, but isn't good right away (and isn't necessary).

It's hard to describe. I get a mental model of the solution and run through scenarios in my head, changing the model where things fail. As different pieces pass more of the scenarios, they become firmer. Once there's a pretty solid mental model, then I can go to a computer and start coding; fleshing out the details and possibly stopping if I run into an unforeseen roadblock. Often times I will segment the problem into the one I want to tackle now and work on that small chunk of work.

As I've gotten more experience (read: made a lot of bad designs) I've realized how much not being at the computer aids this. I've changed the model to use more pre-defined shapes (design patterns) than random blobs. The model is quicker to react to common scenarios (design patterns/previous good designs), and identify traits of those scenarios that guide the trait of the solution. And since the shapes are more pre-defined, I can work with much larger models now that I could as a beginner.

I've realized how much design documents and other formal design hinder my ability to design code, since the audience for the model there is different than 'me, making code'. Once I translate the design into something others can grasp well (and shift into a writing/communicating state of mind), the images pollute my mental model of it and it takes some time to firm it back up.

The process though hasn't really changed in 20 years.
Superman3275, you can see 3 different ways now to get started. This means everyone has his special way of programming, and you need to find your way. Seek out what's the best for you. smile.png
Downloading open source games / engines, exploring them has been a great help for me. So I suggest you to do the same.
Look how other people have done it. How they structure their classes, how they have written their lines of code, etc.
It's very hard to tell you a structure / design. You need to explore / see it for your own.


Telastyn, I also try to work everything out in my head. But when a week has passed it's hard to remember where I was. laugh.png That's why I'm writing/drawing it all. So if I look at my paper a year later I can still remember what I've done. smile.png


Alvaro, I used to work the same way as yours. But I disappreciate it.. Coding immediately caused me allot of messy code, which made me create new projects over and over again. And after that I got 10 files with sort of the same code and I need to look in all of them first to know what I was doing. My first year of programming I made Dragonball Z: supersonic warriors. I've count the number of versions I have: 17. With only 1 working completely. But the examination went pretty good with that file smile.png. After the examination in school I asked the lecturer how he started when he had a game in mind. He said: "I can't tell you that. Every programmer has his own way of thinking so I cannot tell you how to program like me. But I can give you a hint: Storage your information so you can return at it any time.". And so I came with a piece of paper and a pencil. smile.png


~EngineProgrammer
EngineProgrammer: I don't think of my approach as "coding immediately". I first think of a rough division of the problem into parts (this is often not easy, and it takes time), I think of what the interfaces between these parts are going to look like. Then I identify the hardest part(s) and try to code a prototype focusing there. This is very different from the experience you describe with your Dragonball Z project. Of course, I've been programming for 30 years, so I have a much better chance at making a successful prototype on the first or second attempt than anyone in their first year of programming.
Thank you for the fast response Alvaro. smile.png
You are programming for 30 years now, that's nice! I have 2 years of experience now hehe.

It would be awesome if you could help me out. You have more experience and you could help me allot now.
I know I'm not the OP but, I want to rewrite this game for another school project: http://www.rocksolid...games/robokill/
How would you handle it? Please play the first level and explore how you would create a game like that. I owe you one. smile.png

( moderators this is not offtopic. I'm asking a plan to Alvaro. smile.png )


~EngineProgrammer
Two things really help me,

First: get several white boards and lots of different colored markers start drawing your system structure.

Second: UML diagrams, there are some really nice open source UML designers out there. Use them.

Also, when I code, I start by writing the basic classes that passed around as data like a Vector, Matrix, String, Actor, Node, ect... after I get those done then I cleared out most of the small details and can focus on the larger "Manager" kind of classes, which use these data classes that are mostly done.

If this post or signature was helpful and/or constructive please give rep.

// C++ Video tutorials

http://www.youtube.com/watch?v=Wo60USYV9Ik

// Easy to learn 2D Game Library c++

SFML2.2 Download http://www.sfml-dev.org/download.php

SFML2.2 Tutorials http://www.sfml-dev.org/tutorials/2.2/

// Excellent 2d physics library Box2D

http://box2d.org/about/

// SFML 2 book

http://www.amazon.com/gp/product/1849696845/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=1849696845&linkCode=as2&tag=gamer2creator-20

That looks like a very polished game, and it probably took the authors some serious effort to put together. Notice that this is not only a programming project. You'll need graphics, music, sound effects, level design...

I've never made a flash game before, so the first things I would do are getting familiar with the programming environment and testing that I can correctly process input, animate a character, play music, play sound effects... If any of these things is trickier than it seems, better to find out early.

For a prototype, I would focus on getting the gameplay working, even if I don't have a way to load a map, sound of fancy graphics. Programmer art works to begin with.

I haven't given it nearly enough thought, but one possible division of this in blocks would be:
* Description of the scene (as a data structure in memory).
* Scene update
* AI
* Rendering
* Input
* Sound

So you need to write a game loop and work primarily on my first two bullet points (how you describe the scene in memory and how it gets updated). Of course you'll need to render it and you'll need to process input, but input is probably simple and rendering can be kept crude (think triangles instead of robots) for the first stages.

Just make sure you keep things flexible enough that it won't be impossible to add cutscenes and menus in the future. I imagine in this case it would be easier to not use the game loop at all for those things, and simply implement cutscenes and menus separately, with the game loop only running for the game proper.

I don't know if this level of detail helps you at all or not. The next thing is getting dirty and trying to describe the scene in a data structure. A whiteboard and colored markers can be very helpful.
I ask myself questions:

What are my primary goals?
What kind of system would best serve those goals?

Then I write the simplest possible version of that system, and build from there.

It's simple, but it works for me.

+---------------------------------------------------------------------+

| Game Dev video tutorials -> http://www.youtube.com/goranmilovano | +---------------------------------------------------------------------+

This topic is closed to new replies.

Advertisement