Page 2 of 2

Posted: Sat Oct 23, 2010 8:05 pm
by xelanoimis

Code: Select all

//find player position
	px = PlayerGet(P_ X) ;
	py = PlayerGet(P_Y);

	//set box corner coords
	boxx = px+8;
	boxy = py-14;

	boxa = MaterialRead(boxx,boxy,2,16);
        mask_air = (1 < < MAT_AIR);
        if( ( boxa & (~mask_air) ) != 0 )
            return found_other_materials_than_air

Posted: Sat Oct 23, 2010 8:12 pm
by xelanoimis
Oh, here's the mistery:

1. Player's position returned by PlayerGet(P_ X) is in world coordinates and coresponds to the center of the player (at mouth)
2. The read material functions need the coordinates in room space

Do like this

Code: Select all

px = PlayerGet(P_ X) - GameGet(G_ROOM X) *GameGet(G_ROOMW);
py = PlayerGet(P_Y) - GameGet(G_ROOMY)*GameGet(G_ROOMH);
boxx = px+8;
boxy = py-14;
boxa = MaterialRead(boxx,boxy,2,16);
println (boxa);
and move the player with the mouth inside other material

I tested this in the update handler and it showed a different value there

Posted: Sat Oct 23, 2010 8:16 pm
by delta
xelanoimis wrote: 1. Player's position returned by PlayerGet(P_ X) is in world coordinates and coresponds to the center of the player (at mouth)
2. The read material functions need the coordinates in room space
oh bloody bloody hell :dizzy_mad:

EDIT:: That's fixed it! Thank you very much! :D