#105860 - Diirewolf - Thu Oct 12, 2006 6:08 pm
Hi, im a c# managed directx hobby game programmer (long title :D) and my current goal is to make a mario-like sidescroller (possible a mario clone). I have tried making sidescrollers using c# and directx and i made some which looked quite good but i never actually was able to put together a proper game design for my game. My code was quite messy and not really flexible or organized in any way. I need some samples, prefferably simple samples, of 2d sidescrollers (any language) or maybe an article on 2d sidescroller design. Now your probably wondering what this has to do with gba. Well recently ive moved to gba because this was my goal when i first started programming 2 years back (console development). So far ive read a lot on the gba hardware and got set up with devkitPro and visual studio. Ive made a few samples using different video modes just for the purpose of learning the basics. Now i want to aim for a sidescroller on the gba and i need some help on the game design. Sample code is fine but i would actually prefer an article which deals with programming this kind of game. Any help would be greatly appreciated.
Thanks!
#105895 - keldon - Thu Oct 12, 2006 11:15 pm
For now stick with direct x as a lot more is required from you when you get into console development.
If you start by implementing a physics engine then you can go a long way by creating much more modular code in a systematic way. Check out this physics system [click here]. Think about how you would implement such a system. That engine is very simple and requires minimal code to work the engine, and is not much different from what is required for your platform games - apart from collision etc.
#105926 - Diirewolf - Fri Oct 13, 2006 7:33 am
Its not really the engine im worried about or the directx part of it, the part that im confused on is how i would organize my classes and how different objects would interact with each other. Sorry if i wasnt clear on what i wanted. Im more concerned on how my game would be organized in terms of classes eg. how my game loop would look like, what kind of classes i need to make for my game, where exactly would i do collision detection, where would i do things like gravity pull for characters or friction with the ground. For example, before i was coding a 2d sidescroller on c#, i had the following classes:
Game
GameWindow
static Collision
GameState
MenuGameState : GameState
PlayGameState : GameState
Level
Tile
BaseSprite
Character : BaseSprite
Mario : Character
Renderer (deals with DX, contains setup functions and drawing functions)
Now what im most confused about is how these classes would interact. For Example, lets say i want to test for collision between the main character and the tiles in the level. Would i pass the currentLevel variable to each character to do testing or should i make all the variables for the characters public and test collision in my game loop? Also lets say i want to increase each characters y velocity due to gravity, where exactly would it be best to implement this? Another thing, lets say i have the main character and i have a few enemies (also characters), how exactly would i implement events such as enemy colliding with main character, or enemy colliding with another enemy? These parts are mainly where my code gets messy because im not sure which would be the best way to do/organise things. This is why im looking for some source code or articles on sidescroller development because im hoping they will explain these things clearly.
Thx for the reply
#105930 - DekuTree64 - Fri Oct 13, 2006 9:06 am
That's quite an expansive topic you're asking about :)
Designing all the various systems needed for a game and understanding exactly how they interact with eachother is difficult, and there's really no substitute for experience when it comes to making decsions on how to organize them.
For your map collision example, my first thought would be to write a seperate motion system, independent of sprites and the level class. It would operate on collision boxes and a collision tile map. Then each sprite could have a collision box, and pass that, along with its velocity and the level's collision map, into the motion system. The motion system would return whatever necessary info like how far the sprite should actually move, and wether it's on the ground. There could also be collision handler callbacks involved, which could either be called internally by the motion system, or by the sprite using the collision result data.
Check out this little game I made for the TINS allegro compo last year: .exe and data files, source, alleg40.dll (goes in windows\system). It's not exactly a shining example of clean code, but it's pretty easy to follow so maybe it can give you some ideas. The entire thing was written over the course of 2 days, so there was very little 'stop and think about how to do this', and a lot of 'type type type' involved.
Please don't copy my collision code though. I'm not even going to pretend to make excuses for putting it right in the top level map update function like that. At the very least it should be a seperate function, but really should be an entirely seperate system, like what I described before.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku
#105931 - Diirewolf - Fri Oct 13, 2006 9:17 am
WOW!!! nice game, cant wait to look at the code, my compliments. Dont worry i wont copy the collisiong code (or any code) from your game, i just want to have a look at it and compare it to my game.
Thx again
#105935 - keldon - Fri Oct 13, 2006 10:49 am
If you can develop a simple physics engine, it will add to your experience. When done properly, you can develop your physics engine into your game engine. Although having said that, it might only be of a great help if you already have knowledge of software engineering, etc. I only suggested to develop a simple physics engine so that you can find ways to make the classes interact.
This topic has been discussed many times before, but you need to know software engineering - design patterns, [possibly] development cycles and data structures. We could show you had it has been done by one person, but it doesn't mean you could follow suit and do it right, you need an actual understanding of it.
I have thrown out many links, but I no longer have access to the departmental uni website that had many of them listed anymore; but I believe that those issues are the most important for you to learn.
#105947 - sgeos - Fri Oct 13, 2006 3:00 pm
A (simplified) UML diagram would be nifty. I'll probably get around to making one one of these day if noone else does.
-Brendan
#105962 - Diirewolf - Fri Oct 13, 2006 6:07 pm
for what keldon said, i understand where you're coming from. I have never actually taken any programming/game programming classes (not even software design classes), ive learned what i know through the internet ie.tutorials + articles. So im thinking that it would be good to read a book about it, can someone recommend a good book on what keldon said.
thanks
#105966 - sgeos - Fri Oct 13, 2006 6:40 pm
For a introduction to object oriented programming:
Objects First With Java: A Practical Introduction Using BlueJ (3rd Edition) by David Barnes and Michael Kolling
Note that all of the theory behind Java applies to C++. BlueJ is a fantastic way to learn to "know" how objects work (it generates simplified-UML diagrams). After you tackle this book, you'll want to get a book on C++ and read the comp.lang.c++ FAQ. Again, all of the theory in the comp.lang.c++ FAQ applies to all OO languages (and all languages if you know how to interpert it). The mechanics of various languages are different, but that has nothing to do with design and breaking things down- those skills apply to any language.
For good coding practices and a bunch of other nifty stuff like project life cycles:
Code Complete, Second Edition by Steve McConnell
-Brendan
#105969 - Diirewolf - Fri Oct 13, 2006 6:49 pm
Thanks for the books but im pretty confident about the language. I know c++, c# and java and I have worked a lot with OOP before. Im looking for more of Game Design books which deal with code and most importantly the game design.
thx again
#105984 - thegamefreak0134 - Fri Oct 13, 2006 9:57 pm
The basic steps to get a side-scroller up and running, at least on a basic standpoint, are not that difficult to comprehend.
(1) - You need a map handling system. This should be able to scroll the maps and handle the map memory (on hardware) so that the viewport of the GBA always shows what you want it to. This is usually tied to the character movement, but can really follow whatever you need it to, for instance for cutscenes or for continuous scrolling levels. (My how I hate them.)
(2) - Character handling. You need a nice clean simple system to handle what your character can do. One of the most common ways to do this is to program the code for various \"states\" of the character, i.e. jumping, running, death, etc. and then use the keys and the events in the game to controll which state the character is in. Also, your character needs a way to interact with both the level, and the enemies onscreen.
(3) - Collision detection - a bigger topic than it should be, usually. This system needs to be able to dictate whether your character (and enemies) are floating to their doom or standing on a platform. Two methods of choice, both proven effective -
(a) Make a collision map that lines up with the screen graphics. If the character chances to be inside a particular non-solid tile, run the given effects. (land on tile, blow up, etc.) Or you could try
(b) Describe your level in terms of lines and other geometric shapes. Whenever the character\'s current path intersects a particular line or shape, trigger the collision action.
(4) - Enemy action. Not only do you need to be able to controll your enemies, your enemies need to be able to controll themselves. In a mario style game, this can be as simple as moving in a given direction and turning if it hits something. In more advanced games however, the enemies often tend to \"think\" for themselves, and guess who gets to program that in? In some cases, your game may not even need enemies, and may rely rather on clever platforming, but this is not always the case.
(5) - Stats : These are usually relatively simple things, like overall score, health, lives left, magic pooping ability, etc. However, these and other extras like a menu system and a pause screen are expected in most games and should not be neglected.
You wanted a basic rundown right? I can\'t exactly write a book for you, but this should give you a basic idea of what to think about. Also, I\'m sure I missed a few common points along the way, so someone feel free to fill in for me.
-thegamefreak
_________________
What if the hokey-pokey really is what it's all about?
[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]
#105999 - keldon - Sat Oct 14, 2006 12:51 am
Diirewolf wrote: |
Thanks for the books but im pretty confident about the language. I know c++, c# and java and I have worked a lot with OOP before. Im looking for more of Game Design books which deal with code and most importantly the game design.
thx again |
Don't worry about game design books, worry about software engineering books, as a game design book is most likely going to give you a watered down version of SE, which would help you far less than the real thing.
#106032 - sgeos - Sat Oct 14, 2006 10:12 am
Diirewolf wrote: |
Thanks for the books but im pretty confident about the language. |
The point of reading those books has nothing to do with learning the language.
Objects First teaches basic OO concepts. If you are self taught, you'd be surprised by some of the basic concepts you may not know. BlueJ's UML setup is really neat- it lets you visualize your project.
Code Complete talks about creating maintainable software projects. Something you seem to be wanting.
Diirewolf wrote: |
I know c++, c# and java and I have worked a lot with OOP before. Im looking for more of Game Design books which deal with code and most importantly the game design.
thx again |
"Game Design"? No such thing. You want to find books on software engineering and game theory. The heaviest SE books I know of are "The Art of Computer Programming" and "Design Patterns". These books are hard. I can't recommend any game theory books.
keldon wrote: |
Don't worry about game design books, worry about software engineering books, as a game design book is most likely going to give you a watered down version of SE, which would help you far less than the real thing. |
Anyone else know of any good SE books?
-Brendan
#106085 - keldon - Sun Oct 15, 2006 12:56 am
I do, I might even have one here. There is something like Design Patterns [for java], or something like that. Actually I may have sold that to someone a year down. There are others, but I really can't think of them; I just found them in the library and took them out.
#106538 - keldon - Fri Oct 20, 2006 10:20 am
some email I sent to someone wrote: |
for SE there's the Jia book (Object Oriented Software Development Using
Java - Principles, patterns and frameworks) - I have this book; i'll
sell it for ?10 seeing as i don't really need it and it takes up too
much space
There are other books such as one on design patterns - which is in the
library; I have also printed out a book that is available free online on
Design Patterns and on Extreme Programming (ideal for your SE project).
Try "http://www.patterndepot.com/put/8/JavaPatterns.htm" for the design
patterns online book.
For Systems Analysis the Bennett book (Object Oriented Systems Analysis
and Design) is the best as it also compliments what you do in SE - and
is recommended.
I also suggest you get started on design patterns right away as you WILL
do your SE project wrong without them - even if you are a fairly
experienced programmer. |
#106551 - sgeos - Fri Oct 20, 2006 3:11 pm
I wish I had a copy of design patterns with me. =P
-Brendan
#106552 - keldon - Fri Oct 20, 2006 3:18 pm
sgeos wrote: |
I wish I had a copy of design patterns with me. =P
-Brendan |
I just wish I had returned my books to the library. My overdue fee must be about $50 right now.
#106593 - sgeos - Sat Oct 21, 2006 2:58 am
keldon wrote: |
I just wish I had returned my books to the library. My overdue fee must be about $50 right now. |
Is that an annoying $50 or an I have no cash and can't pay $50? If it's the former, I'd return the books promptly. =)
-Brendan
#106602 - Diirewolf - Sat Oct 21, 2006 8:24 am
So you think i should read a Software Engineering book? Aren't there any SE books specific to game programming? If so wouldn't it be better to read one of those?
#106609 - sgeos - Sat Oct 21, 2006 9:45 am
Diirewolf wrote: |
So you think i should read a Software Engineering book? |
Yes.
Diirewolf wrote: |
Aren't there any SE books specific to game programming? |
Many, they just are not very good SE books.
Diirewolf wrote: |
If so wouldn't it be better to read one of those? |
Not if you want to get good at SE. These books tend to do things like point out the advantages and disadvantages of various graphics formats. If you want a book that gives goes into great detail about algoriths, you want an algorithm book.
Writing games properly is no different from writing any other kind of software. Games on something like the the GBA live in a loop that never exits. The loop looks something like this:
Code: |
int main(void)
{
initGame();
while (1)
{
waitUntilNextFrame();
updateGame();
}
return 0;
} |
After you know at least basic SE, read the code of some games or just observe them in action. With enough experience you should be able to come up with a solution to just about any problem on your own. You can always ask for help.
-Brendan