InvasionSeanchans/BoatControlPerso.cpp

185 lines
9.0 KiB
C++

#include "..\C-Engine\CHeader.hpp"
#include"BoatControl.hpp"
#include "BoatControlPerso.hpp"
extern "C"
{
#include <math.h>
}
void BoatControlPerso::Start()
{
StartBoat();
BateauActuelle->VoilesLateralle.Pourcentage = 0;//On set les voiles à 0.
BateauActuelle->VoilesLongitudinal.Pourcentage = 0;
BateauActuelle->masse = 500;//Il pèse 500 kg.
VentActuelle->direction = 180; //Direction du vent et force
VentActuelle->force = 3;
BateauActuelle->CanonDroit.couldown = 100;
BateauActuelle->CanonGauche.couldown = 100;
BateauActuelle->viemax = 30;//Vie max du joueur 30 pt de vie.
BateauActuelle->vie = BateauActuelle->viemax ;
}
void BoatControlPerso::Update()
{
UpdateBoat();
int nbpirate = CheckBoat();
if(input_trigger(K_EXIT))GetEngine()->StopGame();//Bouton quitté.
if(input_trigger(K_VARS))Fire(90);//Bouton pour tirer.
if(input_trigger(K_SHIFT))Fire(-90);
if(input_trigger(K_POW))AfficherMap();// Bouton pour afficher la map
switch(input_dir4())//Bouton pour tourner le bateau.
{
case 6:
Turn(-2);
break;
case 4:
Turn(2);
break;
default: break;
}
if(input_press(K_F4))//Boutons pour lever ou descendre les voiles.
{
BateauActuelle->VoilesLongitudinal.Pourcentage = BateauActuelle->VoilesLongitudinal.Pourcentage - 5;
}
if(input_press(K_F5))
{
BateauActuelle->VoilesLongitudinal.Pourcentage = BateauActuelle->VoilesLongitudinal.Pourcentage + 5;
}
if(input_press(K_F2))
{
BateauActuelle->VoilesLateralle.Pourcentage = BateauActuelle->VoilesLateralle.Pourcentage - 5;
}
if(input_press(K_F3))
{
BateauActuelle->VoilesLateralle.Pourcentage = BateauActuelle->VoilesLateralle.Pourcentage + 5;
}
Object * Buffer = GetObject()->CollisionTagO("BouletP");
if(Buffer != NULL) // Si on se prend un boulet alors on perd une vie.
{
GetEngine()->DelObject(Buffer);
BateauActuelle->vie --;
}
GetEngine()->MiddleScreen( GetX() + 25, (GetY() + 8));//On place la caméra centré sur le joueur.
PrintV(1,2,objectifmax - nbpirate);//Afficher le nombre de bateaux pirate détruit
ML_line(6,6,8,1,ML_BLACK);
PrintV(10,2,objectifmax);
PrintV(88 , 2 , GetX());//On affiche nos cordonnées.
PrintV(88 , 10 , GetY());
if(nbpirate <= 0)//Si il n'y a plus de pirate alors gagné.
{
GetEngine()->StopGame();
while(input_trigger(K_EXE) == 0)
{
input_update();
ML_clear_vram();
PrintXY(13 , 28 , "Mission Reussi !!!" , 0);
ML_display_vram();
}
}
if( BateauActuelle->vie <= 0)//Si plus de vie alors perdu.
{
GetEngine()->StopGame();
while(input_trigger(K_EXE) == 0)
{
input_update();
ML_clear_vram();
PrintXY(5 , 28 , "Vous avez echoue !!!" , 0);
ML_display_vram();
}
}
}
void BoatControlPerso::AfficherMap()
{
bool end = false;//Pour Afficher la map
bool aperso = true;
int x;
int y;
const unsigned char MiniMap[]={0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1c, 0x0, 0x1, 0xc0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x1, 0x0, 0xc0, 0x0, 0x0, 0x0, 0x1c, 0x0, 0x1, 0xf0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x1, 0x0, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0xf8, 0x0, 0x0, 0x1, 0x80, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0xff, 0x80, 0x0, 0x3, 0x0, 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x1, 0xf8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x78, 0x0, 0x0, 0x30, 0x0, 0x1, 0x0, 0x0, 0x0, 0x7e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3f, 0x0, 0x0, 0xe0, 0x0, 0x1, 0x0, 0x0, 0x0, 0xf8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0x80, 0x3, 0x80, 0x0, 0x1, 0x0, 0x0, 0x0, 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0xf0, 0x3, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0, 0x0, 0xb0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf0, 0x0, 0x1, };
x = GetX() * 127 / 1200;
y = 63 - ( GetY() * 63 / 1200);
while(end == false)
{
input_update();
if(input_trigger(K_EXE) || input_trigger(K_POW))end = true;
ML_clear_vram();
ML_bmp_or(MiniMap,0,0,127,63);
if(aperso == true)
{
ML_point( x , y , 1 , ML_BLACK);
aperso = false;
}
else
{
ML_point( x , y , 1 , ML_WHITE);
aperso = true;
}
ML_display_vram();
Sleep(200);
}
}
int BoatControlPerso::CheckBoat()//Fonction qui renvoie le nombre de bateaux pirate sur la map.
{
int a = 0;
for(int i = 0; i < GetEngine()->nbobject; i++)
{
if( strcmp(GetEngine()->ListeObject[i]->tag , "Pirate") == 0)
{
a++;
}
}
return a;
}