Game Programming
|
On January 2, 2001, Elrac said:
About the Obfuscated C Programming Contest
|
From
The Merriam-Webster Collegiate Dictionary:
|
- Main Entry:
- ob·fus·cate
- Pronunciation:
- 'äb-f&-"skAt; äb-'f&s-"kAt, &b-
- Function:
- transitive verb
- Inflected Form(s):
- -cat·ed; -cat·ing
- Etymology:
- Late Latin obfuscatus, past participle of obfuscare,
from Latin ob- in the way + fuscus dark brown -- more at
OB-, DUSK
- Date: 1577
- 1 a : DARKEN
b : to make obscure
- 2 : CONFUSE
- ob·fus·ca·tion /"äb-(")f&s-'kA-sh&n/
noun
- ob·fus·ca·to·ry /äb-'f&s-k&-"tOr-E,
&b-, -"tor-/ adjective
|
There's an annual contest for the most illegible,
incomprehensible or otherwise most strangely mangled C coding.
I entered the source code for Astonia and... no, just kidding.
But I thought you might be amused by the weird and wonderful
things that can be done with the C language (remember, all the
entries are working C programs!), so I'll share this link with
you: http://www.ioccc.org/years.html
|
On January 6, 2001, Elrac said:
First the easy part, about compilers:
I list a handful of compilers in this topic:
www.astonia.com/ubb/Forum13/HTML/000004.html
What I referred to then as the "gnu c compiler" now
has a very Windows-specific port called "mingw32" or
just "mingw". You can read about it (definitely do
this first) and download their stuff from "www.mingw.org".
The compiler has undergone a few name changes: It used to be
called gcc, or "gnu c compiler." Then for a while it
was called "egcs" (I've forgotten what that stands
for) and now it's called gcc again, but now it stands for
"gnu compiler collection" because the same compiler
now does C, C++, Fortran, Pascal and possibly something else
I've forgotten. gcc is the standard C compiler on all Linux
systems, and is the compiler that compiles the server part of
Astonia. The "mingw" project brought this compiler
to DOS/Windows and added some auxiliary files so it can be
used to write Windows programs. This is an open source
project, kind of a program by hackers for hackers, so it comes
in various bits and pieces you have to find and download. You
have to read and understand the documentation that comes with
it, and it works best in conjunction with the tools that come
with it or alongside it (they're called binutils). I have used
this free compiler to compile a truly huge project (not my own
code) and it works well. A powerful debugger called gdb comes
with this compiler, but it's purely command-line.
A little more convenient package for beginners is the
Borland
C++ compiler 5.5, which is now available for downloading for
free. It is intended ONLY for DOS/Windows and the download is
more... in one piece. Lancelot says that the Borland compiler
sometimes causes his PC to crash, though. There used to be no
debugger with this compiler, but Borland has finally broken
down and is offering a debugger along with the compiler. The
debugger is full-screen but text-oriented so it looks kind of
DOS-like.
These two would be my first recommendations for free C++
capable compilers. I understand there is a package called
cygwin
which will allow DJGPP to produce Windows executables,
but some people consider the DJGPP/cygwin approach a bit
awkward because you have to install special runtime libraries
for it. The "min" part of Mingw stands for
"minimalist" because it's less complicated and
generates real, honest Windows-ish executables that run with
the standard MSVCRT library.
All 3 compilers are bare-bones command-line compilers. You
will need at least an editor with them, and if you're
pampered, a complete IDE. There's probably nothing wrong with
rhide
(I've never used it so I can't say), and you can
probably get it to work with all three.
In any case, there's almost no sensible reason for anyone to
spend good money on a compiler like M$ Visual C++.
|
On January 6, 2001, Elrac said:
Now for the tougher part, game and graphics programming.
When people show up here and say that they're about to start
programming a game like Astonia, I subject them to a lot of
public ridicule in the hope of discouraging them. It's not
that Astonia is afraid of competition. It's just that what
these people are saying sounds to me like, "I've taken my
tricycle apart and successfully put it together again. For my
next trick, I'm going to design and build an automobile."
Milambeer, you sound a lot more sensible. You're asking about
information and where to learn what's required. I'm happy to
share some of what I know.
As a first step, for a bit of a challenge, try to do what
Corwin is doing: Build a console-mode Tetris. Read the Tetris
thread in this forum to get started. Maybe you should
collaborate with Corwin? You will find it interesting to write
programs that accept keystrokes and respond in realtime. There
is a wealth of good games that were written with just
characters on an 80 x 25 screen.
When this gets boring, you will want to look at 2D graphics.
Windows gives you a set of functions to draw lines, curves and
shapes on part of the screen (this is called an API, or
Application Programmer Interface). Some people find the
Windows API complicated and inconvenient, so there are 2D
graphics libraries out there which make some things more
convenient. Essentially, 2D graphics is just about drawing the
right thing to the right place (x/y) on the screen. This
drawing can be either lines and shapes you draw from code, or
copying complete graphics images (like the .BMP files used for
items and characters in Astonia) to the desired place on the
screen. Astonia looks 3D but actually it just copies 2D bitmap
images to places on the screen. To make something move (it's
called animation), you just draw the screen again without the
image you want moved, then draw the image on to the screen in
a different place.
The most modern games these days use 3D graphics. 3D graphics
involve generating a model, in the program, of what you want
the user to see: Walls, floors, objects, characters, lights,
and where these things are, and how they're oriented (which
direction they're facing in). This information is known as a
scene, and the program-internal representation is a scene
graph. So you set everything up, including a camera position
and orientation (the "eyes" of your user) and then
give all this information to a 3D game engine. This is a
library of code which computes what the user will see if all
the items in the scene are where you say they are, and then
draws that scene on to the user's screen. This is called
"rendering" a scene.
Whether 2D or 3D, you can only display the graphics you have.
You can dig around the Net for graphics other people designed
and published, or get some graphics tools (MS Paintbrush as a
very modest beginning) and draw your own. If you have some
good paper drawings (your own or somebody else's), you could
consider scanning them into your computer and then touching
them up in a graphics program, rather than starting drawings
from scratch on the computer.
If you want your game to be an online, multi-user Internet
game like Astonia, then you will need to split it into a
"client" part which runs on each user's PC and a
"server" part which runs on a PC of yours with a
24/7 Internet connection. If you're just starting and have
flat-rate access, you can run the server program on your own
PC and leave it connected to the Internet day and night. If
you get a lot of players, you may have to move it to a server
directly hosted by an ISP. In either case, you'll have to
learn about communicating over the Internet, so your client
and server can stay coordinated. You'll probably be exchanging
messages between client and server either via IP or UDP.
To be decently fast and stable, your server should run Linux
rather than Windows. So you're looking at learning a bit about
programming for Linux as well as Windows.
All this is quite the adventure. Expect to take years to get
anywhere. Depending on how much spare time you have, it's
quite possible you will give up after part of the way. This is
not as terrible as it sounds: You will have gained a lot of
valuable programming experience on the way.
|
On January 6, 2001, Elrac said:
Now for some Internet references to get you started.
These references are excerpted from Game Design,
Second Edition, by Marc Saltzmann. I don't have his permission
but I'm doing free advertisement for his book, so I feel it's
OK. Most of the book quotes some of the industry's greatest
game designers on various questions related to their jobs.
There's a lot to be learned. I recommend reading this book
because, after reading about how tough it is, you will forget
about becoming a game designer and save a lot of money on
other books about making games. Still... before you read
Saltzmann, check out these references:
- Computer Role-Playing Game Designer:
- www.ultranet.com/~melkior/crpg/index.htm
- DevGames.com:
- www.devgame.com
- GamaSutra:
- www.gamasutra.com
- Game Design:
- members.aol.com/anarchyxi/gamedev.htm
- Game Design Newsgroup:
- rec.games.design
- Game Design @ Gameslice:
- www.gameslice.com/vgd/index.shtml
- Game Developer Magazine:
- www.gdmag.com
- Game Development Search Engine:
- www.game-developer.com
- Gameslice:
- www.gameslice.com
- GarageGames.com:
- www.GarageGames.com
- HappyPuppy: The Biz:
- happypuppy.com/biz/index.html
- I Have No Words and I Must Design:
- www.crossover.com/~costik/nowords.html
- Loony Games:
- www.loonygames.com
- Murphy's Rules:
- kovalic.com/Murphys/Murphys.html
- So, You Want to be a Computer Game Developer:
- www.makegames.com
- Ultimate Gaming Resource - Company Directory:
- www.ugr.net/listings/listings.htm
In addition, a few recommendations from me that I feel he
forgot to mention:
Usenet newsgroups such as:
comp.games.development.programming.algorithms
and
comp.games.development.programming.misc
If you don't have usenet access set up, you can access
newsgroups through
www.dejanews.com
Egroups: www.egroups.com
If you don't know what these are, go look. Basically public
discussion groups, they're easy to set up (so there are a lot
of useless groups) and easy to access, and everything ever
posted goes into an archive. Yahoo maintains them for free. I
entered "game programming" as a search key and got a
list of 72 groups devoted to this topic. Read their archives,
and join some of those with a lot of members in them already.
Dr. Dobb's Journal,
C/C++ programming resources contains lots of stuff about C
and C++. Just one of countless similar pages. I just happen to
be a loyal DDJ reader.
Source Forge
is a site where people get together to develop open-source
software. You may consider joining an already-existing game
project (if only to listen in) rather than starting up your
own.
Google (or any other
search engine):
http://www.google.com/search?q=c%2B%2B+tutorial
Entering "C++ tutorial" as keywords gives you an
exhaustive list.
OK, that should be enough material to keep you (and anyone
else) browsing for centuries. Enjoy, and if you have any
specific questions, please ask!
|
On January 7, 2001, Elrac said:
Milambeer, it depends on what you want to do. LCC32 is a pure
C compiler (no C++). C is easier to learn than C++, but maybe
you WANT to learn C++. A C++ compiler (and I think DJGPP is
one) can also compile C. But DJGPP probably needs (at least)
some updates to work with Windows.
Nobody writes DOS programs any more, certainly not DOS games.
The moment you write something fairly big, you start messing
with memory extenders and boot disks and... I don't even want
to think about it. Let's just say that DOS in its original
form is dead as far as you are concerned.
Windows GUI, on the other hand, is not easy to program for if
you use C and don't have a powerful toolkit like C++ Builder
or MSVC++. You need to build your GUI using a resource editor
and compiler, then you write coding to make it come alive.
It's not pretty. Ishtar hates it and I've only written a toy
program or two. I think you'll want to get some practice at C
programming before you tackle programming for a Windows GUI.
Fortunately, there is middle ground between pure DOS and
Windows GUI: This is Windows Console Mode. You write programs
pretty much as you would have for plain old DOS, but you get
to use modern compilers and you can use Windows functions.
Windows Console programs run in a black window, but have lots
of memory and are free of many of the restrictions of
"old DOS" programs. This is how Corwin is doing his
Tetris game, and this is how I recommend starting game
programming in C. You only have text characters for output,
but at least it's pretty simple.
|
On January 17, 2001, Elrac said:
Bubble: Tedkees, asked about a function that doesn't echo to
the screen. stdin is an istream, not a function, and not only
does it echo to the screen but it also requires the user to
hit ENTER to end a line. No advantage over scanf().
Tedkees: I don't have a Visual C compiler handy, but the
Borland-ish compilers I have have a header file called conio.h
containing direct-to-the-console IO stuff. There are functions
like kbhit() to test if a key was hit, and getch() to input a
character without echoing to the console. Look for
"conio.h" to see if your compiler has it, and/or
check your compiler's HELP to see if VC has similar functions
available.
If you want your program to say Hit any key to continue...
then get it to say so, using printf(). That's so simple,
there's no function for it. If you want your program to wait
for a keystroke after that, use one of the functions Lancelot
mentioned. I think getch() is one that doesn't echo.
You can also wimp out and change the message to Hit RETURN to
continue and then do a standard getchar() or whatever. A
RETURN may move your cursor down but it won't leave any marks
on the screen.
|
| Sample
Program Code
RPG Programming |
| Back to Programming
Back to Table Of Contents |