From d4cffed17604b56d90ce4981e6d99dff20b10330 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 3 Apr 2020 12:29:57 -0700 Subject: [PATCH] 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(). --- desktop_version/src/Ent.cpp | 85 ++++++++++++++++++++++++++++++++ desktop_version/src/Ent.h | 2 + desktop_version/src/Entity.cpp | 89 +--------------------------------- desktop_version/src/Entity.h | 2 - 4 files changed, 89 insertions(+), 89 deletions(-) diff --git a/desktop_version/src/Ent.cpp b/desktop_version/src/Ent.cpp index 2f9f75bc..74ecd2be 100644 --- a/desktop_version/src/Ent.cpp +++ b/desktop_version/src/Ent.cpp @@ -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; + } +} diff --git a/desktop_version/src/Ent.h b/desktop_version/src/Ent.h index f3e41f93..1cea4d5a 100644 --- a/desktop_version/src/Ent.h +++ b/desktop_version/src/Ent.h @@ -10,6 +10,8 @@ public: bool outside(); + void setenemy(int t); + public: //Fundamentals bool active, invis; diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index 1a3627db..d82380d6 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -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) diff --git a/desktop_version/src/Entity.h b/desktop_version/src/Entity.h index 2b3f6b2b..70a66fc4 100644 --- a/desktop_version/src/Entity.h +++ b/desktop_version/src/Entity.h @@ -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,