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

Move entityclass::setenemyroom() to entclass::setenemyroom()

This moves the setenemyroom() function onto the entity object itself, so
I can more easily change all 'entities[k].' to 'entity.' in
entityclass::createentity() later.

Additionally, I've had to move the rn() macro from Entity.h to Ent.h, or
else entclass::setenemyroom() won't know what it is.
This commit is contained in:
Misa 2020-04-03 12:43:06 -07:00 committed by Ethan Lee
parent d4cffed176
commit f5a84d7972
4 changed files with 352 additions and 352 deletions

View file

@ -171,3 +171,337 @@ void entclass::setenemy( int t )
break;
}
}
void entclass::setenemyroom( int rx, int ry )
{
//Simple function to initilise simple enemies
rx -= 100;
ry -= 100;
switch(rn(rx, ry))
{
//Space Station 1
case rn(12, 3): //Security Drone
tile = 36;
colour = 8;
animate = 1;
break;
case rn(13, 3): //Wavelengths
tile = 32;
colour = 7;
animate = 1;
w = 32;
break;
case rn(15, 3): //Traffic
tile = 28;
colour = 6;
animate = 1;
w = 22;
h = 32;
break;
case rn(12, 5): //The Yes Men
tile = 40;
colour = 9;
animate = 1;
w = 20;
h = 20;
break;
case rn(13, 6): //Hunchbacked Guards
tile = 44;
colour = 8;
animate = 1;
w = 16;
h = 20;
break;
case rn(13, 4): //Communication Station
harmful = false;
if (xp == 256)
{
//transmittor
tile = 104;
colour = 4;
animate = 7;
w = 16;
h = 16;
xp -= 24;
yp -= 16;
}
else
{
//radar dish
tile =124;
colour = 4;
animate = 6;
w = 32;
h = 32;
cx = 4;
size = 9;
xp -= 4;
yp -= 32;
}
break;
//The Lab
case rn(4, 0):
tile = 78;
colour = 7;
animate = 1;
w = 16;
h = 16;
break;
case rn(2, 0):
tile = 88;
colour = 11;
animate = 1;
w = 16;
h = 16;
break;
//Space Station 2
case rn(14, 11):
colour = 17;
break; //Lies
case rn(16, 11):
colour = 8;
break; //Lies
case rn(13, 10):
colour = 11;
break; //Factory
case rn(13, 9):
colour = 9;
break; //Factory
case rn(13, 8):
colour = 8;
break; //Factory
case rn(11, 13): //Truth
tile = 64;
colour = 7;
animate = 100;
w = 44;
h = 10;
size = 10;
break;
case rn(17, 7): //Brass sent us under the top
tile =82;
colour = 8;
animate = 5;
w = 28;
h = 32;
cx = 4;
break;
case rn(10, 7): // (deception)
tile = 92;
colour = 6;
animate = 1;
w = 16;
h = 16;
break;
case rn(14, 13): // (chose poorly)
tile = 56;
colour = 6;
animate = 1;
w = 15;
h = 24;
break;
case rn(13, 12): // (backsliders)
tile = 164;
colour = 7;
animate = 1;
w = 16;
h = 16;
break;
case rn(14, 8): // (wheel of fortune room)
tile = 116;
colour = 12;
animate = 1;
w = 32;
h = 32;
break;
case rn(16, 9): // (seeing dollar signs)
tile = 68;
colour = 7;
animate = 1;
w = 16;
h = 16;
break;
case rn(16, 7): // (tomb of mad carew)
tile = 106;
colour = 7;
animate = 2;
w = 24;
h = 25;
break;
//Warp Zone
case rn(15, 2): // (numbers)
tile = 100;
colour = 6;
animate = 1;
w = 32;
h = 14;
yp += 1;
break;
case rn(16, 2): // (Manequins)
tile = 52;
colour = 7;
animate = 5;
w = 16;
h = 25;
yp -= 4;
break;
case rn(18, 0): // (Obey)
tile = 51;
colour = 11;
animate = 100;
w = 30;
h = 14;
break;
case rn(19, 1): // Ascending and Descending
tile = 48;
colour = 9;
animate = 5;
w = 16;
h = 16;
break;
case rn(19, 2): // Shockwave Rider
tile = 176;
colour = 6;
animate = 1;
w = 16;
h = 16;
break;
case rn(18, 3): // Mind the gap
tile = 168;
colour = 7;
animate = 1;
w = 16;
h = 16;
break;
case rn(17, 3): // Edge Games
if (yp ==96)
{
tile = 160;
colour = 8;
animate = 1;
w = 16;
h = 16;
}
else
{
tile = 156;
colour = 8;
animate = 1;
w = 16;
h = 16;
}
break;
case rn(16, 0): // I love you
tile = 112;
colour = 8;
animate = 5;
w = 16;
h = 16;
break;
case rn(14, 2): // That's why I have to kill you
tile = 114;
colour = 6;
animate = 5;
w = 16;
h = 16;
break;
case rn(18, 2): // Thinking with Portals
//depends on direction
if (xp ==88)
{
tile = 54+12;
colour = 12;
animate = 100;
w = 60;
h = 16;
size = 10;
}
else
{
tile = 54;
colour = 12;
animate = 100;
w = 60;
h = 16;
size = 10;
}
break;
//Final level
case rn(50-100, 53-100): //The Yes Men
tile = 40;
colour = 9;
animate = 1;
w = 20;
h = 20;
break;
case rn(48-100, 51-100): //Wavelengths
tile = 32;
colour = 7;
animate = 1;
w = 32;
break;
case rn(43-100,52-100): // Ascending and Descending
tile = 48;
colour = 9;
animate = 5;
w = 16;
h = 16;
break;
case rn(46-100,51-100): //kids his age
tile = 88;
colour = 11;
animate = 1;
w = 16;
h = 16;
break;
case rn(43-100,51-100): // Mind the gap
tile = 168;
colour = 7;
animate = 1;
w = 16;
h = 16;
break;
case rn(44-100,51-100): // vertigo?
tile = 172;
colour = 7;
animate = 100;
w = 32;
h = 32;
break;
case rn(44-100,52-100): // (backsliders)
tile = 164;
colour = 7;
animate = 1;
w = 16;
h = 16;
break;
case rn(43-100, 56-100): //Intermission 1
tile = 88;
colour = 21;
animate = 1;
w = 16;
h = 16;
break;
case rn(45-100, 56-100): //Intermission 1
tile = 88;
colour = 21;
animate = 1;
w = 16;
h = 16;
break;
//The elephant
case rn(11, 9):
case rn(12, 9):
case rn(11, 8):
case rn(12, 8):
tile = 0;
colour = 102;
animate = 0;
w = 464;
h = 320;
size = 11;
harmful = false;
break;
}
}

View file

@ -1,6 +1,8 @@
#ifndef ENT_H
#define ENT_H
#define rn( rx, ry) ((rx) + ((ry) * 100))
class entclass
{
public:
@ -12,6 +14,8 @@ public:
void setenemy(int t);
void setenemyroom(int rx, int ry);
public:
//Fundamentals
bool active, invis;

View file

@ -1267,340 +1267,6 @@ int entityclass::crewcolour( int t )
return 0;
}
void entityclass::setenemyroom( int t, int rx, int ry )
{
//Simple function to initilise simple enemies
rx -= 100;
ry -= 100;
switch(rn(rx, ry))
{
//Space Station 1
case rn(12, 3): //Security Drone
entities[t].tile = 36;
entities[t].colour = 8;
entities[t].animate = 1;
break;
case rn(13, 3): //Wavelengths
entities[t].tile = 32;
entities[t].colour = 7;
entities[t].animate = 1;
entities[t].w = 32;
break;
case rn(15, 3): //Traffic
entities[t].tile = 28;
entities[t].colour = 6;
entities[t].animate = 1;
entities[t].w = 22;
entities[t].h = 32;
break;
case rn(12, 5): //The Yes Men
entities[t].tile = 40;
entities[t].colour = 9;
entities[t].animate = 1;
entities[t].w = 20;
entities[t].h = 20;
break;
case rn(13, 6): //Hunchbacked Guards
entities[t].tile = 44;
entities[t].colour = 8;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 20;
break;
case rn(13, 4): //Communication Station
entities[t].harmful = false;
if (entities[t].xp == 256)
{
//transmittor
entities[t].tile = 104;
entities[t].colour = 4;
entities[t].animate = 7;
entities[t].w = 16;
entities[t].h = 16;
entities[t].xp -= 24;
entities[t].yp -= 16;
}
else
{
//radar dish
entities[t].tile =124;
entities[t].colour = 4;
entities[t].animate = 6;
entities[t].w = 32;
entities[t].h = 32;
entities[t].cx = 4;
entities[t].size = 9;
entities[t].xp -= 4;
entities[t].yp -= 32;
}
break;
//The Lab
case rn(4, 0):
entities[t].tile = 78;
entities[t].colour = 7;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 16;
break;
case rn(2, 0):
entities[t].tile = 88;
entities[t].colour = 11;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 16;
break;
//Space Station 2
case rn(14, 11):
entities[t].colour = 17;
break; //Lies
case rn(16, 11):
entities[t].colour = 8;
break; //Lies
case rn(13, 10):
entities[t].colour = 11;
break; //Factory
case rn(13, 9):
entities[t].colour = 9;
break; //Factory
case rn(13, 8):
entities[t].colour = 8;
break; //Factory
case rn(11, 13): //Truth
entities[t].tile = 64;
entities[t].colour = 7;
entities[t].animate = 100;
entities[t].w = 44;
entities[t].h = 10;
entities[t].size = 10;
break;
case rn(17, 7): //Brass sent us under the top
entities[t].tile =82;
entities[t].colour = 8;
entities[t].animate = 5;
entities[t].w = 28;
entities[t].h = 32;
entities[t].cx = 4;
break;
case rn(10, 7): // (deception)
entities[t].tile = 92;
entities[t].colour = 6;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 16;
break;
case rn(14, 13): // (chose poorly)
entities[t].tile = 56;
entities[t].colour = 6;
entities[t].animate = 1;
entities[t].w = 15;
entities[t].h = 24;
break;
case rn(13, 12): // (backsliders)
entities[t].tile = 164;
entities[t].colour = 7;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 16;
break;
case rn(14, 8): // (wheel of fortune room)
entities[t].tile = 116;
entities[t].colour = 12;
entities[t].animate = 1;
entities[t].w = 32;
entities[t].h = 32;
break;
case rn(16, 9): // (seeing dollar signs)
entities[t].tile = 68;
entities[t].colour = 7;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 16;
break;
case rn(16, 7): // (tomb of mad carew)
entities[t].tile = 106;
entities[t].colour = 7;
entities[t].animate = 2;
entities[t].w = 24;
entities[t].h = 25;
break;
//Warp Zone
case rn(15, 2): // (numbers)
entities[t].tile = 100;
entities[t].colour = 6;
entities[t].animate = 1;
entities[t].w = 32;
entities[t].h = 14;
entities[t].yp += 1;
break;
case rn(16, 2): // (Manequins)
entities[t].tile = 52;
entities[t].colour = 7;
entities[t].animate = 5;
entities[t].w = 16;
entities[t].h = 25;
entities[t].yp -= 4;
break;
case rn(18, 0): // (Obey)
entities[t].tile = 51;
entities[t].colour = 11;
entities[t].animate = 100;
entities[t].w = 30;
entities[t].h = 14;
break;
case rn(19, 1): // Ascending and Descending
entities[t].tile = 48;
entities[t].colour = 9;
entities[t].animate = 5;
entities[t].w = 16;
entities[t].h = 16;
break;
case rn(19, 2): // Shockwave Rider
entities[t].tile = 176;
entities[t].colour = 6;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 16;
break;
case rn(18, 3): // Mind the gap
entities[t].tile = 168;
entities[t].colour = 7;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 16;
break;
case rn(17, 3): // Edge Games
if (entities[t].yp ==96)
{
entities[t].tile = 160;
entities[t].colour = 8;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 16;
}
else
{
entities[t].tile = 156;
entities[t].colour = 8;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 16;
}
break;
case rn(16, 0): // I love you
entities[t].tile = 112;
entities[t].colour = 8;
entities[t].animate = 5;
entities[t].w = 16;
entities[t].h = 16;
break;
case rn(14, 2): // That's why I have to kill you
entities[t].tile = 114;
entities[t].colour = 6;
entities[t].animate = 5;
entities[t].w = 16;
entities[t].h = 16;
break;
case rn(18, 2): // Thinking with Portals
//depends on direction
if (entities[t].xp ==88)
{
entities[t].tile = 54+12;
entities[t].colour = 12;
entities[t].animate = 100;
entities[t].w = 60;
entities[t].h = 16;
entities[t].size = 10;
}
else
{
entities[t].tile = 54;
entities[t].colour = 12;
entities[t].animate = 100;
entities[t].w = 60;
entities[t].h = 16;
entities[t].size = 10;
}
break;
//Final level
case rn(50-100, 53-100): //The Yes Men
entities[t].tile = 40;
entities[t].colour = 9;
entities[t].animate = 1;
entities[t].w = 20;
entities[t].h = 20;
break;
case rn(48-100, 51-100): //Wavelengths
entities[t].tile = 32;
entities[t].colour = 7;
entities[t].animate = 1;
entities[t].w = 32;
break;
case rn(43-100,52-100): // Ascending and Descending
entities[t].tile = 48;
entities[t].colour = 9;
entities[t].animate = 5;
entities[t].w = 16;
entities[t].h = 16;
break;
case rn(46-100,51-100): //kids his age
entities[t].tile = 88;
entities[t].colour = 11;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 16;
break;
case rn(43-100,51-100): // Mind the gap
entities[t].tile = 168;
entities[t].colour = 7;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 16;
break;
case rn(44-100,51-100): // vertigo?
entities[t].tile = 172;
entities[t].colour = 7;
entities[t].animate = 100;
entities[t].w = 32;
entities[t].h = 32;
break;
case rn(44-100,52-100): // (backsliders)
entities[t].tile = 164;
entities[t].colour = 7;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 16;
break;
case rn(43-100, 56-100): //Intermission 1
entities[t].tile = 88;
entities[t].colour = 21;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 16;
break;
case rn(45-100, 56-100): //Intermission 1
entities[t].tile = 88;
entities[t].colour = 21;
entities[t].animate = 1;
entities[t].w = 16;
entities[t].h = 16;
break;
//The elephant
case rn(11, 9):
case rn(12, 9):
case rn(11, 8):
case rn(12, 8):
entities[t].tile = 0;
entities[t].colour = 102;
entities[t].animate = 0;
entities[t].w = 464;
entities[t].h = 320;
entities[t].size = 11;
entities[t].harmful = false;
break;
}
}
void entityclass::settreadmillcolour( int t, int rx, int ry )
{
rx -= 100;
@ -1781,12 +1447,12 @@ void entityclass::createentity( float xp, float yp, int t, float vx /*= 0*/, flo
if (game.roomy == 111 && (game.roomx >= 113 && game.roomx <= 117))
{
entities[k].setenemy(0);
setenemyroom(k, game.roomx, game.roomy); //For colour
entities[k].setenemyroom(game.roomx, game.roomy); //For colour
}
else if (game.roomx == 113 && (game.roomy <= 110 && game.roomy >= 108))
{
entities[k].setenemy(1);
setenemyroom(k, game.roomx, game.roomy); //For colour
entities[k].setenemyroom(game.roomx, game.roomy); //For colour
}
else if (game.roomx == 113 && game.roomy == 107)
{
@ -1800,7 +1466,7 @@ void entityclass::createentity( float xp, float yp, int t, float vx /*= 0*/, flo
}
else
{
setenemyroom(k, game.roomx, game.roomy);
entities[k].setenemyroom(game.roomx, game.roomy);
}
//}else{*/
@ -2621,17 +2287,17 @@ void entityclass::createentity( float xp, float yp, int t, float vx /*= 0*/, flo
entities[k].harmful = true;
switch(customenemy){
case 0: setenemyroom(k, 4+100, 0+100); break;
case 1: setenemyroom(k, 2+100, 0+100); break;
case 2: setenemyroom(k, 12+100, 3+100); break;
case 3: setenemyroom(k, 13+100, 12+100); break;
case 4: setenemyroom(k, 16+100, 9+100); break;
case 5: setenemyroom(k, 19+100, 1+100); break;
case 6: setenemyroom(k, 19+100, 2+100); break;
case 7: setenemyroom(k, 18+100, 3+100); break;
case 8: setenemyroom(k, 16+100, 0+100); break;
case 9: setenemyroom(k, 14+100, 2+100); break;
default: setenemyroom(k, 4+100, 0+100); break;
case 0: entities[k].setenemyroom(4+100, 0+100); break;
case 1: entities[k].setenemyroom(2+100, 0+100); break;
case 2: entities[k].setenemyroom(12+100, 3+100); break;
case 3: entities[k].setenemyroom(13+100, 12+100); break;
case 4: entities[k].setenemyroom(16+100, 9+100); break;
case 5: entities[k].setenemyroom(19+100, 1+100); break;
case 6: entities[k].setenemyroom(19+100, 2+100); break;
case 7: entities[k].setenemyroom(18+100, 3+100); break;
case 8: entities[k].setenemyroom(16+100, 0+100); break;
case 9: entities[k].setenemyroom(14+100, 2+100); break;
default: entities[k].setenemyroom(4+100, 0+100); break;
}
//Set colour based on room tile

View file

@ -8,8 +8,6 @@
#include <vector>
#include <string>
#define rn( rx, ry) ((rx) + ((ry) * 100))
enum
{
BLOCK = 0,
@ -82,8 +80,6 @@ public:
int crewcolour(int t);
void setenemyroom(int t, int rx, int ry);
void settreadmillcolour(int t, int rx, int ry);
void createentity(float xp, float yp, int t, float vx = 0, float vy = 0,