I am creating smart monsters which can detect obstacles. Objects in yellow circles are obstacles. Red circles are where they can jump
Ignore two yellow circles on both left and right sides of the map
When user is in higher place than monster, monster should find place which they can jump. If monsters are under obstacles, they should not jump.
These obstacles(floors) are drawn so.
Unfortunately, I don't know how to do that. I know how to detect enemies' position but not position of obstacles.
I am not asking do that for me. I am just wondering what should and what can I do!
Any help, advice, tip will be grateful!
So I'm going to assume if you have floor collision you are now farmilliar with mget to check flags of tiles on the map, right?
The simplest way would be to have a blank tile with a specific flag, put that on the map, then if your enemy collides with that do their logic for if they should jump up to the next floor or not.
Does that make sense?
Davbo Oh thank you!
Now I have a Idea.
First check enemy's x position than, check tiles which shares same x position as enemy with higher y position. If mget returns nothing or false, allow jump. If it mget finds tiles than no jump.
Am I right?
I don't know your code, but sure. There are lots of ways to use mget so play around and see what works for you. Remember there is always the Pico 8 wiki if you want some hints and tips on a specific function. Just Google Pico 8 wiki and you'll find it.
Along the lines if what @Davbo suggests: add another map with meta information for the npc.
That map is not drawn, only checked to trigger various actions.
Super Crate Box doesn’t have gazillion of maps nor sprites, that should work just fine.
What he was suggesting is putting an invisible tile with a "jump" flag checked. So when enemies come to it they know to jump. Like imagine putting a spring on the ground when they get to it, they jump. Except you just make the sprite for the spring so it's invisible. Then you just tell your enemies to use the spring only if the player's y is greater than their y.
You could also use sprite flags. For your "edge" tile sprites, set one of the eight flags to say it's a jumpable area. You could even use two of them to say which directions are available to jump. Then you look up the sprite tile the NPC is standing on in the map, check its flags, and let the NPC do its thing.
(Or have a lookup table in your code that's keyed on tile ID or the x,y location on screen and says what interesting landmarks are there.)
Thanks for this post, I didn't know about these flags, it blew my mind, I can do so many things with them!
Thank you every body. I saw answers just now. I will try what I can!
[Please log in to post a comment]