12 Replies - 3816 Views - Last Post: 17 July 2009 - 11:26 AM Rate Topic: -----

#1 Xioshin  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 264
  • Joined: 05-November 08

2D Game Programming (with graphics)

Posted 07 July 2009 - 02:59 PM

Hi guys, I have a good grasp of C++ console application programming, variables, input, control flow, etc, and would like to start creating 2D Tile Games. Problem is, I know nothing about graphic programming in c++.

I could start working on my game in console application form by doing these steps:

1) Initialize some character variables such as initial position 2,2 in a 5x5 array. [x = 2, y = 2]
2) Create a 2D array, size 5x5 as the game world [purposely small]
3) Put nothing in empty cells to let me know they are empty, make the player "O" and put him in 2,2, and put some obstacles in the array as "X"
4) Display the map, ask the user which direction he wants the player to move and take it in as input.
5) With the input taken in from the player, run some tests using complex if-statements to check whether or not the player is about to move into a spot with an obstacle. Prevent the move if these statements return true.
6) Redisplay the map with the updated move

I currently have the programming knowledge and ability to create this. What I would like to do is move on to the next step, graphical programming. I want to create a 2d engine that will allow me to move a character around a small map.

I understand there is a difference between just 2d movement in a game and 2d TILED movement, so If I need to, I will try to create what I just explained above in graphical form, before moving on to 2D gaming WITHOUT tiles, using collision detection.

Any help you can give me is appreciated (point in the right direction, tips, links to your favorite tutorial that you have used successfully to learn this). Thanks a lot in advance.


~Xioshin

Is This A Good Question/Topic? 0
  • +

Replies To: 2D Game Programming (with graphics)

#2 Speedy_92  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 57
  • Joined: 02-July 09

Re: 2D Game Programming (with graphics)

Posted 07 July 2009 - 03:09 PM

Hi Xioshin,
I would like to recommend you this tutorial, and this one. They are both about SDL and in my opinion very easy to understand. The second one is a bit larger, but I have given you the link to the first one, because I really like the autor's programming style. There is also a tutorial about Tile-Maps.

I think, 2D games are not any harder than console games. It is just in graphical form, which is sometimes even easier than fumbling around with the text output.

This was just my individual opinion and maybe you share it sometimes with me ;)

Speedy_92
Was This Post Helpful? 0
  • +
  • -

#3 Xioshin  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 264
  • Joined: 05-November 08

Re: 2D Game Programming (with graphics)

Posted 07 July 2009 - 03:24 PM

View PostSpeedy_92, on 7 Jul, 2009 - 02:09 PM, said:

Hi Xioshin,
I would like to recommend you this tutorial, and this one. They are both about SDL and in my opinion very easy to understand. The second one is a bit larger, but I have given you the link to the first one, because I really like the autor's programming style. There is also a tutorial about Tile-Maps.

I think, 2D games are not any harder than console games. It is just in graphical form, which is sometimes even easier than fumbling around with the text output.

This was just my individual opinion and maybe you share it sometimes with me ;)

Speedy_92


Thanks for the link! Is SDL the best graphic library to use in C++? What are the others and their pros/cons?
Was This Post Helpful? 0
  • +
  • -

#4 Notorion  Icon User is offline

  • D.I.C Regular

Reputation: 35
  • View blog
  • Posts: 378
  • Joined: 17-February 09

Re: 2D Game Programming (with graphics)

Posted 07 July 2009 - 03:32 PM

I have heard SDL is the best place to start with graphics, but there might be some other opinions. I am a beginner at this as well, thanks for the tutorial links Speedy.
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,217
  • Joined: 23-August 08

Re: 2D Game Programming (with graphics)

Posted 07 July 2009 - 05:25 PM

Moving to Game Programming
Was This Post Helpful? 0
  • +
  • -

#6 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: 2D Game Programming (with graphics)

Posted 07 July 2009 - 08:48 PM

Quote

I have a good grasp of C++ console application programming, variables, input, control flow, etc, and would like to start creating 2D Tile Games.
No you don't. You are nowhere near ready to start applications with 2D or 3D graphics. Don't get mad when I say this, and you'll likely go ahead and make a pass (as I once did and everyone else does), limp your way through tutorials, and discover after the end you still have no idea what you are doing. That's OK, but the sooner you get back to working with console based applications, the better.

Quote

I want to create a 2d engine that will allow me to move a character around a small map.
I thought you wanted to create a 2D game? A game and an engine are different. Consider that an engine is a reusable, generic library of code. Can you really create reusable code that would have a good design that you can use over and over in the next games you or someone else makes? If not, it's not a 2D engine you are going to be making.

Quote

I understand there is a difference between just 2d movement in a game and 2d TILED movement
Just a decoupling. Internally, your game will have some logical representation of what 2D is, and what position is, and what movement is (these concepts don't exist, you get to make them up). Then you build up the graphics logic to represent what is going on internally.

Quote

Is SDL the best graphic library to use in C++? What are the others and their pros/cons?
There is no best. Pros/cons is also the wrong question to be asking when you don't have a precise technical decision to make.

SDL is a cross platform layer over some basic fundamental aspects of a game. This includes creating a window, basic event handling (in particular, keyboard, mouse, and joystick), some basic graphics manipulations and support for using opengl instead, a bit of audio support, cdrom, threads, timers, and some file i/o support. And all of this has some cohesiveness throughout the library.

SDL is C based library. I don't know about the C++ bindings, nor if I would care to use them. In fact, for C++ programmers I would suggest SFML first. It's pretty much designed along the same kind of mentality (a thin cross platform layer of functionality) but the API is going to be nicer to use.

You aren't bound to to SFML or SDL. But for a comprehensive cross platform layer, you don't get better. If you're willing to throw out cross platform, then you get DirectX as a complete cohesive package of libraries. Well, DirectX and the Windows API.

Otherwise, you tend to construct what you need from various libraries. For graphics, you might use raw OpenGL, or work with a graphics library or engine like Ogre. Threading with pthreads or Boost.thread or whatever. Timing with whatever the OS provides. Audio with something like Fmod or Irrklang. And so on.

And then you have complete game engines. If you're in a hurry, look at game engines first.
Was This Post Helpful? 0
  • +
  • -

#7 Xioshin  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 264
  • Joined: 05-November 08

Re: 2D Game Programming (with graphics)

Posted 08 July 2009 - 04:55 AM

Your post was very informative and packed with information, thanks for that.

I have created many programs in C++, but stopped for about 8 months. Starting to get back into it, reading some tutorials, and coding some small console programs.

I have also programmed in PHP and other languages for years. I think I DO have a good grasp of the beginner aspects of the language. I don't see why I wouldn't be able to start working on programs with graphics.

Sure, I agree with you that I could probably learn more advanced things inside the console right now, but I can't think of anything I want to spend my time coding. As for your comment about SFML, I will definitely check that out :)

EDIT
Found an awesome site for tutorials. http://www.sfml-dev.org/index.php

Today after work I will start! But I will definitely continue to learn and do more programming in the console as well.

This post has been edited by Xioshin: 08 July 2009 - 04:58 AM

Was This Post Helpful? 0
  • +
  • -

#8 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1376
  • View blog
  • Posts: 10,951
  • Joined: 06-February 08

Re: 2D Game Programming (with graphics)

Posted 08 July 2009 - 05:04 AM

View PostOler1s, on 8 Jul, 2009 - 02:48 AM, said:

Quote

I have a good grasp of C++ console application programming, variables, input, control flow, etc, and would like to start creating 2D Tile Games.
No you don't. You are nowhere near ready to start applications with 2D or 3D graphics.

Bullshit. :) In fact, there's a kid here (Pontus I think) who started with SDL right away.

From what I read, he/she sounds perfectly capable. Besides, graphics really aren't as difficult as people make out. Especially basic 2D stuff.

This post has been edited by gabehabe: 08 July 2009 - 05:05 AM

Was This Post Helpful? 0
  • +
  • -

#9 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 994
  • View blog
  • Posts: 4,158
  • Joined: 14-February 08

Re: 2D Game Programming (with graphics)

Posted 08 July 2009 - 05:47 AM

Far better is it to dare mighty things, to win glorius triumphs, even though checkered by failure... than to rank with those poor spirits who neither enjoy nor suffer much, because they live in a gray twilight that knows not victory nor defeat.

my 2 cents :^:
Was This Post Helpful? 0
  • +
  • -

#10 Speedy_92  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 57
  • Joined: 02-July 09

Re: 2D Game Programming (with graphics)

Posted 08 July 2009 - 05:50 AM

View Postgabehabe, on 8 Jul, 2009 - 04:04 AM, said:

View PostOler1s, on 8 Jul, 2009 - 02:48 AM, said:

Quote

I have a good grasp of C++ console application programming, variables, input, control flow, etc, and would like to start creating 2D Tile Games.
No you don't. You are nowhere near ready to start applications with 2D or 3D graphics.

Bullshit. :) In fact, there's a kid here (Pontus I think) who started with SDL right away.

From what I read, he/she sounds perfectly capable. Besides, graphics really aren't as difficult as people make out. Especially basic 2D stuff.


Look at my nickname, so you can see, that everyone can handle it ;)
Was This Post Helpful? 0
  • +
  • -

#11 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1376
  • View blog
  • Posts: 10,951
  • Joined: 06-February 08

Re: 2D Game Programming (with graphics)

Posted 08 July 2009 - 07:00 AM

View Poststayscrisp, on 8 Jul, 2009 - 11:47 AM, said:

Far better is it to dare mighty things, to win glorius triumphs, even though checkered by failure... than to rank with those poor spirits who neither enjoy nor suffer much, because they live in a gray twilight that knows not victory nor defeat.
I like this. Where's it from?
Was This Post Helpful? 0
  • +
  • -

#12 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 994
  • View blog
  • Posts: 4,158
  • Joined: 14-February 08

Re: 2D Game Programming (with graphics)

Posted 08 July 2009 - 07:09 AM

It was said by the 26th President of the United States, Theodore Roosevelt.

Very poignant!
Was This Post Helpful? 0
  • +
  • -

#13 zymethseven  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 17-July 09

Re: 2D Game Programming (with graphics)

Posted 17 July 2009 - 11:26 AM

Sorry, if i want to develop game Tank. what the step for developing it?

I don't know about step for developing. Plz explain for me.

Thank you very much.

I am student in thai. if eng is wrong, i am sorry. T^T
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1