🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How do you create a side scrolling game?

Started by
14 comments, last by C++ Freak 24 years, 5 months ago
I can display bitmaps and stuff like that but how do you show just one part of a bitmap and when the character on-screen moves show a different part of the bitmap. C++ Rocks
Visit http://members.xoom.com/ivanickgames
Advertisement
You replace the whole bitmap with another, just like cell animation. for example a character punching would just be a series of pics of the character each with the arm in a different position.

Hope that helps,
Nomad
There''s gotta be some other way to do it. I don''t want to draw 100 bitmaps just for the background. Is there some way you can just display part of a really big bitmap?




C++ Rocks
Visit http://members.xoom.com/ivanickgames
Yes. And you do that by having "cells" in a bitmap. For example. You have a 640x480 bitmap. Taking a simple example, lets say each of your character "cells" are 64x48 pixels. That means you have 10x10 or 100 cells in just one bitmap. You can then load the entire bitmap onto a surface, create a rectangle around any of the cells, copy and blit. Move the rectangle, copy, paste,etc.. this will result in animation. (Yes, an overly simplified version)
Nomad was correct, but his choice of words "...replace the whole bitmap with another..." was a poor description. Rather, replace a portion of the onscreen surface with a portion(rect.) of your character animation bitmap.

So yes, you will be drawing ''100'' cells in one bitmap.

Six

Edited by - Sixpack on 1/2/00 11:01:29 AM
I think that C++ Freak may be under the impression that you are loading the intire background of a level into a huge surface and then blt''n parts of it onto the screen. Really what you want to do is draw a bunch of background pieces. like one for sky, one for ground, one for trees, and so on, all the same size, and then do what Sixpak said to draw the world. Take a good look at mario, and you will see that the worlds are made of very few different "pieces" but they are just combined to make it look nice.

I started writing some pseudo-code for ya, but it got too long and complicated, so I suggest that you look up a web site about "side scrolling" they should tell you what you need to know.

Pseudo
Also, instead of changing the rectangle for new frames of animation, it''s better (faster, but it takes more memory) if you have an array of rectangles, one for each frame.
If you want a really simple but cool demo, you might want to check out the DDraw tutorial in the book "Teach Yourself DirectX7 in 24 Hours". It has a very cool scrolling city scene that even uses paralax scrolling.
If anything, it''ll give you a place to start.
I think what he might want is to simply load a huge bitmap (whatever size)into memory and only show part of it. I know baulders gate and some other games are doing that now.(I mean you can get a fully prerendered landscape shaded ect,and multiple layers,ect better than you can with tiles. But if you want multiple levels......)
Anyways what i think you want to look into is directdraw clippers,you just blit the bitmap to the dbuffer then flip it to the screen.What you do to move the bitmap is well like this.

RECT source_rect;
source_rect.left = xtoblitfrom;source_rect.top = ytoblitfrom;
source_rect.right = x+sizeofview;source_rect.bottom = y+sizeofview;

That should let you draw a say 1200x1200bitmap to a 640x480 screen and when you want to scroll right you just increase the x value.
Well what i did is create a logic system for it here''s the source(this is source for an RTS so that you can scroll around the map but the concept is basically the same)
BOB is the bitmap animation object thingy.void
Int_Game_Logic()
{
// Test if Onscreen
BOB_PTR bob;//bob pointer thingy
if((bob->Ax > VX1) && (bob->Ax < VX2) && (bob->Ay > VY1) && (bob->Ay < VY2))//bounds check
ONSCREEN = 1;//onscreen
else
ONSCREEN = 0;//not on screen
// new coordinate system
if(ONSCREEN = 1)//visible
{
Real_x = (bob->Ax) - VX1;
Real_y = (bob->Ay) - VY1;
}
else if(ONSCREEN = 0)//not visible
{
Real_x = 0;
Real_y = 0;
}
}
Thanks for the help
Visit http://members.xoom.com/ivanickgames

This topic is closed to new replies.

Advertisement