Commit 24fd7cc5 authored by Louis Schuck's avatar Louis Schuck

Simplify two player split screen

parent 7656e91a
......@@ -456,90 +456,22 @@ void moveMultiPlayerCameras(RIO_ListCamera* listCamera, float movementRatio, RIO
{
if (listCamera != NULL && listCamera->size > 0)
{
switch(listCamera->size)
RIO_Entity* entityCamera[4];
entityCamera[0] = player1;
entityCamera[1] = player2;
entityCamera[2] = player3;
entityCamera[3] = player4;
int indexPlayer;
for (indexPlayer = 0; indexPlayer < listCamera->size; indexPlayer++)
{
case 1:
if (player1 != NULL)
{
float posCamera[2];
getCenterPosEntity(player1, posCamera);
moveCameraToPoint(listCamera->cameras[0], posCamera[0], posCamera[1], movementRatio);
}
break;
case 2:
if (player1 != NULL && player2 != NULL)
{
RIO_Entity* entityCamera[listCamera->size];
float dist1 = fabsf(player1->x - listCamera->cameras[0]->x) + fabsf(player1->y - listCamera->cameras[0]->y);
float dist2 = fabsf(player2->x - listCamera->cameras[0]->x) + fabsf(player2->y - listCamera->cameras[0]->y);
if (dist1 < dist2)
{
entityCamera[0] = player1;
entityCamera[1] = player2;
}
else
{
entityCamera[0] = player2;
entityCamera[1] = player1;
}
int indexPlayer;
for (indexPlayer = 0; indexPlayer < listCamera->size; indexPlayer++)
{
float posCamera[2];
if (fabsf(entityCamera[0]->x - entityCamera[1]->x) > listCamera->cameras[indexPlayer]->width ||
fabsf(entityCamera[0]->y - entityCamera[1]->y) > listCamera->cameras[indexPlayer]->height*3/4)
{
getCenterPosEntity(entityCamera[indexPlayer], posCamera);
}
else
{
float offsetCamera[2];
getCameraOffsetWhenCliped(listCamera->cameras[indexPlayer], indexPlayer, listCamera->size, offsetCamera);
getCenterPosEntities(entityCamera, 2, posCamera);
posCamera[0] += offsetCamera[0];
posCamera[1] += offsetCamera[1];
}
moveCameraToPoint(listCamera->cameras[indexPlayer], posCamera[0], posCamera[1], movementRatio);
}
}
break;
case 3:
if (player1 != NULL && player2 != NULL && player3 != NULL)
{
RIO_Entity* entityCamera[listCamera->size];
entityCamera[0] = player1;
entityCamera[1] = player2;
entityCamera[2] = player3;
int indexPlayer;
for (indexPlayer = 0; indexPlayer < listCamera->size; indexPlayer++)
{
float posCamera[2];
getCenterPosEntity(entityCamera[indexPlayer], posCamera);
moveCameraToPoint(listCamera->cameras[indexPlayer], posCamera[0], posCamera[1], movementRatio);
}
}
break;
case 4:
if (player1 != NULL && player2 != NULL && player3 != NULL && player4 != NULL)
{
RIO_Entity* entityCamera[listCamera->size];
entityCamera[0] = player1;
entityCamera[1] = player2;
entityCamera[2] = player3;
entityCamera[3] = player4;
int indexPlayer;
for (indexPlayer = 0; indexPlayer < listCamera->size; indexPlayer++)
{
float posCamera[2];
getCenterPosEntity(entityCamera[indexPlayer], posCamera);
moveCameraToPoint(listCamera->cameras[indexPlayer], posCamera[0], posCamera[1], movementRatio);
}
}
break;
if (indexPlayer < 4 && entityCamera[indexPlayer] != NULL)
{
float posCamera[2];
getCenterPosEntity(entityCamera[indexPlayer], posCamera);
moveCameraToPoint(listCamera->cameras[indexPlayer], posCamera[0], posCamera[1], movementRatio);
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment