1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
//Player collision map
void player_collision_map( playerHandle* pPlayer )
{
//Init of graph coordinats
int x;
int y;
//Rect
SDL_Rect set[6];
//Map array
int map_offset [MAP_HEIGHT][MAP_WIDTH]=
{
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,1,2,2,3,0,0,0,0,0,0,0,0,0},
{0,0,0,1,2,3,0,4,5,5,6,0,0,0,0,1,2,3,0,0},
{2,3,0,4,5,6,0,4,5,5,6,0,0,0,0,4,5,6,0,0}
};
for( y = 0; y < MAP_HEIGHT; y++ )
{
for( x = 0; x < MAP_WIDTH; x++ )
{
switch( map_offset[y][x] )
{
case 1 : if( pPlayer->y == (y*32) )
{
pPlayer->isOnGround = true;
};
break;
case 2 : if( pPlayer->y == (y*32) )
{
pPlayer->isOnGround = true;
};
break;
case 3 : if( pPlayer->y == (y*32) )
{
pPlayer->isOnGround = true;
};
break;
case 4 : break;
case 5 : break;
case 6 : break;
}
}
}
}
|