Spawn platforms evenly

Hello everyone, I am having trouble making my spawning platforms look evenly as they appear in the right side of the screen and move to the left. I don't want spaces to appear and I really need to keep the platforms to appear one next to the other because I will make a platform pattern image that will make it look as if it's a continuous platform.

I made a video to better explain my issues:

Hope you can help me out!

Answers

  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    The distance the platform pieces must travel increases with time - but their speed and their size remain constant.

    If you run your project for a couple of minutes** you should see the space between the platforms increase.

    ** change 'game.Gamespeed -2' to 'game.Gamespeed -20' so you can see what is happening a little quicker.


    . . . . . . . . .


    But putting that issue aside for a moment, how have you calculated the width of each platform piece in relation to the rate at which they are spawned ? 1 second for the spawn rate seems like an arbitrary figure, the spawn rate needs to be related to the platform width and speed.
  • davidsalomondavidsalomon Member Posts: 136
    edited December 2012
    @Socks do you have any advices on how can I calculate the spawn rate with the width and speed?

    By the way, it really would be easier to use the Move behaviour but I can't manage to make a condition that if a platform is gone from the screen, how to spawn it again in the right side of the screen. I think once I saw a video of Tshirtbooth on how to re-appear a cloud in the background, I'll check that out.

    Edit: couldn't make it work like the clouds as Tshirtbooth did :/
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    @Socks do you have any advices on how can I calculate the spawn rate with the width and speed?
    With how you have it set up it will be difficult, at the moment you have the actors travelling 810 pixels in 5 seconds, so that's 162pps (pixels per second) - but after 1 second it's 812 pixels, then 814, 816, 818, 820 . . . and so on, so to compensate for the increasing distance each platform needs to travel it will need to either lengthen the time it takes to get there (which negates the goal of the game getting faster) or each platform will need to stretch out to fill the gap that will slowly grow between adjacent actors.

    So . . . not an ideal system.

    How to calculate speed in this context: scene width / desired time = 'speed' . . . .

    So, if you want an actor to travel 568 pixels in 5 seconds it should be travelling at a speed of 113.6.

    So if you were to use move you would make the speed 113.6.

    If you were to use spawn every second then each platform would need to be 113.6 pixels wide.

    If you want each platform to be a quarter of the width of the screen (you have 4 platform in your example) - then each will need to be 142 pixels wide, so the duration of your interpolation would need to be 4 (568 / 4 = 142) rather than the 5 you currently have.
    By the way, it really would be easier to use the Move behaviour but I can't manage to make a condition that if a platform is gone from the screen, how to spawn it again in the right side of the screen.
    When x position = XXX then destroy actor and spawn a new one righthand side of the screen.
    Or . . .
    When x position = XXX the change x position to the righthand side of the screen.
  • davidsalomondavidsalomon Member Posts: 136
    Socks, thank you for all your help.

    So the best solution is with the interpolate (with everything you told me) rather than any other solution?
  • SocksSocks London, UK.Member Posts: 12,822
    So the best solution is with the interpolate // (?)
    Probably not !

    The ideal way would be to move the camera to the right rather than move the scene to the left.

    That way you are only worried about moving your actor to the right - rather than worrying about moving your whole game to the left.

    But I am not expert on scrolling platform games, never made one, there are lots of people here who could probably offer you lots of good ideas . . . . .
  • davidsalomondavidsalomon Member Posts: 136
    Thank you very much Socks, I'm still going to see what can I get with what you told me before. ;)
    Hope that someone with scrolling platform games helps me out too!
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    Thank you very much Socks, I'm still going to see what can I get with what you told me before. ;)
    Hope that someone with scrolling platform games helps me out too!
    When using interpolate / move / constrain (etc) in this kind of scenario expect annoying little gaps (1 pixel or so) to appear between your actors, you can usually get rid of these by making the platform pieces a little wider than the maths says they need to be.

    Moving the camera does not introduce these little gaps.
  • davidsalomondavidsalomon Member Posts: 136
    edited December 2012
    Thank you very much Socks, I'm still going to see what can I get with what you told me before. ;)
    Hope that someone with scrolling platform games helps me out too!
    When using interpolate / move / constrain (etc) in this kind of scenario expect annoying little gaps (1 pixel or so) to appear between your actors, you can usually get rid of these by making the platform pieces a little wider than the maths says they need to be.

    Moving the camera does not introduce these little gaps.
    That's the problem I am encountering right now, there are 1 or 2 px gaps between the incoming actors.
  • davidsalomondavidsalomon Member Posts: 136
    edited December 2012
    I got the solution I need!
    The answer is not in the platforms, is in the enemy spawns!
    I want to spawn enemies and obstacles, I'll just give an effect/scrolling images to the platforms and make it as if my hero is moving forward!
    And the enemies will just appear faster and move faster too.
  • SocksSocks London, UK.Member Posts: 12,822
    And the enemies will just appear faster and move faster too.
    . . . and the scrolling images animation on the platforms will need to be animated faster.

    This really is the most difficult way I can imagine achieving side scrolling action !
  • davidsalomondavidsalomon Member Posts: 136
    And the enemies will just appear faster and move faster too.
    . . . and the scrolling images animation on the platforms will need to be animated faster.

    This really is the most difficult way I can imagine achieving side scrolling action !
    Yeah, I didn't notice until now that the animation's fps is a scrollable bar and not a number that can be modified easily :/

  • beefy_clyrobeefy_clyro Member Posts: 5,394
    And the enemies will just appear faster and move faster too.
    . . . and the scrolling images animation on the platforms will need to be animated faster.

    This really is the most difficult way I can imagine achieving side scrolling action !
    Yeah, I didn't notice until now that the animation's fps is a scrollable bar and not a number that can be modified easily :/

    You can still adjust that easily ...

    If score < 100
    animate 12 fps

    If score is >99
    and
    <200
    animate 20 fps

    etc etc

    But generally theres 2 ways people would use to make a runner ... player moves with camera or player stays and the scenes moves in from the left just looping
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    You can still adjust that easily ...

    If score < 100
    animate 12 fps . . . .
    Unfortunately you cannot access the animate frame rate.

    If you could, you would need to increment the frame rate in small (but accurate) fractions to keep sync with the increasingly speedy enemies, but not only can the animate frame rate not be accessed, but even if it could it only increments in whole numbers - and even if you could access these whole number values they are inaccurate to the point of being largely ornamental.

    eg:

    30 fps on the animate fps slider plays at 23.5 fps.
    29, 28, 27, 26, 25, 24, 23, 22 and 21 fps all play at 20.1 fps.
    20 fps plays at 16.5 fps

    . . . . etc etc

    Which might lead you to creating your own timers using rules that check the game's clock (self.time / game.time) . . . . but honestly this is all getting a little insane ! :) you will end up with dozens of fixes and tricks and workarounds and animations and attributes and constrains (etc etc) - all to avoid simply moving the camera !

    It's like he is trying to get from his house to the train station - and we are all offering workarounds and tricks and clever ideas as to how he can move the city passed his house so that eventually the train station will come to him.

    :)
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    Yeah, I didn't notice until now that the animation's fps is a scrollable bar and not a number that can be modified easily :/
    And even if you could modify it's value it's a comically inaccurate number ! The value it displays bears no relationship to the real word, it's not even internally consistent- i.e: 29 fps is the same speed as 21 fps (both 20.1 fps) - and 16 fps is the same speed as 19 fps (both 15.1 fps) - 20 fps is not double the playback speed of 10 fps . . etc etc
  • beefy_clyrobeefy_clyro Member Posts: 5,394
    @Socks Good point my man! Although part of the fun is coming up with a workaround ;)
    Personally, as i've got a little bit of extra time off this xmas and to have a break from my main project i'm working on, i've started work on a runner. Only spent half a day on it but have most mechanics down. I went with the whole everything scrolling from the left and its all going ok at the moment.
  • SocksSocks London, UK.Member Posts: 12,822
    Although part of the fun is coming up with a workaround ;)
    Very true, you learn a lot from trying to trick GameSalad into doing something it doesn't want to.
    I went with the whole everything scrolling from the left and its all going ok at the moment.
    Scrolling from the left ! You've just broken several hundred years of game design law, you will be reported to the game design police.

    : )
  • beefy_clyrobeefy_clyro Member Posts: 5,394


    Scrolling from the left ! You've just broken several hundred years of game design law, you will be reported to the game design police.

    : )
    I like to break the mould from time to time, a quick whizz in from the left and then loop, jobs a good-un!

    Don't report me though, I heard the punishment for such a cyber crime is every time I switch on my Mac, a photo of Jedward appears!!! I'm not gonna lie, I don't know if I cant take that man!
  • SocksSocks London, UK.Member Posts: 12,822
    Don't report me though, I heard the punishment for such a cyber crime is every time I switch on my Mac, a photo of Jedward appears!!! I'm not gonna lie, I don't know if I cant take that man!
    It's worse than you think, the image is accompanied by a random selection of four tracks from their shocking new album 'Young Love' - all rendered in mind bending 12kbps / 11kHz - I've seen strong men breakdown and cry.
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    Nooooooooo
    If you can't do the time, don't do the crime. Scrolling from the left !? Whatever next !?!
Sign In or Register to comment.