Basics of 2D games

I am looking into making a 2D game like Pokemon or Don't starve in c++, but I don't really know all of the stuff I would need to know.
Some of the basic stuff I can think of is arrays,how to make a window,displaying images, and receiving key input.
My advice:

Start simple. Take things 1 step at a time. Learn how to do each step.

Get a window up and running.
Then draw an image
Then move that image around
Then move that image around in response to the user pressing a button
Then have one image move around on its own, while another image is user controlled
etc
etc


When learning a new thing, write a separate test program before applying the knowledge into your main program.

Don't be afraid to rewrite your main program once you learn something new that significantly changes things. Odds are you won't get things right your first time out of the gates anyway, and rewrites are not that big of a deal until the program gets bigger (when starting, I had projects that I rewrote like 4 or 5 times -- it's more about education than making the final product).



As for how to do these things... SFML is an easy to use 2D graphical window lib that has support for lots of other things you might want (like audio, gamepads, etc)

http://sfml-dev.org/

Download and install it. There are tutorials on the site to help get you started.
Besides those basic things you mentioned you will probably also need to learn about AI and pathfinding, scripting, and sprite animation.

Also the data structures and design patterns that are useful game programming.

I'm with Disch when they say "start simple". Don't jump in and start writing your dream game. Start with the extreme basics: tic tac toe, tetris, breakout, pac man, etc.
For a Pokemon clone pathfinding isn't a big deal and the only AI is actually quite simple. When against a trainer all the trainer does is use a set Pokemon team and, when it is a gym leader, uses a potion when their Pokemon get low in health.

The Pokemon simply use one of their attacks that are most effective against the enemy and if no attack is super effective then they use either a status changing move or a normal attack.
For the catch rate i imagine that they have a random number generator and they set the maximum number to 255 (the minimum catch rate) and then check to see if the random number is between 1 and the Pokemon catch rate. If it is in this range then it will catch, if it is, say, 1-4 numbers away then the Pokeball shakes 3 times but then opens, 5-8 it shakes twice, etc.

The only pathfinding needed would be the NPCs walking around outside which wouldn't be very difficult to implement.


For a don't starve clone i don't know exactly what would be put into it as i have only recently begun my first 2d game that i am hoping to publish (and it is a relatively simple game) but it would require knowledge of AI and pathfinding.

So for a pokemon clone it won't be too difficult.
for a don't starve clone it would be more difficult.

P.S. This is just speculation on my part and I don't actually have any evidence other then what I have seen so please correct me if i'm wrong

As for what you need it would be: displaying images on a window, manipulating that window, player input, random (number or otherwise) generators, game states, progress/stat saving, i'm sure there are other things but i can't think of them right now.

once again correct me if i'm wrong
Last edited on
Topic archived. No new replies allowed.