my second coming
hi there i would like to ask for some advice i have recently started to make games again. i made one game before using sdl which was ok but never finished and polished.
the game i made i didnt really use classes and as a novice c++ programmer i fell the coding of the game was the easy part.
ok my question is how do you start designing a game i mean how do you decide the classes to use and which functions will belong to which class.
ok that might sound easy but i normally position things on screen manually and work out my collisions manually which is ok until i need to change the window size so either a little advice or maybe a link about the design of a game would be much appreciated.
thanks in advance :)
edit: ok maybe using a tetris clone as an example? what classes would you use im fairly sure once i got the idea of classes i could code them together its just the picking choosing of classes that gets me. how do you decide which classes are needed. thanks again :)
Deciding classes and such are never easy and there's never a must-do example.
But the general idea is to consider classes as objects, so in a tetris game, a class of the falling parts, one base class for them and from them derived classes for each type of part since they have different properties. If anything, their dimensions would be specified in a derived class.
One class for the actual room where the blocks fall. It must contain a vector with all the parts inside. It will also probably be the one that's responsible for seeing if there are any full lines are for collision detection. Each part class will probably keep track of its own coordinates in the room.
There's more, to be sure, but just off-hand, I cannot say. It will come to you when you start designing the whole thing. You just need to know what tools are available to you and think logically how they might fit into a solution for your design problem.
There's going to be polymorphism and virtual functions too (due to the base class).
Other might give you a different answer. It's up to the designer, really. A good implementation is one that will require you to do little code in sense of checking this and that, one might say. Or I don't really know how to explain it.
In any case, you really have to try and pan it out yourself. There are no definite rules for layout.
thanks for your advice i appreciate it and will try now to use it and put the pieces into perspective my aim for now is to make a packman clone for my daughter but i thought mapping the collisions for everywall would be tiresome and also i would need to do that for each map i made so i decided that i should start with a tetris clone maybe to get the idea ball rolling.
i have used sdl before but i am going to try using open gl so that i can create 3d games in the near future. would you advise me to do this or should i go back to sdl until i have more game programming and genral programming experience?
I'd stick with whatever was simpler to begin with, if you already have a bit of SDL experience I'd suggest sticking with it. I tried to dive into OpenGL but got overwhelmed with it, I was trying to create a far too advanced rendering system for my knowledge.
Now I'm working on a text blackjack game and learning is coming much easier.
I haven't used SDL at all, so no ideas there.
Stay with SDL because you can use openGL if you want. Personally I find SDL gets in the way too much (my opinion), so I use glfw instead.
ok thanks i think ill go back to sdl for now as opengl seems to be more for 3d and less forgving toward 2d?
wow its not until u try to make tetris that you realsie its a bigger task than ive ever undertook.
so far im still on the design stage as this for me is the hardest part because i can simply find tutorial and advice for code but working out the inner functions is very hard for me at the moment.
i have decided that i will try to make a 2d array for the grid and in turn that will draw the blocks as need be.