Basic game thoughts

Basically i'm making a snake game with an oop approach.
Now my problem is:

Does the Game class handles the snake movement or the snake has methods to move in the grid?

pseudocode:
1
2
3
4
5
6
7
8
Game::HandleImputs(){
blabla
}
or

Snake::Imputs(KEYBOARD key){
left right bla bla
}


And also, how can i speed down the snake?
I'm currently using SDL and i feel SDL_Delay() is just wrong (i'm decreasing it everytime he scores a point)
Choose whichever method is easiest for you to follow. By the time you finish the game, you would either switch to another method or stick with the one you started out with.

If you start waiting around to find the best method, you will never start your project
Does the Game class handles the snake movement or the snake has methods to move in the grid?


Since it is a simple snake clone I would say just keep it simple and just handle all user input inside your game class. What way you do it doesn't really matter, you could just have each key hardcoded to do something, or you could create a map which maps each key to a callback command which runs when that key is pressed. It is really up to you but since this is a small game I would say keep the input handling solely inside of you game class.

I would also suggest looking into the Command Pattern which works perfectly on problems like this. Also if you are into design patterns you the State Pattern would also be good reading on this subject.

Anyways hope that helps, just keep things simple for this game and once you gain a bit more experience you can state branching out and trying out more complex input handling techniques.
Last edited on
And what about the Delay in the game, is SDL_Delay (or sleep() or some other function like this) the best way? Because i want to add networking to my game.
Topic archived. No new replies allowed.