How to put maps in your game
-
I’m making a game I got the player sprite to move how I wanted but I don’t know how to put the map I made for it onto the screen.
-
Outside of your game loop, you use loadMap() to load your map, and then in the game loop, before drawSprites(), you use drawMap() to display the map. And, if your map contains animations, you also call updateMap(), usually before drawMap.
-
Thank you Z-Mann
-
I got the map to appear but I can’t get the collision to work
-
This post is deleted! -
That would be collideMap(yourSprite), in the simplest case. That will move yourSprite out of the way of any collision zones of your map.
Depending on your game, you will need to do additional work. If you keep the desired location of your character in a variable, you need to read it out post-collision with getSpriteLocation().
If your character is supposed to have momentum/velocity, that is if it's not instantly stopping if you center the stick, you'll need to understand and use the returned data of collideMap and use it to modify the velocity so that further movement does not drive you further into the collision zones. Or maybe you want to bounce off walls. That is all
, very hard to explain in a vacuum and you probably don't need it at first.