Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / help! 2D games - Screens, scrolling & sprite positions..

Author
Message
RedRain
21
Years of Service
User Offline
Joined: 11th Jun 2003
Location:
Posted: 11th Jun 2003 13:38
Ok, I can create sprites and animate them no problems, and I can get a bitmap background to the screen no problem. I can scroll a background round and round, using copy bitmap, but I'm having a lot of trouble getting my head around how to create an entire level of a 2D scrolling game, like say Double Dragon. So far I've been going about achieving this by thinking that each 'screen' will be a bitmap, and as the user moves along to a point where the screen needs to scroll, I copy sections of 2 bitmaps to the screen in a loop like this:

(Both bitmaps are 800x600 backdrops)

ScrollAmt = 1

COPY BITMAP 1, ScrollAmt, 0, 800-ScrollAmt, 600 - TO SAME POSITION
ON THE SCREEN
COPY BITMAP 2, 0, 0, ScrollAmt,600 - TO SAME POSITION ON THE SCREEN

So essentially the screen becomes an amalgamation of 2 bitmaps and gives the illusion of a 'complete' backdrop scrolling along behind.

At the moment I have 5 backdrop screens which all need to scroll seemlessly into eachother as the character moves. But I'm really not sure this is the best way to do it. Should I use Bitmaps, Images ot Sprites for this work?

For starters, I want my character to be allowed to move back and forth along the entire level, and as you're only allowed 31 bitmaps it means that any level is not gonna be that big. Secondly, I need some AI in the game where cpu contolled characters do their own thing at any position along the whole level. So they will randomly receive instructions to go hang out at a particular place along the level, which may or may not be in view of the human character. How will I achieve that their positioning when they are doing something that is not on screen? Should I give the cpu controlled sprites a pseudo screen position in relation to the amount the screen has to scroll before they come into view or something?

Is there some way I can amalgamate all of the background graphics into as single long backdrop rather than doing all the cutting and pasting of stuff? I've tried to create a bitmap and copy all my bitmaps onto it. (e.g in the case of my 5 backdrops, I create a bitmap of 4800x600) but DB just crashes!

Any help on any of these problems would be hugely appreciated!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 11th Jun 2003 14:02
I think that I would use images - bitmaps take up valuable video memory, while images are stored in system memory. Using sprites would complicate matters - you'd need to get the zorder right, otherwise your enemy/player sprites could appear behind your backdrop.

There's a piece of code that I posted yesterday for Nilrem about a tiling system. You could adapt that to draw your backdrop.

*If* you use that code, then that could simplify the second part of your question, because it works on negative offsets of the tiles (ie to scroll right, you decrease the x coordinate of the tiles).

Subtracting that from your player/enemy sprite positions would position them on-screen (assuming you were storing their coordinates in an array).

ie, If your sprite was positioned at x=2000, but your level has been scrolled along by -1800 then the actual screen position of the sprite would be at x=200.

Oh, and finally, don't try and combine the levels into one big bitmap - the problem you had is caused by your video card and drivers. A lot of cards/drivers cannot handle bitmaps of that size, so even if it worked for you, it may not work for anyone else.
RedRain
21
Years of Service
User Offline
Joined: 11th Jun 2003
Location:
Posted: 11th Jun 2003 14:45
Cheers for the response! Whereabouts is the code example you posted on the tiling system? Is it in this forum somewhere? Sounds like that would sort out my problems a treat!

RedRain
21
Years of Service
User Offline
Joined: 11th Jun 2003
Location:
Posted: 11th Jun 2003 14:48
It's ok I found it! (In the 2d forum for anyone else who's interested).
thanks a lot!

Login to post a reply

Server time is: 2024-11-24 16:44:09
Your offset time is: 2024-11-24 16:44:09