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.

Dark GDK / How do I set up 2D platforms?

Author
Message
spine
16
Years of Service
User Offline
Joined: 24th Aug 2008
Location:
Posted: 11th Jun 2009 06:58 Edited at: 11th Jun 2009 07:03
I want to set up some platforms that are off-screen. My plan is to simply create integers that are outside the boundaries of the window. Also, how would I handle the sidescrolling?

Also, how would I make characters stand on top of a platform?
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 11th Jun 2009 07:03
What would be the purpose of displaying text outside the window boundries? I'm not too sure thats even possible.

As for sidescrolling, I thought about it for a second and you could move the background image and whatever images you have on the screen that represent your world/playfield when the player got too close to either edge of the screen, that method would probably work although there may be more effective ways.

spine
16
Years of Service
User Offline
Joined: 24th Aug 2008
Location:
Posted: 11th Jun 2009 07:19
Ermm... Text? I was talking about placing the platforms. When I thought of that, I remembered how if one left certain parts of code out, [insert object here] would fly outside the bounds of the window (and maybe come back?) I wonder if I can use that.

As for the sidescrolling, I think I remember reading something like that before. So you're saying that at a certain area on the window, my character would stop moving and everything else moves instead? It sounds like it's worth a shot. Thanks!
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 11th Jun 2009 07:29
yeah thats what im saying, as for the text, this is what you said:
Quote: "My plan is to simply create integers that are outside the boundaries of the window."


Does that not coincide with:
Quote: "What would be the purpose of displaying text outside the window boundries?"


Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 11th Jun 2009 07:41 Edited at: 12th Jun 2009 23:06
I think he's saying that there would be tiles whose positional values would be outside the view port.

Since I've never done this I won't go into too much detail but, if it were me.....

Assuming side scrolling only for now, number the tiles 0 through whatever for their horizontal order number (we'll call it variable "ordnum") and assign the appropriate images to the sprites for those position.s Assume for now the tile width is 32 pixels. If the leftmost tile is supposed to be up against the left side, the x position of any of the tiles will be the horizontal order number of the tile * the width of the tiles.

Tile 0 has its x-position at 0 * 32 = 0
Tile 1 has its x-position at 1 * 32 = 32
Tile 2 has its x-position at 2 * 32 = 64

etc.

Now you want to shift the background three pixels to the left. You'll need to set the x offset of all the sprites to 3. Scroll it three more pixels to the left and the x offset needs to be 6. Keep scrolling and eventually you find yourself in a position where Tile 1 is now aligned against the left side or further on. In theory, though I haven't tried this, you could continue to manipulate the background by offsetting the x position of all the involved sprites by the column of the pixel that needs to be in the leftmost column. So if column 153 of your background needs to be up against the left, set the x-offset of all tile sprites to 153.

You'd probably want to detect which tiles are supposed to be on screen and hide the sprites of the ones that aren't currently visible and show the ones that are. This cuts down on unnecessary CPU usage.

There are other ways to do this but this is the most direct.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
spine
16
Years of Service
User Offline
Joined: 24th Aug 2008
Location:
Posted: 11th Jun 2009 07:43
I guess so... I was just talking about the placement values. I'll try to clear that up next time.

Login to post a reply

Server time is: 2024-10-01 03:33:31
Your offset time is: 2024-10-01 03:33:31