Log In  

Hi! I'm in the middle of trying to make a 2-D platformer as my first game, and I've been wondering how I would do something like this.
I want the player to spawn on a specific map tile with a specific flag. I don't want to have to jot down the specific tile to record for each spawn location, but if it is what I need to do then so be it. Any help at all would be appreciated!

P#92573 2021-05-25 21:53

This is possible, and a good way to do it! It lets you define and see enemy spawn points in the map editor, which is nicer than having to check the code too all the time.

The basic idea to spawn enemies on various spawn points (edit: you wanted player, same idea works)

  • sprite flags are 8 on/off toggles set for each sprite and that have no default meaning
  • define that some flag sprite means spawn
  • when the game starts (or when a level is loaded), go through all tiles on screen with a for loop
  • use mget+fget functions to see if the tile has the special flag
  • if yes, create an entity for a monster there (probably a table with sprite number, x, y, health, etc. depends on your game)
  • if you want to, use mset to replace the spawn tile with another tile (if you have a special mark on your spawn tile that you want to see in map editor but not in game)

This should get you started and give you function names to search for!

P#92597 2021-05-26 03:00 ( Edited 2021-05-26 03:00)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-19 17:09:27 | 0.005s | Q:11