A nice friendly community for Amateur, Independent, Freelance, Student, Hobby, and Commercial Game Developers alike
Join us!
Click here to join CGEmpire, a quickly growing indie / commercial game development community
with free tutorials, advice, member blogs, discussion forums, activities and competitions!
User CP
My CGEspace
Arcade
Gallery
Member Blogs
Articles
Today's Posts
About

Welcome to the CGEmpire forums. A friendly online community aimed at professional and amateur game developers, artists, coders and musicians.

You are currently here as a guest - you may read the discussions, but by joining our free community, you'll have access to post topics, PM, and many other features. These include CGEspace, where you can upload art into the advanced personal gallery system, music into your own online jukebox and a detailed profile!

Registration is fast, simple and absolutely FREE so please, join our community today!

Log on:             
 
Terror in ASCII Dungeon! A C++ tutorial for codephobes - Part 1
Tutorials

LinkBack (2) Thread Tools Display Modes
  2 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 06-13-2006, 02:53 PM
chris's Avatar
chris
Resident
1,262 Posts
Location: North-East England
General Code
Freelance / Contractor

Introduction


So, you’ve just opened this thread because you want to make a game, right? Maybe you just clicked on it because you were curious, or just checking out all the new posts on the forum. You’ve always fancied giving it a go, sure, but everything you’ve read on the subject you’ve just felt overwhelmed:

“I could never program games, all those numbers and code; it just fries my brain!?!”

If this is you, then you are in fact exactly the kind of person I’m hoping to introduce to game programming. Yes, writing a high-tech 3D engine may be out of your reach, at least for now. But actually making a nice simple game, with the proper introduction, is not as much of a leap as you might think.

This guide will require literally no programming knowledge, and the software used is completely free to download. Everything is explained, in small manageable bites, by analogy, or by explaining how they are relevant to games, and the design of the game. After finishing the tutorial, you will not be a master of manipulating computer memory, not in the position to start writing funky rendering effects on-screen, and not knowledgeable enough to write complex AI systems… You won’t be qualified for a game industry job once you reach the last page…

… but you will have made a game!!

You did! You who thought you could never write code. And furthermore you will then be at the level of skill where, with an internet connection and some patience, you could most likely amble through making another game all on your own.

You will then be in a much better position to learn all the technical stuff this tutorial flagrantly ignores, as you will have a good idea how games are structured, how C++ works on a high level, and the syntax and formatting used. You may not understand *how* things work under the bonnet, but you will understand what these “magical things” are useful for, and how they should be used.

Those things you read before and found “overwhelming” will no longer be so, and you will be in a much better position to learn the lower level details on how those “magical things” you use actually work.

Then it’s just a matter of time before it all just *clicks* -- you feel it, one day -- and from that point you will feel you could give anything a go.

You don’t need to be particularly good at mathematics, though that will obviously help. At the end of the day, you tell your computer to perform complicated calculations--you don’t need to perform them yourself! You will need to be able to think what *kind* of equations you need in a situation, but this is more of a case of remembering which ones are used for what you need, and I will try and explain these in an intuitive manner so you can think about *what* calculations you need to do, even if you'd have no chance of working out the answer yourself . No multiplying this by this, carrying the 1 and hoping you’ve got the answer right will be necessary

To follow this tutorial, you do however have to:
…be able to read pretty well. If you are reading these words, it is likely you can read well enough.

…be able to type letters into your keyboard, and use the shift key to access different symbols on the keyboard. The faster typer you are the better, but just being able to do it is enough.

…understand that even if something is represented visually on-screen (e.g. a bubbling red pot of health, or how pissed off an enemy is) it will actually be a number under the bonnet.

… have a basic handle on logic. For example: opening the window before putting your head through it, and not the other way round.

… understand the principal of deciding whether or not to do something based on what else is happening. For example: Only crossing the road if there isn’t a bus approaching at high speed.

… understand the principal of doing things numerous times until some condition is satisfied, for example washing your car until it is clean, or poking a cat with a stick until it is no longer stuck in the tree.
If you answered no to one or more of these, then you might have some difficulty (in life, not to mention this tutorial, if some of the latter ones).

I've leant towards over explaining things more than under explaining things in this tutorial, and assumed that the reader may not have understood points when they are raised the first time. This is because I would rather people who digest a point quicker would need to skim read a paragraph or two, than leave someone who did not understand anything in the tutorial lost and unable to continue, so I hope none of this tutorial comes off as patronising, as this is by no means the intent.

Now onto what we are going to make!

Register for free to remove these ads!


Last edited by chris : 08-12-2006 at 02:43 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-13-2006, 02:58 PM
chris's Avatar
chris
Resident
1,262 Posts
Location: North-East England
General Code
Freelance / Contractor

ASCII Dungeon

In this tutorial we will look at the process of making a really simple (yet really cool) RPG dungeon using ASCII art (letters, numbers and symbols [^$%&()”$:@~}{P<>] put together to make pictures).

The game will be inspired heavily by an old freeware ASCII RPG called Rogue that, despite being a bit basic on the graphics front, was perhaps one of the most fondly remembered games I’ve ever played… In fact one of the top on my list of games I’d love to have made…

Ctrl/Shift+Click: Zoom In, Click: Zoom Out, Alt+Click: Reset
Kill that demonic bat!

Ctrl/Shift+Click: Zoom In, Click: Zoom Out, Alt+Click: Reset
Make sure you don't get lost in... ASCII Dungeon!

In our game, you will be able to explore randomly generated dungeons with your ever smiling hero ASCII Man, and meet a range of terrifying ASCII enemies to fight, and funky ASCII weapons and magical items to use. The beauty of it being ASCII is it’s so symbolic you can stick whatever setting you would like on this. Is it a dark, dank industrial space-ship? Or some parallel universe where sheep are the dominant species? Will you meet bats and trolls, or perhaps Nazis? You decide. This tutorial will try to encourage a bit of creativity, so you don’t all end up with exactly the same game.

This tutorial is aimed at those who want to understand how to make a game, but are simply not ready to plunge all into all that whole low-level computer math stuff that seems so daunting to the newbie.

After following this tutorial you will hopefully have a good overall idea about the following things:
1)Game loops: how a game runs through a “loop” of instructions constantly and updates all the various bits and pieces to make your game do funky stuff.

2)Program flow – How the program can take different routes depending on the situation, and how you can perform tests on parameters in the game to decide different routes to take.

3)2D graphics: While you won’t be making any pretty, colourful 2D graphics, making a game with ASCII art still teaches a good few important lessons about 2d game programming. Even a few lessons useful for 3D! Better still you don’t need to be an artist to complete this tutorial, and you will not be overloaded with things to learn. Once our game is complete we will look into making the game use proper 2D colour graphics.

4)Input: You will learn a bit about being able to use your keyboard to control your character.

5)Object Orientated Programming – You will learn about how objects can interact together in a game, in code, and how to use this to map out in your head how your game is going to work before you write it.

6)File-Formats – Namely XML, you will have all your monster, weapon and magic items defined in a text file in your game directory which you can edit, tweak, and add to outside of your code.
I’m going to skip through a lot of fundamental stuff about C/C++ and programming in general. Not to say it is not incredibly important, but that you’ll be much more prepared to take all that in once you have a game under your belt. And this time round, you don’t need to know these little bits and bobs, because I’m here to help you through this one

How a Game Works

Think of your PC running a program like a bunch of actors on-stage reading a script. The script gives the actors a bunch of instructions: “Walk to there, say that, walk to there, pick that up.” The actors carry out these instructions, but whilst there may be several actors on stage, there is no point in them all reading different parts of the play at the same time. .. That would be too confusing.

They all keep track and work through their script together, taking turns at reading lines, one line at a time, until they get to the end. Then they wait for applause and sod off home.

This is kind of how your PC acts when running a game (though it doesn’t often get applause, or sod off home). The PC starts running the program from the first line of its “script” (the .exe file you run), and works its way through the script line by line, one line at a time, until it gets to the end. Using a “debugger” that comes with C/C++, you can stop the game in its tracks and see the current line it is looking at. You can press a button to step through line by line, having a good nosey inside your computer’s memory and seeing what it is up to.

The major difference between a computer game and a stage-play, is that in a computer game, instead of having a single path from beginning to end, there are always many different paths the script could take. It is a bit like those Fighting Fantasy adventure novels where you get a choice of what you want to do next:

If you want to climb back up the mountain, turn to 67.
If you want to run away like a girl, turn to 232

If you understand this, then remarkably, this is the most fundamental concept to get your head around with making games. It’s simply a flow of logic… the computer asking your game questions your game had instructed it to, with different paths depending on the questions asked and the answers received. “… if this is true, do this… but if that is true, do that instead… you always want to do this bit… but then, hey! You’ve just done this, so I’m going to do that… “

Learning and understanding the syntax of the C++ code is going to be the thing that takes the most time, but the syntax is just the language used… it’s not what language in which you say something, it’s what you should say that’s the important thing to learn.

So, bearing this in mind, in the next section we’re going to design how our code is going to work, using a language we are a little more familiar with. English! Huzzah. But don’t be disheartened, as you will learn how the code works without needing to learn the code at the same time, and in the very next section, we will set about making our game a reality with C++ code!

Click here for part 2

Last edited by chris : 08-12-2006 at 02:48 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


LinkBacks (?)
LinkBack to this Thread: http://www.cgempire.com/forum/tutorials-101/terror-ascii-dungeon-c-tutorial-codephobes-part-1-a-379.html
Posted By For Type Date
Untitled document This thread Refback 10-30-2006 05:43 PM
Untitled document This thread Refback 10-29-2006 10:25 PM

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Terror in ASCII Dungeon! A C++ tutorial for codephobes - Part 3 chris Tutorials 36 09-07-2008 08:43 PM
Terror in ASCII Dungeon! A C++ tutorial for codephobes - Part 2 chris Tutorials 10 09-18-2006 10:38 PM
[TUTORIAL] Debugging: Part 1 MillsJROSS Tutorials 11 07-24-2006 01:58 AM
Games Programming for beginners: Part 9 - Number conversions (PART 2 - DEC to BIN) Nickenstien Registered Members Only 0 06-11-2006 04:45 AM
Games Programming for beginners: Part 8 - Number conversions (PART 1 - DEC to HEX) Nickenstien Registered Members Only 0 06-11-2006 04:39 AM


 
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC5
vB Ad Management by =RedTyger=
©2006 CGEmpire