How do I make a side scrolling game?

2000-10-19

Hi! I was at your website today and was reading the question and answer section and wanted to know if you could help me because I really need help!!! I'm planning on making a game. A simple side scrolling game. I know c++ and I know what to do to code the game: Classes, functions, pointers (well I'm kinda new at pointers), etc. So I'm ready to start making my game. BUT!! I have NO CLUE how to program the graphics! Please I need help! I've been to many internet sites and have read a lot of source code but still I don't understand how to make graphics and how to animate them on the screen. An example of the game I would like to make is Commander Keen. I was planning on making a simple side scrolling game and build on it and make it more detailed slowly after time.

Please if you could help, it would be extremely appreciated!

Thanks, Paul M.

Have you checked out www.makegames.com. I think that is pretty much exactly what they do or maybe they just do a scroller.

Usually you make the a commander keen level out of "tiles". You need a map editor to do this. If you don't mind using a dos program (should run under windows I think) you can use tUME. http://members.aol.com/opentume/

Basically it's the same as if you were to use text to make the game with '=' being the ground and "|" being a wall and * being a coin (think mario). Except instead you have a graphic that looks like ground, usually 16x16 pixels or 32x32 pixels and you only draw it on tile size pixel boundaries (relative to the entire level, not the screen) Then you apply a meaning to each "tile" For example since you know '=' is the ground to can check if the player's character touches that tile and if so make him walk on the ground. Usually I do this through a look up table. That way for each type of graphic it's assign a type. Then you can easily add graphics

example

type 0 sky
type 1 ground
type 2 wall
type 3 diggable ground
type 4 water

etc.

tile 0 ' ' type 0
tile 1 '=' type 1
tile 2 'w' type 4
tile 3 '%' type 3
tile 4 '#' type 1
tile 5 'X' type 1
tile 6 'M' type 1

as you can see there are several "graphics" or images that correspond to type 1 (ground) so that your program is really only concerned with the type of each tile (is it ground, is it sky, was I in the sky and now I'm in the water, etc...)

to draw the background you'd do something like this

#define SCREEN_WIDTH 640
#define SCEEEN_HEIGHT 480
#define TILE_WIDTH 32
#define TILE_HEIGHT 32
#define TILES_ACROSS_SCREEN ((SCREEN_WIDTH + TILE_WIDTH - 1) / TILE_WIDTH)
#define TILES_DOWN_SCREEN ((SCREEN_HEIGHT + TILE_HEIGHT - 1) / TILE_HEIGHT)

#define TILES_ACROSS_MAP 1000
#define TILES_DOWN_MAP 1000

uint16 map[TILES_DOWN_MAP][TILES_ACROSS_MAP];

int worldxpos; // in pixels
int worldypos; // in pixels

DrawMap ()
{
 int toplefttileX = worldxpos / TILE_WIDTH;
 int toplefttileY = worldypos / TILE_HEIGHT;

 int offsetX = worldxpos % TILE_WIDTH;
 int offsetY = worldypos % TILE_HEIGHT;

 uint16* pTile = &map[toplefttileY][toplefttileX];

 for (ty = 0; ty < TILES_DOWN_SCREEN + 1; ty++)
 {
 for (tx = 0; tx < TILES_ACROSS_SCREEN + 1; tx+)
 {
 DrawImage (
 images[*pTile],
 tx * TILE_WIDTH - offsetX,
 ty * TILE_HEIGHT - offsetY);
 pTile++;
 }
 pTile += TILES_ACROSS_MAP - (TILES_ACROSS_SCREEN + 1);
 }
}

got it?

-gregg

Comments
I'm an animator and I want to program
How do I start making a Playstation game?