I’ve been trying to recreate all of the Super Mario bros and need an answer on making enemies spawn off screen. Every time I run the program the enemies fall into a hole and I don’t want them to spawn until i reach a point in a level.
For making them spawn at a certain point in the level would something like forever if player x is a certain value spawn the enemies thats just an idea though
You could make invisible tile locations that act as checkpoints and once you reach it spawns it in just remember to name your tile
if you are using code that places an enemy on every tile of a certain kind, you can repeatedly check whether or not that tile is close to your player and only spawn an enemy when they are. Sort of like this:
Forever:
For element (value) of (array of all ( enemySpawnerTile) locations):
If ((value) row) - (tilemap location of (mySprite) < (40)):
(Code for summoning the enemy)
(Place (EmptyTileOrSomething) at (tilemap location of (my enemy))
Sorry for the unreadability of that, but this is (theoretically) the code for checking if a tile is less than 40 blocks to the right of the player and spawning the enemy if it is. (maybe don’t take my word for this I didn’t test it)
You can modify the code to also check distance upwards and stuff and change the (40) to whatever you want. I hope this makes sense!
I figured I should make a more readable version of that. Also, that code would not work at all I did that math wrong. Here is a better version:
maybe make a sprite with the height of 120 and make it to the right of the screen, so whenever it touches a tile a goomba or whatever will spawn at that tile location, i hope this makes sense XD
Thank you. Ive decided to use this one. Here is the unfinished game: https://arcade.makecode.com/S35243-10831-75287-88765
If there is anything I need to change please say so.
So i got a new problem.
Now that I’ve been working on the game a a lot I’ve recently started working on the sub areas. For some odd reason when you go in to the 4th pipe and exit it, if you are carrying a power up you go back to being small Mario. Here is the game to show you what I’m talking about: https://arcade.makecode.com/S35243-10831-75287-88765