123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- #include "Helico.h"
- Helico::Helico(SDL_Surface* ecran) : Ennemy(0,ecran),m_vitesse(5+takeRand(5))
- {
- m_helico = SDL_LoadBMP("Images/Helicopter.bmp");
- SDL_SetColorKey(m_helico,SDL_SRCCOLORKEY,SDL_MapRGB(m_helico->format,255,255,255));//On met le fond (blanc) en invisible !
- m_positionHelico.x=takeRand(620);
- m_positionHelico.y=40+takeRand(350);
- }
- Helico::Helico(SDL_Surface* ecran,int vie) : Ennemy(0,ecran,vie),m_vitesse(5+takeRand(5))
- {
- m_helico=SDL_LoadBMP("Images/Helicopter.bmp");
- SDL_SetColorKey(m_helico,SDL_SRCCOLORKEY,SDL_MapRGB(m_helico->format,255,255,255));//On met le fond (blanc) en invisible !
- }
- Helico::Helico(SDL_Surface* ecran, int vie, int antiLatence) : Ennemy(0,ecran,vie),m_vitesse(5+takeRand(5,antiLatence))
- {
- m_helico = SDL_LoadBMP("Images/Helicopter.bmp");
- SDL_SetColorKey(m_helico,SDL_SRCCOLORKEY,SDL_MapRGB(m_helico->format,255,255,255));//On met le fond (blanc) en invisible !
- m_positionHelico.x=takeRand(620,antiLatence);
- m_positionHelico.y=40+takeRand(350,antiLatence);
- }
- Helico::~Helico()
- {
- SDL_FreeSurface(m_helico);
- }
- void Helico::afficher()
- {
- if (m_positionHelico.x<640)
- {
- m_positionHelico.x=m_positionHelico.x+=m_vitesse;
- }
- else
- {
- m_positionHelico.x=0;
- }
- SDL_BlitSurface(m_helico,NULL,m_ecran,&m_positionHelico);
- if (m_tempsFire==0)
- {
- if (m_positionHelico.x+64>m_xFire&&m_xFire>m_positionHelico.x && m_positionHelico.y+32>m_yFire&&m_yFire>m_positionHelico.y)
- {
- switch(m_typeFire)
- {
- case 0:
- this->recevoirDegats(11);
- break;
- case 1:
- this->recevoirDegats(5);
- break;
- case 2:
- this->recevoirDegats(3);
- break;
- }//Switch
- }//Verification position
- }//Si tir
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- BossOne::BossOne(SDL_Surface* ecran,Joueur* cible) : Ennemy(cible,ecran,100)
- {
- m_bossOne=SDL_LoadBMP("Images/HelicopterBossUn.bmp");
- m_tir=SDL_LoadBMP("Images/HelicopterBossUnTir.bmp");
- SDL_SetColorKey(m_bossOne,SDL_SRCCOLORKEY,SDL_MapRGB(m_bossOne->format,255,255,255));
- SDL_SetColorKey(m_tir,SDL_SRCCOLORKEY,SDL_MapRGB(m_tir->format,255,255,255));
- m_positionBoss.x=100;
- m_positionBoss.y=50;
- m_vaVersLeBas=true;
- m_vaVersLaDroite=true;
- m_armeCycle=100;
- }
- BossOne::~BossOne()
- {
- SDL_FreeSurface(m_bossOne);
- }
- void BossOne::afficher()
- {
- //Deplacement
- if (m_vaVersLeBas)
- {
- m_positionBoss.y++;
- if (m_positionBoss.y>324)//480-76-80
- {
- m_vaVersLeBas=false;
- }
- }
- else
- {
- m_positionBoss.y--;
- if (m_positionBoss.y<0)
- {
- m_vaVersLeBas=true;
- }
- }
- if (m_vaVersLaDroite)
- {
- m_positionBoss.x++;
- if (m_positionBoss.x>512)
- {
- m_vaVersLaDroite=false;
- }
- }
- else
- {
- m_positionBoss.x--;
- if (m_positionBoss.x<0)
- {
- m_vaVersLaDroite=true;
- }
- }
- //Collage
- SDL_BlitSurface(m_bossOne,NULL,m_ecran,&m_positionBoss);
- //Gestion des tirs du joueur
- if (m_tempsFire==0)
- {
- if (m_positionBoss.x+128>m_xFire&&m_xFire>m_positionBoss.x && m_positionBoss.y+80>m_yFire&&m_yFire>m_positionBoss.y)
- {
- this->recevoirDegats(10);
- }
- }
- //Gestion des tirs d'helico
- if (!takeRand(50,m_armeCycle))
- {
- m_armeCycle=0;
- m_cible->recevoirDegats(1);
- }
- if (m_armeCycle<5)
- {
- SDL_Rect positionTir;
- positionTir.x=m_positionBoss.x+m_bossOne->w/2-m_tir->w/2;
- positionTir.y=m_positionBoss.y+m_bossOne->h/2-m_tir->h/2;
- SDL_BlitSurface(m_tir,NULL,m_ecran,&positionTir);
- }
- m_armeCycle++;
- }
|