Thanks for all response. Done a lot of testing with if statements where I added and subtracted the width of the sprite (40 in this case), but no result. It works fine on one side but not on the other… So I end up with this solution. Not the best or must genius solution I think, but it works. The screen size is 1400, so I give coords1_x a value of 700. I use that value when doing the check and now it works fine.

Anyway, I’m shore it’s a better way to do it.

Code:
function collisions_startup()
{
	wait (3); 
	
	var coords1_x, coords1_y;
	var format, pixel1;
	COLOR pixel1_color;
 
	while (1)
	{
		
		// This check the bottom of the player sprite
		
                coords1_x = 700;
		
		if (coords1_x <= (my_player.pos_x + bmap_width(player_tga))) 
		{
		coords1_x = my_player.pos_x + bmap_width(player_tga) - 40;
	   }
		if (coords1_x >= (my_player.pos_x + bmap_width(player_tga))) 
		{
		coords1_x = my_player.pos_x + bmap_width(player_tga);	
		}	
	 
		coords1_y = my_player.pos_y + 40;
		format = bmap_lock (level_tga, 0);
		pixel1 = pixel_for_bmap(level_tga, coords1_x, coords1_y);
		pixel_to_vec (pixel1_color, NULL, format, pixel1); 
		if (pixel1_color.red == 255) 
		{
			my_player.pos_y -= 2;
			}
	
		bmap_unlock (level_tga);
		wait (1);
	}

}



Last edited by Gastara; 06/24/10 14:09.