Platform Map Collisions
-
Hi All
I am working on a platform game with a map I made in the map editor as a first test for myself. I set it up so that unless there is a collision the player falls down. I start the player in the air someplace, and he lands allright on a platform. But, when I jump and hit a platform from below, the same code that stops me falling down, gets me stuck to the bottom of the platform that my head hit.
It is because upon I set playeryspeed = 0 when a collision is detected. It seems to me the answer may lie in the collsion resolution but I have not been able to figure out how to use those.
Is there a good tutorial or resource to read on collisions? I have searched but not found one.
Another question I had is could you help me understand what all is being set when I use collidemap(sprite)? For example if I use colided = colidemap(sprite) it makes what appear to be arrays. Why is this the case? I only checked one sprite against the map. I then do an if len(colided) > 0 then to detect colision, why could I not use colided.exists?Thanks!
-Gil -
The collideMap function handles collisions for you. If you need more control you can use the new marked areas but you will need to handle the collisions yourself. There is an example here: https://fuzearena.com/forum/topic/749/new-marked-map-area-functions
-
Wasn't there also a way for the collision to trigger only if the bottom of the sprite touches the ground? I think I saw something like this in one of the tutorials.
Edit: Sorry, accidental double-post.
-
This post is deleted! -
Thanks for your answer. I understand that collidemap handles collisions for me. Could you elaborate on the specifics?
The built in help does not go into much detail.col = collidemap(sprite)
Results in a variable structure I am not clear on.
Is it an array? It seems to be, but why - is it because there can be more than 1 collision at a time? If so How do I know which is which? Should I setup a loop to go through the col array and look at resolution vectors?Related question. I noticed in the map editor that if I select a bunch of tiles than move them, the collision boxes do not come with. I cant select when editting the map in collision mode. Is there a solution I am missing for this?
Thanks!
-Gil -
@gilman if you change your map youl have to redo your collision boxes to suit, collide map will deal with collision with specified sprite player and the map collision boxes only.
-
@gilman Yes it is an array because there can be more than one collision at the same time. Each array element is a structure containing an exists flag and two resolution vectors (resolution_a and resolution_b). This is common to all collision types (with the map and with other sprites). In the case of the map you need to look at the resolution_a vector.
There is a good example in the built-in Fuze programs called Map Collision Demo which shows both types of collisions.
-
@waldron
Sure this seems right if you change your tiles, but if you translate everything to a new position, say if you need to adjust a platform position because it is too hard to reach by the character jumping, then I would expect collision boxes to come with. Otherwise you have to place everything perfectly the first time you design your map. Maybe -
@gilman just a matter of practice and calculating how far or high your character to jump using the grid reference on the editor