Jump to content
  • Advertisement
Sign in to follow this  
Cadmus

How do I practice with C++

This topic is 4439 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm still relatively new to game programming, but since everything is based off of C/C++, I was wanting to do some practice while I'm still in school (something outside of the books and school assignments). I was wondering what would be a good way to go about accomplishing this task. I would like to create my own programs, but I just don't know how to start or what to create for practice. Any suggestions would be great, and I appreciate your time for looking into this for me and possibly many others who are struggling with this.

Share this post


Link to post
Share on other sites
Advertisement
Simple programs are the best way to go. Don't get worried about using every detail of OOP all in the same program or having at a certain number of functions or variables. Just limit yourself for now. Make small consoles programs and stay away from trying graphics at the moment. Once you have console programs down you can check out a graphics API down the road.

I would suggest doing the first program that mostly every programmer does which is hello world and then go from there. If you want to get into games make a guess the number or letter game. Then move from there and start working on a text adventure. Just remember to let everything sink in and you will get the hang of it. Good luck!

Share this post


Link to post
Share on other sites
Well how much experience do you have? (API?) The best way to practice would be to make some sort of program, naturally.

Share this post


Link to post
Share on other sites
If you need experience with something think of a program you could write that is based on whatever you need experience with.

For example, after I finished my first course on C, I was still pretty iffy with pointers and dynamic data structures, so I wrote a little program that posed as a "bank" with accounts stored in a text file and everything. Each account was stored in a new element in the linked list. As a result I know linked lists and pointers as well as anyone else who's been programming for a couple of years as well as getting some proper experience in basic text file parsing when I loaded the accounts into the linked list.

If you can think of a skill/area which you want to learn, attempt to think up something that you could program around that. Obviously don't go for re-usable code at the moment, just something that you can learn from and then throw away.

Share this post


Link to post
Share on other sites
It depends on what course you take. First you do console to get a basic knowledge and feel for programming and then decide.
If you want to do just 2D, then your probably looking at GameBoy and stuff, because they are the main things for 2D.
If you will do 3D, then you should (although optional) learn at least a bit of 2D first, to get the hang of it, then use OpenGL (nehe.gamedev.net is a very good free tutorial) or DirectX (I wouldn't know tutorials for this as I am only learning OpenGL ATM, but you could try www.ultimategameprogramming.com)
The choice is yours to make, but the PC, XBox and PSX releases are almost all 3D with 2D parts in them (Mini-games, etc. This is only reason why I suggest at least basic 2D first)

I'm still learning myself, but that is my advice that I have recieved from others. For 2D, everyone uses SDL or Allegro from what I've heard. I can't get either to work, so... meh. Not yet sure. SDL seems much more popular, but you should really keep an open mind about these things (unlike me ;)

Share this post


Link to post
Share on other sites
You could try making some simple games if you're interested in that. Have you started learning the language yet or are you an absolute beginner?

Some games you could make it the console (text mode):
- Guess the number
- 'Hangman'
- tic-tac-toe (naughts and crosses)
- text-adventure (optional, can be quite time consuming and reasonably complex)

And some graphical ones for once you're familiar with the language:
- tic-tac-toe (again, but with graphics)
- pong (followed by 'breakout'/'arkanoid')
- asteroids
- snake
- tetris (can be tricky for a beginner)
- pac-man
- mario brothers (or your platformer of choice)

You could also try changing things around and adding your own twists to things if you'd like.

You should start out in the console making fairly simple things so that you can get a good understanding of how the language itself works, and so that you can try out new things without having to worry about too much at once. Once you think you're comfortable with the language and can write some decent console programs, you can then choose a graphics API (SDL or Allegro are good choices for a beginner) and start learning the basics of that, moving on and building from there. Even if you already feel you know the language pretty well, trying out a console game or two first might be a good way to get your feet wet with thinking about how to get a game working without having to deal with the added complexity of displaying graphics.

If you havn't already got books, tutorials and whatnot, I'd recommend the book Beginning C++ Game Programming, and for online tutorials, the C++ tutorials at www.cprogramming.com.

Hope that helps you. [smile]

Share this post


Link to post
Share on other sites
The first game I ever programmed with C++ was a console version of Tic-Tac-Toe. Kazgoroth already mentioned programming simple games, but I'd like to add one more game to the list: Minesweeper. My second game was a console version of Minesweeper, and in programming that game I learned quite a bit about troubleshooting and ingenuity, both of which are probably as important as actually knowing the language.

When looking at books, make sure that they have a section at the end of each chapter for practice assignments. Sure, it's a bit like homework, but many times it's the actual use of the language that learn from, not just reading about it.

Just keep at it! Don't rush the basics, take your time and make sure you know something before moving on, and above all else, have fun. That's what it's all about.

Good luck!

Share this post


Link to post
Share on other sites
Pacman makes for a good second (graphical) game. Maps are easily created with notepad, and the collision detection/rendering is very easy, too.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!