1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2025-01-05 16:39:44 +01:00

Move more properties to enemy types

This should keep most of the mess outside of `setenemyroom`, however
`setenemy` still has a few variables I don't know how to tackle.
This commit is contained in:
AllyTally 2023-09-01 23:52:35 -03:00 committed by NyakoFox
parent 9a17a07ef3
commit 3e4079a0d2
3 changed files with 65 additions and 49 deletions

View file

@ -113,14 +113,10 @@ void entclass::setenemy( int t )
break; break;
case 1: case 1:
obj.set_enemy_type(this, "lies"); obj.set_enemy_type(this, "lies");
yp += 10;
lerpoldyp += 10;
behave = 11; behave = 11;
para = 9; // destroyed when outside para = 9; // destroyed when outside
x1 = -200; x1 = -200;
x2 = 400; x2 = 400;
cx = 1;
cy = 1;
break; break;
case 2: case 2:
obj.set_enemy_type(this, "lies_collector"); obj.set_enemy_type(this, "lies_collector");
@ -134,22 +130,13 @@ void entclass::setenemy( int t )
{ {
case 0: case 0:
obj.set_enemy_type(this, "factory_emitter"); obj.set_enemy_type(this, "factory_emitter");
size = 9;
behave = 12; behave = 12;
cx = 0;
cy = 24;
break; break;
case 1: case 1:
obj.set_enemy_type(this, "factory_clouds"); obj.set_enemy_type(this, "factory_clouds");
xp += 4;
lerpoldxp += 4;
yp -= 4;
lerpoldyp -= 4;
behave = 13; behave = 13;
para = -6; //destroyed when outside para = -6; //destroyed when outside
x2 = 400; x2 = 400;
cx = 0;
cy = 6;
break; break;
case 2: case 2:
obj.set_enemy_type(this, "factory_collector"); obj.set_enemy_type(this, "factory_collector");
@ -186,26 +173,15 @@ void entclass::setenemyroom( int rx, int ry )
obj.set_enemy_type(this, "guard"); obj.set_enemy_type(this, "guard");
break; break;
case rn(13, 4): //Communication Station case rn(13, 4): //Communication Station
harmful = false;
if (xp == 256) if (xp == 256)
{ {
//transmittor //transmittor
obj.set_enemy_type(this, "transmitter"); obj.set_enemy_type(this, "transmitter");
xp -= 24;
lerpoldxp -= 24;
yp -= 16;
lerpoldyp -= 16;
} }
else else
{ {
//radar dish //radar dish
obj.set_enemy_type(this, "radar"); obj.set_enemy_type(this, "radar");
cx = 4;
size = 9;
xp -= 4;
lerpoldxp -= 4;
yp -= 32;
lerpoldyp -= 32;
} }
break; break;
@ -234,15 +210,12 @@ void entclass::setenemyroom( int rx, int ry )
break; //Factory break; //Factory
case rn(13,7): // MAVVERRRICK case rn(13,7): // MAVVERRRICK
obj.set_enemy_type(this, "bus"); obj.set_enemy_type(this, "bus");
size = 9;
break; break;
case rn(11, 13): //Truth case rn(11, 13): //Truth
obj.set_enemy_type(this, "truth"); obj.set_enemy_type(this, "truth");
size = 10;
break; break;
case rn(17, 7): //Brass sent us under the top case rn(17, 7): //Brass sent us under the top
obj.set_enemy_type(this, "solider"); obj.set_enemy_type(this, "solider");
cx = 4;
break; break;
case rn(10, 7): // (deception) case rn(10, 7): // (deception)
obj.set_enemy_type(this, "bowtie"); obj.set_enemy_type(this, "bowtie");
@ -265,13 +238,9 @@ void entclass::setenemyroom( int rx, int ry )
//Warp Zone //Warp Zone
case rn(15, 2): // (numbers) case rn(15, 2): // (numbers)
obj.set_enemy_type(this, "numbers"); obj.set_enemy_type(this, "numbers");
yp += 1;
lerpoldyp += 1;
break; break;
case rn(16, 2): // (Manequins) case rn(16, 2): // (Manequins)
obj.set_enemy_type(this, "mannequin"); obj.set_enemy_type(this, "mannequin");
yp -= 4;
lerpoldyp -= 4;
break; break;
case rn(18, 0): // (Obey) case rn(18, 0): // (Obey)
obj.set_enemy_type(this, "obey"); obj.set_enemy_type(this, "obey");
@ -303,7 +272,6 @@ void entclass::setenemyroom( int rx, int ry )
break; break;
case rn(18, 2): // Thinking with Portals case rn(18, 2): // Thinking with Portals
//depends on direction //depends on direction
size = 10;
if (xp == 88) if (xp == 88)
{ {
obj.set_enemy_type(this, "centipede_right"); obj.set_enemy_type(this, "centipede_right");
@ -347,8 +315,6 @@ void entclass::setenemyroom( int rx, int ry )
case rn(11, 8): case rn(11, 8):
case rn(12, 8): case rn(12, 8):
obj.set_enemy_type(this, "elephant"); obj.set_enemy_type(this, "elephant");
size = 11;
harmful = false;
break; break;
} }
} }

View file

@ -105,7 +105,7 @@ void entityclass::init(void)
add_default_types(); add_default_types();
} }
void entityclass::create_type(const char* type, int tile, int colour, int animate, int width, int height) EnemyType* entityclass::create_type(const char* type, int tile, int colour, int animate, int width, int height)
{ {
EnemyType enemy_type; EnemyType enemy_type;
enemy_type.tile = tile; enemy_type.tile = tile;
@ -113,12 +113,21 @@ void entityclass::create_type(const char* type, int tile, int colour, int animat
enemy_type.animate = animate; enemy_type.animate = animate;
enemy_type.width = width; enemy_type.width = width;
enemy_type.height = height; enemy_type.height = height;
enemy_type.harmful = true;
enemy_type.corner_x = 0;
enemy_type.corner_y = 0;
enemy_type.x_offset = 0;
enemy_type.y_offset = 0;
enemy_type.size = 0;
enemy_types[type] = enemy_type; enemy_types[type] = enemy_type;
return &enemy_types[type];
} }
void entityclass::add_default_types(void) void entityclass::add_default_types(void)
{ {
EnemyType* type;
create_type("square", 78, 7, 1, 16, 16); // Vibrating String Problem create_type("square", 78, 7, 1, 16, 16); // Vibrating String Problem
create_type("circle", 88, 11, 1, 16, 16); // Kids His Age Bounce create_type("circle", 88, 11, 1, 16, 16); // Kids His Age Bounce
create_type("disc", 36, 8, 1, 16, 16); // Security Sweep create_type("disc", 36, 8, 1, 16, 16); // Security Sweep
@ -136,39 +145,66 @@ void entityclass::add_default_types(void)
create_type("wavelength", 32, 7, 1, 32, 16); // Linear Collider create_type("wavelength", 32, 7, 1, 32, 16); // Linear Collider
create_type("stop", 28, 6, 1, 22, 32); // Traffic Jam create_type("stop", 28, 6, 1, 22, 32); // Traffic Jam
create_type("yes", 40, 9, 1, 20, 20); // The Yes Men create_type("yes", 40, 9, 1, 20, 20); // The Yes Men
create_type("bus", 96, 6, 4, 64, 44); // B-B-B-Busted
create_type("vertigo", 172, 7, 100, 32, 32); // Vertigo create_type("vertigo", 172, 7, 100, 32, 32); // Vertigo
create_type("guard", 44, 8, 1, 16, 20); // Trench Warfare create_type("guard", 44, 8, 1, 16, 20); // Trench Warfare
create_type("truth", 64, 7, 100, 44, 10); // Boldly To Go
create_type("obey", 51, 11, 100, 30, 14); // Time to get serious create_type("obey", 51, 11, 100, 30, 14); // Time to get serious
create_type("mannequin", 52, 7, 5, 16, 25); // Short Circuit
create_type("numbers", 100, 6, 1, 32, 14); // Take the Red Pill
create_type("ghost", 106, 7, 2, 24, 25); // The Tomb of Mad Carew create_type("ghost", 106, 7, 2, 24, 25); // The Tomb of Mad Carew
create_type("wheel", 116, 12, 1, 32, 32); // The Hanged Man, Reversed create_type("wheel", 116, 12, 1, 32, 32); // The Hanged Man, Reversed
create_type("skeleton", 56, 6, 1, 15, 24); // You Chose... Poorly create_type("skeleton", 56, 6, 1, 15, 24); // You Chose... Poorly
create_type("solider", 82, 8, 5, 28, 32); // Brass Sent Us Under The Top
create_type("transmitter", 104, 4, 7, 16, 16); // Comms Relay type = create_type("mannequin", 52, 7, 5, 16, 25); // Short Circuit
create_type("radar", 124, 4, 6, 32, 32); // Comms Relay type->y_offset = -4;
type = create_type("numbers", 100, 6, 1, 32, 14); // Take the Red Pill
type->y_offset = 1;
type = create_type("solider", 82, 8, 5, 28, 32); // Brass Sent Us Under The Top
type->corner_x = 4;
type = create_type("truth", 64, 7, 100, 44, 10); // Boldly To Go
type->size = 10;
type = create_type("bus", 96, 6, 4, 64, 44); // B-B-B-Busted
type->size = 9;
type = create_type("transmitter", 104, 4, 7, 16, 16); // Comms Relay
type->harmful = false;
type->x_offset = -24;
type->y_offset = -16;
type = create_type("radar", 124, 4, 6, 32, 32); // Comms Relay
type->harmful = false;
type->x_offset = -4;
type->y_offset = -32;
type->corner_x = 4;
type->size = 9;
create_type("edgegames_left", 160, 8, 1, 16, 16); // Edge Games create_type("edgegames_left", 160, 8, 1, 16, 16); // Edge Games
create_type("edgegames_right", 156, 8, 1, 16, 16); // Edge Games create_type("edgegames_right", 156, 8, 1, 16, 16); // Edge Games
create_type("centipede_right", 66, 12, 100, 60, 16); // Sweeney's Maze type = create_type("centipede_right", 66, 12, 100, 60, 16); // Sweeney's Maze
create_type("centipede_left", 54, 12, 100, 60, 16); // Sweeney's Maze type->size = 10;
type = create_type("centipede_left", 54, 12, 100, 60, 16); // Sweeney's Maze
type->size = 10;
// LIES // LIES
create_type("lies_emitter", 60, 6, 2, 32, 32); create_type("lies_emitter", 60, 6, 2, 32, 32);
create_type("lies", 63, 6, 100, 26, 10); type = create_type("lies", 63, 6, 100, 26, 10);
type->corner_x = 1;
type->corner_y = 1;
type->y_offset = 10;
create_type("lies_collector", 62, 6, 100, 32, 32); create_type("lies_collector", 62, 6, 100, 32, 32);
// Factory // Factory
create_type("factory_emitter", 72, 6, 3, 64, 40); type = create_type("factory_emitter", 72, 6, 3, 64, 40);
create_type("factory_clouds", 76, 6, 100, 32, 12); type->corner_y = 24;
type->size = 9;
type = create_type("factory_clouds", 76, 6, 100, 32, 12);
type->corner_y = 6;
type->x_offset = 4;
type->y_offset = -4;
create_type("factory_collector", 77, 6, 100, 32, 16); create_type("factory_collector", 77, 6, 100, 32, 16);
// Elephant // Elephant
create_type("elephant", 0, 102, 0, 464, 320); type = create_type("elephant", 0, 102, 0, 464, 320);
type->size = 11;
type->harmful = false;
} }
void entityclass::set_enemy_type(entclass* entity, const char* type) void entityclass::set_enemy_type(entclass* entity, const char* type)
@ -181,6 +217,14 @@ void entityclass::set_enemy_type(entclass* entity, const char* type)
entity->animate = enemyType->animate; entity->animate = enemyType->animate;
entity->w = enemyType->width; entity->w = enemyType->width;
entity->h = enemyType->height; entity->h = enemyType->height;
entity->harmful = enemyType->harmful;
entity->cx = enemyType->corner_x;
entity->cy = enemyType->corner_y;
entity->xp += enemyType->x_offset;
entity->lerpoldxp += enemyType->x_offset;
entity->yp += enemyType->y_offset;
entity->lerpoldyp += enemyType->y_offset;
entity->size = enemyType->size;
} }
} }

View file

@ -40,6 +40,12 @@ struct EnemyType
int animate; int animate;
int width; int width;
int height; int height;
int harmful;
int corner_x;
int corner_y;
int x_offset;
int y_offset;
int size;
}; };
class entityclass class entityclass
@ -47,7 +53,7 @@ class entityclass
public: public:
void init(void); void init(void);
void create_type(const char* type, int tile, int colour, int animate, int width, int height); EnemyType* create_type(const char* type, int tile, int colour, int animate, int width, int height);
void add_default_types(void); void add_default_types(void);
const char* legacy_id_to_entity(int id); const char* legacy_id_to_entity(int id);
void set_enemy_type(entclass* entity, const char* type); void set_enemy_type(entclass* entity, const char* type);