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.

2D All the way! / Map Scrolling Concept Help

Author
Message
Swampert
14
Years of Service
User Offline
Joined: 17th Dec 2008
Location: Somewhere in the Interwebs
Posted: 16th Dec 2009 02:37
Such as the map scrolling tutorial found for DBP, would it also be a good idea to create a tile map ( say a 64x64(tiles) map using 32x32 tiles ) and then use the get image command to capture the whole map, make the map a sprite, and then scroll it using set sprite texture coord? Or should I look into a much better way.
Ashingda 27
14
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 16th Dec 2009 04:31
There are much better methods. It's more efficient to use a bitmap that is about one tilesize larger than the screen. For example if you're running a 640x480 resolution and your tile size are 32x32 then you'll want your bitmap size to be 672x512 (640+32 x 480+32).

Draw what you need on the bitmap, in this case we can fit 20x15 tiles onto the screen so we make a loop that'll draw that plus 1 to both the x & y counts. Use the copy bitmap statement and copy over what is needed. When you scroll out of bounds just simply redraw the tiles with the new increments and reset your scrolling variables. I'm really not good with words, so check out the codes .




This example is just a basics of how to get this method to work, there are also more advance ways to work with this that'll keep the graphics smooth.
Swampert
14
Years of Service
User Offline
Joined: 17th Dec 2008
Location: Somewhere in the Interwebs
Posted: 16th Dec 2009 11:49
I'm starting to understand this and I like the example. As a thought, the player X and Y can only be between 0 and 640/480 while you're actually scrolling the map, not the screen correct?
Van B
Moderator
20
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 16th Dec 2009 12:53
There is one sub-option if you like. There's a plugin that allows you to paste images onto other images, like you could make a big image and paste the tiles right onto it. But what I'm thinking is that you could go old school on it, similar to what Ashingda is doing.

The main thing is that scrolling, with this method you could paste the backdrop image onto a new image with the desired offset, then paste the tiles needed after the 'scrolling'. This is how it was done with a lot of 16-bit titles, especially on the ST. The benefit with using the plugin is that you don't need to copy screens, so the backdrop could be pasted, or it could be a sprite - you really just have to offset it for scrolling, then adjust it in chunks of 32 pixels as needed. The plugin is called ImageKit, and it's usefulness holds no bounds .


Health, Ammo, and bacon and eggs!
Ashingda 27
14
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 16th Dec 2009 17:07
Quote: "you're actually scrolling the map, not the screen correct"
It's a little mix of scrolling the screen and scrolling the map. The screen only scrolls from 0 to 32 once it reaches 32 it starts over at 0 but the Map scrolling gets updated.

ScreenX and ScreenY ranges from 0 to 32 and it's used to offset the copy bitmap, once the ScrollX/Y reaches it's limits it will increase or decrease the ViewX,ViewY variables.

ViewX and ViewY has no range limit and it's used as index pointers for the Terrain(). To prevent an out of bounds error, we make a check and only perform Terrain() array if it's within 0-64,0-64.
Swampert
14
Years of Service
User Offline
Joined: 17th Dec 2008
Location: Somewhere in the Interwebs
Posted: 16th Dec 2009 18:47
Ok. I think I'm getting it. I'll keep looking at examples and tutorials as well. Thanks you guys!

Login to post a reply

Server time is: 2023-01-29 06:24:59
Your offset time is: 2023-01-29 06:24:59