scroll-wrap feature or workaround...

harrioharrio Member Posts: 234
edited November -1 in Working with GS (Mac)
hello gs,

i plan to try a 'defender' clone of sorts. it will be similar to your shooter example except that not only should it scroll, it should also seamlessly wrap the level or scene horizontally, or vertically i suppose, depending on the game type, as one 'world'.
i looked at your asteroid example and i can see how that might work. but, if the scene is larger than the camera and you scroll to one 'side' will the scene flash back to the other end/side of the scene.
i guess i'm asking if there is a way of implementing the 'defender effect' or is there some workaround/hack that you can suggest?

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Hi harrio,

    you would just need some longer scene backgrounds and when each scene portion goes all the way off the screen(its position is negative half its width) then you can have a rule that checks this and the direction you are moving to do a Change Attribute on the X position to move it to the other end of screen at an exact point so it would look endless.

    With the way wrapping works the whole image needs to leave the scene area before it will start to appear on the other end. So the method above should work. We are still working on perfecting that.

    Hope that helps.
  • harrioharrio Member Posts: 234
    hello cm,

    thanks for the response. i don't have my mac laptop yet, so i'm mapping out rules, actions and attributes with good 'ole pen and paper right now. is there any way you can visualize your 'method'. i'm not quite understanding it. my fault i'm sure. i put a mock up of what i'm trying to get here...

    http://docs.google.com/Doc?id=dcrvmt6h_11fcddsrdp
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    In your doc, would it seem as the ship is moving right but the buildings are moving faster to the right?

    Or did you want to "move right" and the buildings move left.
  • harrioharrio Member Posts: 234
    i wanted the buildings to always be moving in the opposite direction of the ship. so in my doc i have the ship facing right and the buildings are moving/scrolling/wrapping left.
  • harrioharrio Member Posts: 234
    bump...?
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Hi harrio,
    We've been busy working on a game that has something close to what you are looking for. The good news is that we have it nearly completely looking seemless. The bad news is it is in a build that is not yet on the site for release.

    So the way we have it is we have 2 instances of the same actor prototype. That prototype has the image that scrolls. In your case, all of those buildings.

    In the case below, the width of the actor is the width of the screen. i.e. 480
    Have one rule that moves the actor right when the left button is pushed.
    Have another rule that moves the actor left when the right button is pushed.
    To have seemless scrolling, align the 2 instances next to each other and have these 2 rules:
    Rule 1: When the X position is less than negative half its width AND right button is down
    -> change attribute : The X position is set to its X position plus the width of the actor plus the width of the scene.

    Rule 2: When the X position is greater than half its width plus the scene width AND left button is down
    -> change attribute : The X position is set to its X position minus the width of the actor minus the width of the scene.
  • harrioharrio Member Posts: 234
    thanks cm,

    this sounds really juicy. i'm going to have to wrap my head around this setup.

    don't worry, i won't ask the cliche question of when the next build will be out. i'll leave that to the others.

    i'm going crazy waiting for my mbp to arrive!
  • shwinstershwinster Member Posts: 23
    I'm not sure if you've said this already but how do you make a background loop so that after it goes through one background it loops back to start.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Hi shwinster,
    The method above does that.

    You would need 2 instances of the actor with the background, and place them next to each other.

    So say I had an image that looks like it never ends when you connect the sides of it.
    I make an actor that is the width of scene with that image. i.e. 480.
    I create 2 instances of that actor so that they are right next to each other.

    When it is all the way off the screen(i.e. its centerpoint is offset from the edge of the scene by half the width(or height) of the actor, then change the attribute value of the X position to the other side of the screen.
  • shwinstershwinster Member Posts: 23
    Thank you, Now I can complete my game.
  • harrioharrio Member Posts: 234
    thanks a ton cm,

    i had to read your explanation about 20 times and then i still had to do 'picture mode' so that i could figure it out. i hope this mock up makes it easier to understand for others. or maybe i'm the only dummy who didn't get it...lol

    http://docs.google.com/Doc?id=dcrvmt6h_12fbrhgkcv
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Thanks harrio,
    If it is okay with you, may I use that image as part of the How-Tos in the wiki?
    Or if you want, you can add it to the wiki yourself and provide descriptions.

    http://gamesalad.com/wiki/how_tos
  • harrioharrio Member Posts: 234
    hey cm,

    sure you can use it! i'd be honored/geek'd.

    even though i'm only working on pen and paper right now, still waiting for my macbook pro to arrive, i plan on making a screencast/tutorial with http://www.screentoaster.com
    i think this would be great for others who want to contribute to the wiki too.
  • edhedh Member Posts: 23
    Was there ever a tutorial done for this? I can't seem to find anything in the Wiki.

    Thanks!
    -Ed
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    I think I understand the theory of positioning 2 instances of the background next to each other but what specific rules are used to swap them so I can have an infinite background?
    Reading the above posts from 9 months back shows it can be done but the biggest issue with these rules is knowing how to use them without seeing examples.
    Any help is most welcomed - thanks!
  • PhoticsPhotics Member Posts: 4,172
    I didn't see a tutorial for this in the Wiki either.

    I'm in the process of determining how large my background should be. It seems that one wrapping 512x512 image would be more efficient than a 1000x8000 image.
  • reddotincreddotinc Member Posts: 653
    Anyone manage to get this to work? I'm moving my background at 200-300 and it's causing the images to lag slightly behind each other causing a black gap "/

    // Red Dot Inc
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Try making your background image size a power of two - 128x128, 512x512, 1024x1024.

    That SHOULD fix it...
  • reddotincreddotinc Member Posts: 653
    Thanks FMG, I did test it out in the few minutes I had before leaving for work so had to rush but think its' nearly there. It wasn't PERFECT, but did seem better than before.

    I was using a 1024x1024 image for iPhone 4 so 512x512, any issues with that you think?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Not that I know of, but I don't have an iPhone4 to test with yet...
  • reddotincreddotinc Member Posts: 653
    Thanks, I'll test later and report back. All this would be so easy with wrap-able layers :(
  • reddotincreddotinc Member Posts: 653
    I'm going to go insane with this :(.. nothing I do can make it loop correctly.. the 2nd image always lags behind a little bit.. any ideas?
  • QbAnYtOQbAnYtO Member Posts: 523
    Try overlapping them. Maye it will "gap into place" if that makes any sense
Sign In or Register to comment.