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 / Sprite - Background etc 2D Game Srolling

Author
Message
Bozzy
18
Years of Service
User Offline
Joined: 10th Sep 2006
Location: Birmingham, UK
Posted: 15th Jan 2007 23:00 Edited at: 15th Jan 2007 23:00
Hi, I basically dont get any of the tutorials at all waa waa... and I kinda need this scrolling sorted for this 2D thing I'm working on

As in when I press up the whole map, like placed sprites, background etc scrolls up together

Can you help me?

Thanks,
Bozzy
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 16th Jan 2007 01:39
What does your code look like so far? And what kind of game are you wanting to make? Side scrolling like Mario or overhead like Zelda?

Usually we make a map drawing function and its called anytime the map moves. In the function is where the background and any sprites are placed on the screen so when the map moves every sprite moves accordingly.
Bozzy
18
Years of Service
User Offline
Joined: 10th Sep 2006
Location: Birmingham, UK
Posted: 16th Jan 2007 08:16
I'm trying to make a Zelda overhead type game, but I havent got any main code yet due to the fact I wanted to learn how to do this before starting on it.

Thanks,
Bozzy
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 16th Jan 2007 10:25
Since you haven't started yet I'll tell you the concept... I just hope I don't insult your intelligence.

You make a map array to store all the data. It has to be at least a 2D array (one for the x and one for the y coordinates of the map).

You load up all the tiles from a single image. Making 100 little images is not only annoying but a nightmare to work with... it's easier to edit a single image storing all the tiles.

You grab all the tiles as single images. The image numbers used is what is stored in the map array. You use those image numbers to build the map in the array and use the array to determine if the player can move in the direction he/she wants to go.

The map making function needs to be called with the current x and y coordinates of the upper left corner of the map so it can start pasting tiles starting from those coordinates from the map array. That is how you move the map... change the coordinates it starts at and it'll appear to scroll. The array is used to paste each image number across and down the playing area. If you want your characters/creatures to appear behind objects you need to paste each creature after pasting the tile so that when the next row of tiles is pasted any tiles that hide or partially hide them will look right. The characters/creatures themselves can be stored in the map array with 3 numbers instead of just enough space for the x and y... the z coordinate can store bad guys, good guys, items, teleporters, whatever you want or use separate arrays.

You can make the map move constantly or just show one area of the map till the player moves off the screen.

That's all I can think of right now.

Login to post a reply

Server time is: 2024-11-26 03:35:30
Your offset time is: 2024-11-26 03:35:30