Question on enemy spawner in sidescroller
butterbean
Member Posts: 4,315
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
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
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
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?
Just wanted to see if peeps were approaching this any different
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