1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Move entityclass::setenemy() to entclass::setenemy()

This moves the setenemy() function onto the entity object itself,
instead of having to give the indice of the entity in obj.entities. This
makes the code more object-oriented so later I can simply change all
'entities[k]' to 'entity.' in entityclass::createentity().
This commit is contained in:
Misa 2020-04-03 12:29:57 -07:00 committed by Ethan Lee
parent c278f05397
commit d4cffed176
4 changed files with 89 additions and 89 deletions

View file

@ -86,3 +86,88 @@ bool entclass::outside()
}
return false;
}
void entclass::setenemy( int t )
{
switch(t)
{
case 0:
//lies emitter
if( (para)==0)
{
tile = 60;
animate = 2;
colour = 6;
behave = 10;
w = 32;
h = 32;
x1 = -200;
}
else if ( (para) == 1)
{
yp += 10;
tile = 63;
animate = 100; //LIES
colour = 6;
behave = 11;
para = 9; //destroyed when outside
x1 = -200;
x2 = 400;
w = 26;
h = 10;
cx = 1;
cy = 1;
}
else if ( (para) == 2)
{
tile = 62;
animate = 100;
colour = 6;
behave = -1;
w = 32;
h = 32;
}
break;
case 1:
//FACTORY emitter
if( (para)==0)
{
tile = 72;
animate = 3;
size = 9;
colour = 6;
behave = 12;
w = 64;
h = 40;
cx = 0;
cy = 24;
}
else if ( (para) == 1)
{
xp += 4;
yp -= 4;
tile = 76;
animate = 100; // Clouds
colour = 6;
behave = 13;
para = -6; //destroyed when outside
x2 = 400;
w = 32;
h = 12;
cx = 0;
cy = 6;
}
else if ( (para) == 2)
{
tile = 77;
animate = 100;
colour = 6;
behave = -1;
w = 32;
h = 16;
}
break;
default:
break;
}
}

View file

@ -10,6 +10,8 @@ public:
bool outside();
void setenemy(int t);
public:
//Fundamentals
bool active, invis;

View file

@ -1601,91 +1601,6 @@ void entityclass::setenemyroom( int t, int rx, int ry )
}
}
void entityclass::setenemy( int t, int r )
{
switch(t)
{
case 0:
//lies emitter
if( (entities[r].para)==0)
{
entities[r].tile = 60;
entities[r].animate = 2;
entities[r].colour = 6;
entities[r].behave = 10;
entities[r].w = 32;
entities[r].h = 32;
entities[r].x1 = -200;
}
else if ( (entities[r].para) == 1)
{
entities[r].yp += 10;
entities[r].tile = 63;
entities[r].animate = 100; //LIES
entities[r].colour = 6;
entities[r].behave = 11;
entities[r].para = 9; //destroyed when outside
entities[r].x1 = -200;
entities[r].x2 = 400;
entities[r].w = 26;
entities[r].h = 10;
entities[r].cx = 1;
entities[r].cy = 1;
}
else if ( (entities[r].para) == 2)
{
entities[r].tile = 62;
entities[r].animate = 100;
entities[r].colour = 6;
entities[r].behave = -1;
entities[r].w = 32;
entities[r].h = 32;
}
break;
case 1:
//FACTORY emitter
if( (entities[r].para)==0)
{
entities[r].tile = 72;
entities[r].animate = 3;
entities[r].size = 9;
entities[r].colour = 6;
entities[r].behave = 12;
entities[r].w = 64;
entities[r].h = 40;
entities[r].cx = 0;
entities[r].cy = 24;
}
else if ( (entities[r].para) == 1)
{
entities[r].xp += 4;
entities[r].yp -= 4;
entities[r].tile = 76;
entities[r].animate = 100; // Clouds
entities[r].colour = 6;
entities[r].behave = 13;
entities[r].para = -6; //destroyed when outside
entities[r].x2 = 400;
entities[r].w = 32;
entities[r].h = 12;
entities[r].cx = 0;
entities[r].cy = 6;
}
else if ( (entities[r].para) == 2)
{
entities[r].tile = 77;
entities[r].animate = 100;
entities[r].colour = 6;
entities[r].behave = -1;
entities[r].w = 32;
entities[r].h = 16;
}
break;
default:
break;
}
}
void entityclass::settreadmillcolour( int t, int rx, int ry )
{
rx -= 100;
@ -1865,12 +1780,12 @@ void entityclass::createentity( float xp, float yp, int t, float vx /*= 0*/, flo
if (game.roomy == 111 && (game.roomx >= 113 && game.roomx <= 117))
{
setenemy(0, k);
entities[k].setenemy(0);
setenemyroom(k, game.roomx, game.roomy); //For colour
}
else if (game.roomx == 113 && (game.roomy <= 110 && game.roomy >= 108))
{
setenemy(1, k);
entities[k].setenemy(1);
setenemyroom(k, game.roomx, game.roomy); //For colour
}
else if (game.roomx == 113 && game.roomy == 107)

View file

@ -84,8 +84,6 @@ public:
void setenemyroom(int t, int rx, int ry);
void setenemy(int t, int r);
void settreadmillcolour(int t, int rx, int ry);
void createentity(float xp, float yp, int t, float vx = 0, float vy = 0,