Author Topic: wrap-around map  (Read 4130 times)

MadMath

  • Regular
  • **
  • Posts: 20
    • View Profile
    • eMidrash.net
wrap-around map
« on: 2008-01-25, 12:55:39 PM »
Is there a way to create a wrap around map? I know that virtual size will do something close to what I want, but there are a few differences. I want it to wrap around infinitely and I want it to include sprites in the wrap around.

Another way to explain it: I want the map to act like a circle, so that if you keep on going in one direction you will eventually end up where you started.

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: wrap-around map
« Reply #1 on: 2008-01-25, 01:32:50 PM »
how interesting, that's exactly what i pondered once. i'm curious to hear if it's possible.

Richard Kain

  • Regular
  • **
  • Posts: 23
    • View Profile
Re: wrap-around map
« Reply #2 on: 2008-01-25, 01:55:01 PM »
Oh, yes, this is actually quite easy. All you have to do is program the engine so that a new instance of the map is created and placed at the far end of the existing map. That way, as the player advances through the level, the offscreen instance of the map will be deleted, while the upcoming instance is appended. At any given time, there would be three instance of the map. In that way, the level could scroll indefinitely in either direction. Of course, it would almost certainly require some additional programming. (ie, I don't think you could do this just with the visual rule editor, but maybe I'm wrong)

MadMath

  • Regular
  • **
  • Posts: 20
    • View Profile
    • eMidrash.net
Re: wrap-around map
« Reply #3 on: 2008-01-25, 02:33:51 PM »
I am not a very good programmer. Can anyone tell me how I could go about programming this?
Also, I have a few questions about this approach. How would it handle the sprites?

1)If an enemy sprite fell down a hole would it appear from the ceiling (I am thinking about using this as a veritcal wrap-around)?
2)Would the sprites on one instance always be in the same place as they are on the other instances?
3)If I got hit by an enemy, would it process the rule that handles that three times (once for each instance)?

What I am worried about here is how this approach will acheive acheive the examples in the first two questions while avoiding the problem in my third question.

Richard Kain

  • Regular
  • **
  • Posts: 23
    • View Profile
Re: wrap-around map
« Reply #4 on: 2008-01-25, 03:02:54 PM »
Well, and this is the difficult part, you would ideally have your player sprite separate from the vertically scrolling layer of the map. I'm not exactly sure whether or not this can work in SGDK2, as I haven't gotten to that part yet in my own projects. If the player sprite were on a separate layer, you wouldn't have to worry about enemy collisions being processesd multiple times, as there would only be one instance of the player. It's not often that you see a game pull off the kind of effect you're describing. I do remember one NES title called "MetalStorm" that did exactly that, though, so it certainly should be possible.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: wrap-around map
« Reply #5 on: 2008-01-26, 07:43:17 PM »
Actually there was a game for version 1 called Ethereal Peace that had a wrap-around map.  It accomplished this by simply having an area at the end of the map that wasn't too complicated and would teleport the player to the beginning.  The tiles were all identical to the beginning of the map and the player would get teleported from the end to the beginning while walking through that area without noticing (because the beginning so perfectly matched the end).  Of course it's easier to make the beginning and end match in SGDK2 by making the virtual size slightly larger than the actual size; it will automatically show the beginning of the map at the end.  The only trick is that you have to make sure that part of the map is simple (no sprites) or it will be difficult to teleport/copy all the sprites too.

Of course to wrap in both directions, you also need to be able to teleport from the beginning to the end going in the other direction.

Edit: In case you haven't thought of it, it should be pretty easy to make any sprite wrap (not just the player, if that's your concern).  You can make them wrap vertically when falling down a hole, like you mentioned.  You can use the TransportToPlan function (available when defining plan rules) when the sprite enters an area near the end of the map.  Just make sure that if you wrap both directions, the target of the teleportation is not overlapping the plan that will teleport you back, otherwise you will get stuck infinitely teleporting back and forth.
« Last Edit: 2008-01-26, 07:49:54 PM by bluemonkmn »

MadMath

  • Regular
  • **
  • Posts: 20
    • View Profile
    • eMidrash.net
Re: wrap-around map
« Reply #6 on: 2008-01-28, 01:41:23 PM »
Well, unfortunately I have chosen the most complicated place to use this. I have an idea of how to make this simpler, but it involves modifying the source code (and I am not very good at programming). Anyway, first I will explain my problem then I will give my idea.

In my game there are tiles which change solidity whenever the player presses a certain key. The level I want to wrap around vertically will be composed entirely of those tiles (Basically at any point in the game, the player can send himself and all the other sprites into freefall by making the ground unsolid). By making the map wrap-around vertically, the player can stop himself at any time by making the ground solid again. So, eliminating the sprites isn't an option, and there is a very wide area to cover.

I played around with the view layout code just a little bit and found that I could change the size of the views. I assume that I could also change what the view was of. Couldn't a function be created to display a view from one plan within the rectangle of another plan (did I explain that well enough)? Then a plan could be placed under the bottom of the map to display the top of the map and vice versa.
Of course, such a function could also be used for several other interesting effects.


bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: wrap-around map
« Reply #7 on: 2008-01-28, 04:39:25 PM »
Isn't it good enough to just make the player sprite and all other sprites wrap?  If not, I doubt it will be good enough to just display the beginning of the map next to the end of the map, because you'll still have problems with clipping and/or collision detection.  What if half of the player sprite of off the bottom of the map, and is overlapping an enemy sprite that's at the top.  Collision detection will not see that these sprites are touching.  So if that's the case, it should probably just make the sprites jump to the top when they go off the bottom since collision detection is only going to pick that up like that anyway.

MadMath

  • Regular
  • **
  • Posts: 20
    • View Profile
    • eMidrash.net
Re: wrap-around map
« Reply #8 on: 2008-01-28, 05:08:27 PM »
That would be a problem. Oh well, I guess I will just have to settle for the simple approach.