2023-08-31 09:58:35 +02:00
|
|
|
#include "../config.h"
|
2023-08-14 14:22:53 +02:00
|
|
|
|
2023-08-13 17:33:25 +02:00
|
|
|
#include "boss.h"
|
|
|
|
#include "bullet.h"
|
|
|
|
#include <cstdint>
|
|
|
|
#include <num/num.h>
|
|
|
|
#include <gint/rtc.h>
|
|
|
|
#include <sys/types.h>
|
2023-08-31 09:58:35 +02:00
|
|
|
#include "../utilities/fast_trig.h"
|
2023-08-13 17:33:25 +02:00
|
|
|
|
|
|
|
#include <gint/gint.h>
|
|
|
|
#include "collections.h"
|
2023-08-22 23:34:18 +02:00
|
|
|
#include "player.h"
|
2023-08-13 17:33:25 +02:00
|
|
|
|
2023-08-31 09:58:35 +02:00
|
|
|
#include "../utilities/vector2D.h"
|
2023-08-13 17:33:25 +02:00
|
|
|
|
|
|
|
extern bopti_image_t img_Lifebar;
|
|
|
|
extern bopti_image_t img_Boss1;
|
2023-08-22 23:34:18 +02:00
|
|
|
extern bopti_image_t img_BossGun;
|
2023-08-13 17:33:25 +02:00
|
|
|
|
2023-08-14 14:22:53 +02:00
|
|
|
extern font_t milifont_prop;
|
|
|
|
|
2023-08-13 17:33:25 +02:00
|
|
|
|
2023-08-22 23:34:18 +02:00
|
|
|
extern std::vector<Bullet*> MyEnemiesBullets;
|
|
|
|
extern Player *MyPlayer;
|
|
|
|
|
2023-08-13 17:33:25 +02:00
|
|
|
#define NB_PIECES_BOSS 12
|
2023-08-22 23:34:18 +02:00
|
|
|
#define NB_GUNS 12
|
|
|
|
|
2023-08-13 17:33:25 +02:00
|
|
|
libnum::num XdataBossInternal[NB_PIECES_BOSS];
|
|
|
|
libnum::num YdataBossInternal[NB_PIECES_BOSS];
|
|
|
|
libnum::num XdataBossExternal[NB_PIECES_BOSS];
|
|
|
|
libnum::num YdataBossExternal[NB_PIECES_BOSS];
|
|
|
|
|
|
|
|
BossPart Pieces[NB_PIECES_BOSS*2];
|
|
|
|
|
2023-08-22 23:34:18 +02:00
|
|
|
libnum::num xGuns[NB_GUNS];
|
|
|
|
libnum::num yGuns[NB_GUNS];
|
|
|
|
|
|
|
|
BossGun Guns[NB_GUNS];
|
2023-08-13 17:33:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
void savedata( void )
|
|
|
|
{
|
|
|
|
FILE* exportfp = fopen("databosPtxt", "w" );
|
|
|
|
if(exportfp)
|
|
|
|
{
|
|
|
|
fprintf(exportfp, "Points : \n" );
|
|
|
|
|
|
|
|
for( int i=0; i<NB_PIECES_BOSS; i++ )
|
|
|
|
{
|
|
|
|
fprintf(exportfp, "Ext[ %d ] : X= %d - Y= %d \n", i, (int) XdataBossExternal[i], (int) YdataBossExternal[i] );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( int i=0; i<NB_PIECES_BOSS; i++ )
|
|
|
|
{
|
|
|
|
fprintf(exportfp, "Int[ %d ] : X= %d - Y= %d \n", i, (int) XdataBossInternal[i], (int) YdataBossInternal[i] );
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(exportfp, "Triangles : \n" );
|
|
|
|
|
|
|
|
for( int i=0; i<NB_PIECES_BOSS; i++ )
|
|
|
|
{
|
|
|
|
fprintf(exportfp, "Tri ext[ %d ] : P1= %d - P2= %d - P3= %d \n", i, Pieces[2*i].P1, Pieces[2*i].P2, Pieces[2*i].P3 );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( int i=0; i<NB_PIECES_BOSS; i++ )
|
|
|
|
{
|
|
|
|
fprintf(exportfp, "Tri int[ %d ] : P1= %d - P2= %d - P3= %d \n", i, Pieces[2*i+1].P1, Pieces[2*i+1].P2, Pieces[2*i+1].P3 );
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose( exportfp );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Is_Point_Inside_Triangle( int Px, int Py, int P1x, int P1y, int P2x, int P2y, int P3x, int P3y )
|
|
|
|
{
|
|
|
|
int as_x = Px - P1x;
|
|
|
|
int as_y = Py - P1y;
|
|
|
|
|
|
|
|
bool s_ab = (P2x - P1x) * as_y - (P2y - P1y) * as_x > 0;
|
|
|
|
|
2023-08-14 14:22:53 +02:00
|
|
|
if (((P3x - P1x) * as_y - (P3y - P1y) * as_x > 0) == s_ab)
|
2023-08-13 17:33:25 +02:00
|
|
|
return false;
|
2023-08-14 14:22:53 +02:00
|
|
|
if (((P3x - P2x) * (Py - P2y) - (P3y - P2y)*(Px - P2x) > 0) != s_ab)
|
2023-08-13 17:33:25 +02:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Boss::Boss( int16_t _x, int16_t _y, uint8_t _id )
|
|
|
|
{
|
|
|
|
x = libnum::num(_x);
|
|
|
|
y = libnum::num(_y);
|
|
|
|
|
|
|
|
ID = _id;
|
|
|
|
|
2023-08-23 20:16:30 +02:00
|
|
|
speed = 1;
|
2023-08-13 17:33:25 +02:00
|
|
|
|
|
|
|
toberemoved = false;
|
|
|
|
|
|
|
|
width = img_Boss1.width/2;
|
|
|
|
height = img_Boss1.height/2;
|
|
|
|
|
|
|
|
xmin = (int) x - width;
|
|
|
|
xmax = (int) x + width;
|
|
|
|
ymin = (int) y - height;
|
|
|
|
ymax = (int) y + height;
|
|
|
|
|
|
|
|
if (ID==0)
|
|
|
|
{
|
|
|
|
life = 1000;
|
|
|
|
life0 = 1000;
|
|
|
|
}
|
|
|
|
|
2023-08-23 20:16:30 +02:00
|
|
|
hasTrajectory=false;
|
|
|
|
|
2023-08-13 17:33:25 +02:00
|
|
|
lastshoot0 = rtc_ticks();
|
|
|
|
lastshoot1 = rtc_ticks();
|
|
|
|
|
2023-08-22 23:34:18 +02:00
|
|
|
radiusInt = libnum::num( 80 );
|
|
|
|
radiusExt = libnum::num( 90 );
|
2023-08-13 17:33:25 +02:00
|
|
|
|
|
|
|
rotAngle = 0.0f;
|
|
|
|
rotSpeed = 2;
|
|
|
|
|
|
|
|
this->Update(0.0f);
|
|
|
|
|
|
|
|
for( int i=0; i<NB_PIECES_BOSS; i++ )
|
|
|
|
{
|
|
|
|
Pieces[i*2].P1 = i%NB_PIECES_BOSS; //exterior circle
|
|
|
|
Pieces[i*2].P2 = (i+1)%NB_PIECES_BOSS; //exterior circle
|
|
|
|
Pieces[i*2].P3 = (i+1)%NB_PIECES_BOSS; //interior circle
|
|
|
|
Pieces[i*2].life = 100;
|
|
|
|
Pieces[i*2].toberemoved = false;
|
|
|
|
Pieces[i*2].color = 0xbdf7; //light gray
|
|
|
|
|
|
|
|
Pieces[i*2+1].P1 = i%NB_PIECES_BOSS; //interior circle
|
|
|
|
Pieces[i*2+1].P2 = (i+1)%NB_PIECES_BOSS; //interior circle
|
|
|
|
Pieces[i*2+1].P3 = i%NB_PIECES_BOSS; //exterior circle
|
|
|
|
Pieces[i*2+1].life = 100;
|
|
|
|
Pieces[i*2+1].toberemoved = false;
|
|
|
|
Pieces[i*2+1].color = 0x528a; //darker gray
|
|
|
|
}
|
|
|
|
|
2023-08-22 23:34:18 +02:00
|
|
|
for( int i=0; i<NB_GUNS; i++ )
|
|
|
|
{
|
|
|
|
Guns[i].life = 100;
|
|
|
|
Guns[i].toberemoved = false;
|
|
|
|
}
|
2023-08-13 17:33:25 +02:00
|
|
|
|
2023-08-30 10:01:20 +02:00
|
|
|
accumulatedTime = 0.0f;
|
2023-08-13 17:33:25 +02:00
|
|
|
/* FOR DEBUGGING */
|
|
|
|
// gint_world_switch( GINT_CALL( savedata ) );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Boss::~Boss()
|
|
|
|
{
|
2023-08-23 20:16:30 +02:00
|
|
|
if (hasTrajectory)
|
2023-08-31 09:58:35 +02:00
|
|
|
pathToFollow->DeleteRegistry();
|
2023-08-13 17:33:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Boss::Update( float dt )
|
|
|
|
{
|
2023-08-23 20:16:30 +02:00
|
|
|
|
|
|
|
if (hasTrajectory)
|
|
|
|
{
|
2023-08-30 10:01:20 +02:00
|
|
|
pathToFollow->CalculatePosition( &accumulatedTime, dt, speed, true, &x, &y );
|
2023-08-23 20:16:30 +02:00
|
|
|
}
|
|
|
|
|
2023-08-13 17:33:25 +02:00
|
|
|
xmin = (int) x - width;
|
|
|
|
xmax = (int) x + width;
|
|
|
|
ymin = (int) y - height;
|
|
|
|
ymax = (int) y + height;
|
|
|
|
|
|
|
|
rotAngle += rotSpeed * dt / 25000.0f;
|
|
|
|
if (rotAngle>360.0f) rotAngle-=360.0f;
|
|
|
|
|
|
|
|
|
2023-08-22 23:34:18 +02:00
|
|
|
/* Management of the shield part of the boss (rotating circles made of triangles)*/
|
2023-08-13 17:33:25 +02:00
|
|
|
uint16_t angleint = (uint16_t) rotAngle;
|
|
|
|
uint16_t angledelta = (uint16_t) (360/NB_PIECES_BOSS);
|
|
|
|
|
|
|
|
for( int i=0; i<NB_PIECES_BOSS; i++ )
|
|
|
|
{
|
|
|
|
XdataBossInternal[ i ] = this->x + this->radiusInt * FastCosInt( angleint );
|
|
|
|
YdataBossInternal[ i ] = this->y + this->radiusInt * FastSinInt( angleint );
|
|
|
|
angleint += angledelta;
|
|
|
|
if (angleint>=360) angleint -= 360;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pour le cercle Exterieur on se décale d'un demi-incrément d'angle pour le sommet du triangle
|
|
|
|
angleint = (uint16_t) rotAngle + angledelta/2;
|
|
|
|
if (angleint>=360) angleint -= 360;
|
|
|
|
|
|
|
|
for( int i=0; i<NB_PIECES_BOSS; i++ )
|
|
|
|
{
|
|
|
|
XdataBossExternal[ i ] = this->x + this->radiusExt * FastCosInt( angleint );
|
|
|
|
YdataBossExternal[ i ] = this->y + this->radiusExt * FastSinInt( angleint );
|
|
|
|
angleint += angledelta;
|
|
|
|
if (angleint>=360) angleint -= 360;
|
|
|
|
}
|
|
|
|
|
2023-08-22 23:34:18 +02:00
|
|
|
/* Management of the Guns part of the boss (rotating cannons made of sprites)*/
|
|
|
|
|
|
|
|
angledelta = (uint16_t) (360/NB_GUNS);
|
|
|
|
angleint = (uint16_t) rotAngle + angledelta/2;
|
|
|
|
if (angleint>=360) angleint -= 360;
|
|
|
|
|
|
|
|
for( int i=0; i<NB_GUNS; i++ )
|
|
|
|
{
|
|
|
|
xGuns[i] = this->x + (this->radiusInt + this->radiusExt) / 2 * FastCosInt( angleint );
|
|
|
|
yGuns[i] = this->y + (this->radiusInt + this->radiusExt) / 2 * FastSinInt( angleint );
|
|
|
|
angleint += angledelta;
|
|
|
|
if (angleint>=360) angleint -= 360;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t tempshoot = rtc_ticks();
|
|
|
|
|
|
|
|
bool hasExternalGun = false;
|
|
|
|
|
|
|
|
if (Shoot_OK( tempshoot, BULLET_ENEMY_RED ))
|
|
|
|
{
|
|
|
|
/* shoot from the rotating cannons (aiming directly the position of the player )*/
|
|
|
|
for( int i=0; i<NB_GUNS; i++ )
|
|
|
|
{
|
|
|
|
if (Guns[i].toberemoved==false)
|
|
|
|
{
|
|
|
|
Vector2D shootDirection( MyPlayer->x - xGuns[i], MyPlayer->y - yGuns[i] );
|
|
|
|
shootDirection.Normalise();
|
|
|
|
|
2023-08-23 20:16:30 +02:00
|
|
|
Bullet *b = new Bullet( xGuns[i] , yGuns[i], shootDirection.x, shootDirection.y, BULLET_ENEMY_RED );
|
2023-08-22 23:34:18 +02:00
|
|
|
MyEnemiesBullets.push_back( b );
|
|
|
|
|
|
|
|
hasExternalGun = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasExternalGun==false)
|
|
|
|
if(Shoot_OK( tempshoot, BULLET_ENEMY_GREEN ))
|
|
|
|
{
|
|
|
|
/* central shoot from the main ship only if no more other gun shooting */
|
|
|
|
|
|
|
|
Bullet *b0 = new Bullet( xmin, (int) y, -3, 0, BULLET_ENEMY_GREEN );
|
|
|
|
MyEnemiesBullets.push_back( b0 );
|
|
|
|
|
|
|
|
Bullet *b1 = new Bullet( xmin, (int) y, -2, -2, BULLET_ENEMY_BLUE );
|
|
|
|
MyEnemiesBullets.push_back( b1 );
|
|
|
|
|
|
|
|
Bullet *b2 = new Bullet( xmin, (int) y, -2, 2, BULLET_ENEMY_BLUE );
|
|
|
|
MyEnemiesBullets.push_back( b2 );
|
|
|
|
|
|
|
|
Bullet *b3 = new Bullet( xmin, (int) y, -3, -1, BULLET_ENEMY_GREEN );
|
|
|
|
MyEnemiesBullets.push_back( b3 );
|
|
|
|
|
|
|
|
Bullet *b4 = new Bullet( xmin, (int) y, -3, 1, BULLET_ENEMY_GREEN );
|
|
|
|
MyEnemiesBullets.push_back( b4 );
|
|
|
|
}
|
2023-08-13 17:33:25 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Boss::Render( void )
|
|
|
|
{
|
|
|
|
|
2023-08-22 23:34:18 +02:00
|
|
|
if (toberemoved==false)
|
2023-08-13 17:33:25 +02:00
|
|
|
{
|
|
|
|
for( int i=0; i<NB_PIECES_BOSS; i++ )
|
|
|
|
{
|
|
|
|
if (Pieces[i*2].toberemoved == false)
|
2023-08-14 14:22:53 +02:00
|
|
|
{
|
2023-08-13 17:33:25 +02:00
|
|
|
azrp_triangle( (int) XdataBossExternal[ Pieces[i*2].P1 ], (int) YdataBossExternal[ Pieces[i*2].P1 ],
|
|
|
|
(int) XdataBossExternal[ Pieces[i*2].P2 ], (int) YdataBossExternal[ Pieces[i*2].P2 ],
|
|
|
|
(int) XdataBossInternal[ Pieces[i*2].P3 ], (int) YdataBossInternal[ Pieces[i*2].P3 ],
|
|
|
|
Pieces[i*2].color );
|
2023-08-14 14:22:53 +02:00
|
|
|
|
|
|
|
#if(DEBUG_MODE)
|
|
|
|
dfont( &milifont_prop );
|
|
|
|
int X = (int) ((XdataBossExternal[ Pieces[i*2].P1 ] + XdataBossExternal[ Pieces[i*2].P2 ] + XdataBossInternal[ Pieces[i*2].P3 ]) / 3);
|
|
|
|
int Y = (int) ((YdataBossExternal[ Pieces[i*2].P1 ] + YdataBossExternal[ Pieces[i*2].P2 ] + YdataBossInternal[ Pieces[i*2].P3 ]) / 3);
|
|
|
|
azrp_print( X, Y, C_WHITE, "%d", Pieces[i*2].life );
|
|
|
|
#endif
|
2023-08-13 17:33:25 +02:00
|
|
|
|
2023-08-14 14:22:53 +02:00
|
|
|
}
|
2023-08-13 17:33:25 +02:00
|
|
|
if (Pieces[i*2+1].toberemoved == false)
|
2023-08-14 14:22:53 +02:00
|
|
|
{
|
2023-08-13 17:33:25 +02:00
|
|
|
azrp_triangle( (int) XdataBossInternal[ Pieces[i*2+1].P1 ], (int) YdataBossInternal[ Pieces[i*2+1].P1 ],
|
|
|
|
(int) XdataBossInternal[ Pieces[i*2+1].P2 ], (int) YdataBossInternal[ Pieces[i*2+1].P2 ],
|
|
|
|
(int) XdataBossExternal[ Pieces[i*2+1].P3 ], (int) YdataBossExternal[ Pieces[i*2+1].P3 ],
|
|
|
|
Pieces[i*2+1].color );
|
2023-08-14 14:22:53 +02:00
|
|
|
|
|
|
|
#if(DEBUG_MODE)
|
|
|
|
dfont( &milifont_prop );;
|
|
|
|
int X = (int) ((XdataBossInternal[ Pieces[i*2+1].P1 ] + XdataBossInternal[ Pieces[i*2+1].P2 ] + XdataBossExternal[ Pieces[i*2+1].P3 ]) / 3);
|
|
|
|
int Y = (int) ((YdataBossInternal[ Pieces[i*2+1].P1 ] + YdataBossInternal[ Pieces[i*2+1].P2 ] + YdataBossExternal[ Pieces[i*2+1].P3 ]) / 3);
|
|
|
|
azrp_print( X, Y, C_WHITE, "%d", Pieces[i*2+1].life );
|
|
|
|
#endif
|
|
|
|
}
|
2023-08-13 17:33:25 +02:00
|
|
|
}
|
|
|
|
|
2023-08-22 23:34:18 +02:00
|
|
|
|
|
|
|
for( int i=0; i<NB_GUNS; i++ )
|
|
|
|
{
|
|
|
|
if (Guns[i].toberemoved==false)
|
|
|
|
{
|
|
|
|
azrp_image_p8_effect( (int) xGuns[i] - img_BossGun.width/2,
|
|
|
|
(int) yGuns[i] - img_BossGun.height/2,
|
|
|
|
&img_BossGun, DIMAGE_NONE);
|
|
|
|
|
|
|
|
#if(DEBUG_MODE)
|
|
|
|
dfont( &milifont_prop );;
|
|
|
|
int X = (int) xGuns[i] - img_BossGun.width/2 + 15 ;
|
|
|
|
int Y = (int) yGuns[i] - img_BossGun.height/2 +15;
|
|
|
|
azrp_print( X, Y, C_WHITE, "%d", Guns[i].life );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-13 17:33:25 +02:00
|
|
|
azrp_image_p8_effect(xmin, ymin, &img_Boss1, DIMAGE_NONE);
|
|
|
|
|
2023-08-22 23:34:18 +02:00
|
|
|
|
2023-08-13 17:33:25 +02:00
|
|
|
if (life>life0*2/3) azrp_subimage_p8_effect((int) x - img_Lifebar.width/2, ymin - 9, &img_Lifebar, 0, 7, (img_Lifebar.width*life)/life0, 5, DIMAGE_NONE );
|
|
|
|
else if (life>life0/3) azrp_subimage_p8_effect((int) x - img_Lifebar.width/2, ymin - 9, &img_Lifebar, 0, 12, (img_Lifebar.width*life)/life0, 5, DIMAGE_NONE );
|
|
|
|
else azrp_subimage_p8_effect((int) x - img_Lifebar.width/2, ymin - 9, &img_Lifebar, 0, 17, (img_Lifebar.width*life)/life0, 5, DIMAGE_NONE );
|
2023-08-22 23:34:18 +02:00
|
|
|
|
2023-08-13 17:33:25 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Boss::Test_Impact( Bullet *projectile )
|
|
|
|
{
|
2023-08-22 23:34:18 +02:00
|
|
|
/* We check if the bullet collides with teh shield of the boss */
|
2023-08-13 17:33:25 +02:00
|
|
|
for( int i=0; i< NB_PIECES_BOSS; i++ )
|
|
|
|
{
|
|
|
|
if (Pieces[i*2].toberemoved == false)
|
|
|
|
{
|
|
|
|
if (Is_Point_Inside_Triangle( (int) projectile->x, (int) projectile->y,
|
|
|
|
(int) XdataBossExternal[ Pieces[i*2].P1 ], (int) YdataBossExternal[ Pieces[i*2].P1 ],
|
|
|
|
(int) XdataBossExternal[ Pieces[i*2].P2 ], (int) YdataBossExternal[ Pieces[i*2].P2 ],
|
|
|
|
(int) XdataBossInternal[ Pieces[i*2].P3 ], (int) YdataBossInternal[ Pieces[i*2].P3 ] ))
|
|
|
|
{
|
|
|
|
Pieces[i*2].life -= projectile->strength;
|
|
|
|
if (Pieces[i*2].life<=0)
|
|
|
|
{
|
|
|
|
Pieces[i*2].toberemoved = true;
|
|
|
|
Create_Explosion( (int) projectile->x, (int) projectile->y );
|
|
|
|
}
|
|
|
|
projectile->toberemoved = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Pieces[i*2+1].toberemoved == false)
|
|
|
|
{
|
|
|
|
if (Is_Point_Inside_Triangle( (int) projectile->x, (int) projectile->y,
|
|
|
|
(int) XdataBossInternal[ Pieces[i*2+1].P1 ], (int) YdataBossInternal[ Pieces[i*2+1].P1 ],
|
|
|
|
(int) XdataBossInternal[ Pieces[i*2+1].P2 ], (int) YdataBossInternal[ Pieces[i*2+1].P2 ],
|
|
|
|
(int) XdataBossExternal[ Pieces[i*2+1].P3 ], (int) YdataBossExternal[ Pieces[i*2+1].P3 ] ))
|
|
|
|
{
|
|
|
|
Pieces[i*2+1].life -= projectile->strength;
|
|
|
|
if (Pieces[i*2+1].life<=0)
|
|
|
|
{
|
|
|
|
Pieces[i*2+1].toberemoved = true;
|
|
|
|
Create_Explosion( (int) projectile->x, (int) projectile->y );
|
|
|
|
}
|
|
|
|
projectile->toberemoved = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-22 23:34:18 +02:00
|
|
|
/* We check if the bullet collides with the cannons of the boss */
|
|
|
|
for( int i=0; i<NB_GUNS; i++ )
|
|
|
|
{
|
|
|
|
if (Guns[i].toberemoved==false)
|
|
|
|
{
|
|
|
|
if (projectile->x >= (int) xGuns[i] - img_BossGun.width/2 &&
|
|
|
|
projectile->x <= (int) xGuns[i] + img_BossGun.width/2 &&
|
|
|
|
projectile->y >= (int) yGuns[i] - img_BossGun.height/2 &&
|
|
|
|
projectile->y <= (int) yGuns[i] + img_BossGun.height/2 )
|
|
|
|
{
|
|
|
|
Guns[i].life -= projectile->strength;
|
|
|
|
if (Guns[i].life<0)
|
|
|
|
{
|
|
|
|
Guns[i].toberemoved = true;
|
|
|
|
Create_Explosion( (int) projectile->x, (int) projectile->y );
|
|
|
|
}
|
|
|
|
projectile->toberemoved = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We check if the bullet collides with the main ship part of the boss */
|
2023-08-13 17:33:25 +02:00
|
|
|
if (projectile->x >= xmin && projectile->x <= xmax && projectile->y >= ymin && projectile->y <= ymax )
|
|
|
|
{
|
|
|
|
life -= projectile->strength;
|
2023-08-22 23:34:18 +02:00
|
|
|
if (life<0)
|
|
|
|
{
|
|
|
|
this->toberemoved = true;
|
|
|
|
Create_Explosion( (int) projectile->x, (int) projectile->y );
|
|
|
|
}
|
2023-08-13 17:33:25 +02:00
|
|
|
projectile->toberemoved = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else return false;
|
|
|
|
}
|
|
|
|
|
2023-08-22 23:34:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
bool Boss::Shoot_OK( uint32_t tempshoot, uint8_t shootID )
|
|
|
|
{
|
|
|
|
if (shootID==BULLET_ENEMY_RED)
|
|
|
|
{
|
2023-08-23 20:16:30 +02:00
|
|
|
if(tempshoot-lastshoot0>1)
|
2023-08-22 23:34:18 +02:00
|
|
|
{
|
|
|
|
lastshoot0=tempshoot;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else return false;
|
|
|
|
}
|
|
|
|
else if (shootID==BULLET_ENEMY_GREEN)
|
|
|
|
{
|
2023-08-23 20:16:30 +02:00
|
|
|
if(tempshoot-lastshoot1>1)
|
2023-08-22 23:34:18 +02:00
|
|
|
{
|
|
|
|
lastshoot1=tempshoot;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else return false;
|
|
|
|
}
|
|
|
|
else return false;
|
|
|
|
|
|
|
|
}
|