where i try to answer your questions about game development

Friday, November 23, 2007

Text Console Library

When you first start coding in C/C++ your first programs are done in the console. The problem with the console nowadays is that the conio.h library no longer lets you do all the fun things it used to, like set the text color, set cursor position, clear the screen, etc. You can only print text out in a stream just like the olden days of the 70's and teletype printers. Lame.

This is the problem that all beginning game coders run into and it really takes some of the fun out of learning when you can't even sit down and try to write Pac-Man in text mode.

So I poked around and found a little snippet of code, added my own functions and now I have a nice little text console library you can use. Just add the console.h and console.cpp files into your empty Win32 console project and you can actually make text games. Without this kind of library you can't really make any kind of fun text game other than an adventure.

I threw together a short sample program to demonstrate what you can do. It's a simple maze that has a random exit ('X') in it; touch it and you win. The source is named main.cpp. The game? ULTRA-X OF THE FORBIDDEN REALM!

To add even cooler stuff to your console games you should download FMOD and link it into your project. Instructions on how to do this are on FMOD.ORG and are easy to follow. Imagine that - a text game with background music and sound effects. :)

Grab the code here

Monday, April 30, 2007

Beginning C++, pt. 2

After further investigation and actual use, I would like to now recommend Michael Dawson's book "Beginning C++ Game Programming". I went to the book store, rifled through a ton of C++ programming books and after getting through my filter I settled on this book for my son Michael to start with.

Even though the title of the book sounds like you'll be getting into a bunch of fun game stuff the reality is that all the focus for the first 8 or so chapters is just on learning C. C++ comes in during the next couple chapters and builds upon what you learned about C but doesn't go too far - it keeps it simple.

Along the way you use the language to construct a few simple games that are all text-based which I believe is a great way to just focus on learning the language and some basics about game construction. So don't be expecting to be drawing graphics and making sounds and using the mouse on a graphical screen - you need another book to do that and it should be AFTER you get through this one.

I got Michael a book on coding game graphics that he's diving into now since he finished this book. I'm proud to say that he can program in C++ now after finishing this book and it's not an overly long one either. It's also very easy to understand with good explanations for the concepts.

Some things I would have liked to have seen in the book were explanations of switch() before its use, using struct{} and explanations of complex data structures, and explanations and use of printf. The book relies heavily on cout and cin which I'm not too fond of because of the syntax but they're easy to understand when it comes to printing string objects. When Michael was going through the book I taught him printf and had him convert all the couts in the book to printfs - it showed him more about what goes on inside those string objects and was less typing when he needed to print %d, %s, etc. arguments.

Try it!

Tuesday, May 30, 2006

beginning game programming

Just got an email about game programming books, a very popular question I get:

Hey John, I've mailed you before but I doubt you remember; with that said, I love your games! Always have, always will. I've done a bit of game programming with some beginner's languages like GML and many versions of BASIC, but I'd really like to learn C. I have one question: I've pretty much learned all there is to make console applications, which is all I can find tutorials for. Where can I get some info on basic graphics programming? Just drawing/manipulating bitmaps or pixels, something like that.

Thanks!

-Jake


Here's what I would recommend with just a quick search on Amazon: Beginning Game Programming by Michael Morrison.

Now, I haven't had to read a game programming book in about 22 years but this one seems pretty solid with good reviews. Sure, some of the reviews might be by the guy's mom and friends but how else can you tell if it's good unless you try it yourself?

I'm sure some of the readers here can recommend other great books - that's what this section is for!

Monday, February 13, 2006

code newbie?


Continuing on from my previous post, if you're a beginning programmer there's a great site out there for you: Code Newbie. You absolutely do not have to know how to program already when you go to this site and you can get great explanations of common programming problems in the forums. Check it out!

Tuesday, January 31, 2006

total beginner programmers


Just today I got this cute email from a 13-year old:


Dear Mr. Romero,

I'm a thirteen-year-old boy who absolutely loves the games that you've made throughout the years, so much that I really want to start programming, however, I don't know where to start.
BASIC seems too small a language to aid me in what I want to do, create the games graphical engine, but C# and C++ seem a little robust for a beginner. What do you think?
I really want to program, and I know that I do want to learn C# and C++, it's just that I'm not sure if they're the best languages for me to start in. I'd sort of like to learn BASIC, but I really can't find any good tutorials online, do you have any that I could possibly use?
Anyways, I hope that you take time out of your busy schedule to reply, but I won't be absolutely crushed if you don't. Thanks.

Sincerely,
Zachary


This was an absolutely great, well-written email with an excellent question. My answer is pretty much the same every time: if you want to learn how to code, you should be learning C. You can learn C++ later but I still believe it's best to go the C/C++ route rather than Visual Basic or some scripting language.

My personal favorite environment is the Visual Studio C++ Standard or Professional Edition. The Standard Edition is around $280 online and has everything you'll need for quite a while if you're a beginner.

If you're on a budget, like, a no-money kind of budget, then you should download, for free, the Visual C++ Express Edition product by Microsoft. There's even a nice book for complete beginners on Amazon.com that will help a lot.

This dev environment can get you through PC game development, handheld development (PocketPC anyone?) and with enough tweaking you can get it to work with external compilers for special hardware.

in the beginning...

I get so many emails asking me development questions that I decided to just start an area where I try to answer them and hopefully the information will help.

Several readers will be commenting and giving their own opinions and viewpoints - but what you read from me is what I believe from my experience.

Here we go!