distance from an object?

Started by MisterN, January 03, 2012, 01:23:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MisterN

how does one go about putting in the code for the distance from an object. I used to use map_get_pixel but I am trying to find a better way for collision. To test things out, I changed everything in my fall code to:
// Implementation of fall.   
        ii = fall;   
        if(ii > 0)
            while(ii != 0)   
                if(collision(type level_mask))
                    ii = ii + 1;
                    falling=false;
                        if(!walking);
                            player_status=0;
                        else
                            player_status=1;
                        end
                break; 
            end   
            ii = ii - 1; 
            end   
        else   
            ii = 0; 
        end


It kinda works, if I made every bit of collision (walking left and right into, hitting the ceiling, preparing to jump, etc.) that, then the character just does nothing and floats up. i was wondering if there was a way to get certain distances, like for example x and y and 16 and -16. if someone could (or at the very least show) a way to use the if(collision(type level_mask)) with distance, that would be most helpful.
werg

Arcontus

I can not understand what you're trying to do, but if you are looking for a function that return a distance between two processes, you can obtain this with "INT get_dist ( <INT processID> )" or "INT fget_dist ( <INT pointA-X> , <INT pointA-Y> , <INT pointB-X> , <INT pointB-Y> )". The first function return a value between the curren process that call this function and other process. The second function is very usefull to obtain the distance between other processes.

Regards!
5Leaps, el primer juego comercial desarrollado para BennuGD. http://www.5leaps.com