PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Internal game design

slashandburn · 27 Mar 2003, 00:10 UTC
How should i make coding a game easier

:?: Use a base class and create sub classes for each part. That have a draw function and a input function and an exit clause. So to change scenes i would only have to change the pointer.

:?: Or code the project in one huge file that contains switches and elseif options that link to game functions.

And the game is like risk, but against various computer systems so there would be lots of option screens and dialogs.
I generally create classes for the different components with each having their own rendering methods, but I always handle the draw ordering within ProcessNextFrame so I get a single flip() at then end of it all.

I do use gamestates to keep solid control of logic flow.
slashandburn · 27 Mar 2003, 02:54 UTC
i think i will use classes and pass an array of graphics to the class.

I think the structure would be :
drawframe(surface,graphics array)
handleclick(point)
handleinput(button, stuff)

and then the class would indicate to the application to switch classes and when to shutdown. so after the frame is drawn it would check for a change notification and delete the current class and set the pointer to a new class.
Just to let you know, new and delete are really slow on a pocket pc. If you are going to be doing memory allocation in the middle of your game I would suggest building an optimized memory manager. (Something that understands your game objects and does more preallocating and recycling of objects.)