Question on enemy spawner in sidescroller

butterbeanbutterbean Member Posts: 4,315
edited November -1 in Working with GS (Mac)
So I'm just diving into creating a sidescrolling platformer and wanted to see how peeps on GS are spawning enemies in a sidescrolling platformer game.

So, the width of the entire scene (that I've planned so far for one level) is approximately 1500 width, but the standard height (320)

2 questions:

1) How and where would you spawn enemies from if the scene is so wide?

Would you spawn them from position 1480 (at the end of the scene) say every 4 seconds?

I know there is a simple solution, just have tunnel vision from creating other games not realated to this genre :)

For example, as the character moves to the right, through the scene, I want enemies spawning from the left and the right side, how would you implement this?

2) When creating the backdrops and laying them side by side, would it be okay per GS standards and for memory usage to place 2 1024 X 320 scenes next to one another given the power of 2 rule?

Or would it be best to shrink it down further, and do 3, 512X320 scenes and line them next to each other?

Thank you :)

Comments

  • SDMGSDMG Member Posts: 280
    Hi Butterbean21,

    i have some ideas that doesn't fits perfectly your needs but maybee it will point you in the right direction

    Maybee you can spawn an enemy when your character is moving ie. every 50 pixels this way:

    Create a global Variable(integer) calling ie. XPosCheck
    Then constrain XPosCheck to Character.XPos % 50

    Create a rule:

    If XPosCheck equals 0 --> Spawn enemy

    If this should work only by moving the character to the right i would create a global variable calling OldCharacter_XPos... and then create a rule: (at start you have to set the Character_oldXPos to your Character.XPos)

    If an attribute changes: Character.XPos is greater than Character_oldXPos and(!)
    If XPosCheck equals 0 --> Spawn enemy and Character_oldXPos=Character.XPos

    Just an idea ... i haven't test it ;)

    and i would think that using 3 * 512x320 uses less memory ... and spawning enemies far away uses unnecessary memory for things that are not visible... may you can spawn them dynamically at Character.XPos + ScreenWidth... this way they are out of sight but quick on screen...

    Cheers

    SDMG
  • butterbeanbutterbean Member Posts: 4,315
    Thanks SDMG! I'm going to give that a try :) Appreciate your help!

    That's what I figured with the 512X320 scenes, I will go ahead and do it that way, thanks :)

    Has anyone else done this in a different way as far as spawning enemies on the screen in a sidescroller that may be a little easier?
  • butterbeanbutterbean Member Posts: 4,315
    Is there another way of spawning enemies in a sidescroller besides the idea mentioned above?

    Just wanted to see if peeps were approaching this any different :)
  • quantumsheepquantumsheep Member Posts: 8,188
    Well, thinking about it a little you could:

    Plan out the whole level, and have certain enemies appear after a certain amount of time.

    After 10 seconds spawn a fighter ship.

    After 20 seconds spawn a Bigger fighter ship etc etc

    Maybe make them appear 300 to the right of the player ship at a random height (that's how they might spawn for example - actually, I LOVE that! Thanks, me!).

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • butterbeanbutterbean Member Posts: 4,315
    That sounds like a great solution too, but what if you're having multiple enemies of the same caliber being spawned, could I say every 3 seconds, spawn enemy "name"? But if I want a dedicated position, like enemies being spawned from either side of the main actor, how would I do that based on timer and what position should I place in there?
Sign In or Register to comment.