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.

Author
Message
Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 1st Nov 2010 16:51
I am starting to design an 2D rpg or mmorpg. I want the world to be big and i dont know how to screen-scroll, so i am going to make it to where when you hit the edge of the screen, you move to another room (screen) and showing up on the other screen depending on the last x and y value the sprite has touch the edge of the screen. How would i make rooms and make the-edge-of-the-screen collision to go the the next room (screen)?

onhcet d(-_-)b techno
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Nov 2010 18:32
I would just track the sprite position and when it =screen width() or zero or screen height() then you know you are at the edge of the screen.

Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 1st Nov 2010 20:58
but how would i make it to where he wont go off the screen. I feel like i know how to code it but i just cant figure it out


onhcet d(-_-)b techno
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Nov 2010 21:11
Say your sprite was 64x64 pixels:


Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 1st Nov 2010 21:36
omg! ive been looking for this code forever!! thank you so much!

onhcet d(-_-)b techno
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Nov 2010 21:49
Quote: "when you hit the edge of the screen, you move to another room (screen) and showing up on the other screen depending on the last x and y value the sprite has touch the edge of the screen"


So like the old Zelda game on Nintendo?


In my zelda clone, I use to arrays to accomplish this task. The first holds the information of the map you're currently interacting with. When you reach the edge of the map (in any direction) you load up the information of the second screen into the second array. Display that 2nd portion of the map and offset it to be right next to the current map. As the first map slides over, the 2nd map slides with it.
Once it has completely shifted, I load the first array with the data from the 2nd and update the collision map. Basically, the 2nd map is only used when shifting between screens as the 1st map is always used to draw the screen.


"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Nov 2010 23:03 Edited at: 1st Nov 2010 23:04
Quote: "omg! ive been looking for this code forever!! thank you so much!"

Any time!

@Phaelax, I was thinking Zelda too!

Login to post a reply

Server time is: 2026-07-22 04:37:15
Your offset time is: 2026-07-22 04:37:15