Ajout de plein de monstres XD

This commit is contained in:
Fife 2016-07-12 18:10:22 +01:00
parent 7a3d3e6326
commit ae1ba14757
12 changed files with 914 additions and 156 deletions

41
GUI.cpp
View File

@ -12,6 +12,7 @@ void Script_GUI::Start()
vie = 6;
restart = 4;
score = 0;
timer = 500;
}
@ -50,6 +51,14 @@ void Script_GUI::Update()
if(vie < 5)ML_rectangle(87,60,89,61, 1 , ML_BLACK , ML_BLACK);
if(vie < 6)ML_rectangle(93,60,95,61, 1 , ML_BLACK , ML_BLACK);
ML_rectangle(114,-1,129,7,1,ML_BLACK, ML_WHITE);
ML_pixel(114,7,ML_WHITE);
if(timer / 100)
PrintV(116,1,timer);
else if(timer / 10)
PrintV(120,1,timer);
else
PrintV(124,1,timer);
ML_bmp_or(Keby , 102 , 57 , 16 , 7);
@ -59,6 +68,18 @@ void Script_GUI::Update()
if(input_press(K_ALPHA))GetEngine()->ShowFps();
}
void Script_GUI::UpdateEverySecond()
{
timer --;
if(timer < 0)
{
vie = 0;
restart = 0;
Lose();
}
}
void Script_GUI::DelVie(int v)
{
@ -71,6 +92,11 @@ void Script_GUI::DelVie(int v)
}
}
int Script_GUI::GetVie()
{
return vie;
}
void Script_GUI::AddScore(int v)
{
if(v > 0)score += v;
@ -137,7 +163,18 @@ void Script_GUI::Lose()
TryAgain();
}
Kirby->GetTransform()->SetXY(8, 32);
switch(Kirby->GetEngine()->GetIdCurrentLevel())
{
default: Kirby->GetTransform()->SetXY(8, 32); break;
case 0: Kirby->GetTransform()->SetXY(8, 32); break;
case 1: Kirby->GetTransform()->SetXY(8 , 16 ); break;
case 2: Kirby->GetTransform()->SetXY(96 , 32); break;
case 3: Kirby->GetTransform()->SetXY(16 , 336 ); break;
case 4: Kirby->GetTransform()->SetXY(112 , 48); break;
}
}
void Script_GUI::TryAgain()
@ -210,6 +247,8 @@ void Script_GUI::TryAgain()
if(choix == 0)
{
this->restart = 4;
vie = 6;
timer = 500;
score = score / 2 ;
}

View File

@ -9,8 +9,10 @@ class Script_GUI: public Script
void Start();
void Update();
void UpdateEverySecond();
void DelVie(int v);
int GetVie();
void AddScore(int v);
void Lose();
@ -21,6 +23,7 @@ class Script_GUI: public Script
int score;//Sc: 0
int vie;//Nb de vie
int restart;//Restart * 4
int timer;
};

114
IA_Bomber.cpp Normal file
View File

@ -0,0 +1,114 @@
#include "IA_Bomber.hpp"
Mob_Bomber::Mob_Bomber()
{
direction = false;
needtoback = false;
choix = 0;
life = 3;
}
void Mob_Bomber::Update()
{
isground = CollisionDecor( GetX() , GetY() - 1 );
switch(choix)
{
case 0:
break;
case 1:
if(needtoback)Move(3,0);
else Move(-3,0);
if(isground && needtoback)
{
choix = 0;
needtoback = false;
return;
}
if(isground && !needtoback)
{
needtoback = true;
GetBody()->velocity.y = 40;
}
break;
case 2:
if(isground)
{
choix = 0;
Object * Buffer = new Object;
Ia_Bomb * Buffer_Script = new Ia_Bomb;
Buffer->AffectScript(Buffer_Script);
Buffer->GetTransform()->SetXY( GetX() - 16 , GetY() + 1);
Buffer->GetRender()->SetRender(A_Bomb);
Buffer->AddRigidBody();
Buffer->AffectTag("Ennemis");
GetEngine()->AddObject(Buffer);
}
break;
default: break;
}
SetIt(choix);
Object * Star = GetObject()->GetObjectCollisionTag("Star");
GetEngine()->UpdateRelativePosition();
int x = GetObject()->GetTransform()->GetRelativeX() + 5;
int y = 64 - GetObject()->GetTransform()->GetRelativeY() - 30;
for(int i = 0 ; i < life ; i++)
{
ML_rectangle( x + i * 4 , y , x + 2 + i * 4, y - 3 , 1 , ML_BLACK , ML_BLACK);
}
if(Star)
{
GetEngine()->DelObject(Star);
life --;
if(life < 1)GetEngine()->DelObject(GetObject());
}
}
void Mob_Bomber::UpdateEverySecond()
{
if(!choix)
{
choix = rand_int(6);
if(choix > 2)choix = 0;
if(choix)
{
GetBody()->velocity.y = 39;
Move(0,1);
}
}
}
void Ia_Bomb::Update()
{
Move(-4,0);
if(CollisionDecor( GetX() - 1 , GetY() ) )GetEngine()->DelObject(GetObject());
}

38
IA_Bomber.hpp Normal file
View File

@ -0,0 +1,38 @@
#ifndef IABOMBER
#define IABOMBER
#include "..\C-Engine\CEngine.hpp"
#include "IA_Monstre.hpp"
// Mob script
class Mob_Bomber: public Mob
{
public:
Mob_Bomber();
void Update();
void UpdateEverySecond();
Animation A_Bomb;
private:
int choix;
bool needtoback;
bool isground;
int life;
};
class Ia_Bomb: public Script
{
public:
void Update();
};
#endif

View File

@ -1,72 +1,104 @@
#include "IA_Monstre.hpp"
void IaOurs::Start()
Mob::Mob()
{
direction = true;
}
void IaOurs::UpdateEverySecond()
{
if(direction == true) direction = false;
else direction = true;
}
void IaOurs::Update()
{
GetObject()->ORender->ReverseRender( direction);
if(direction == true)Move( -1 , 0 );
else Move( 1 , 0 );
}
void IaPiaf::Start()
{
GetObject()->ORender->ReverseRender(true);
couldown = 0;
}
void IaPiaf::Update()
void Mob::SetDirection( bool d)
{
if( GetObject()->ORigibody->CollisionDecor( GetX() , (GetY() - 1 )) == 1)
direction = d;
}
void Mob::SetCouldown( int c)
{
couldown = c;
}
void Mob_InLine::Update()
{
if(direction)
{
Move( - 1 , 0 );
if(CollisionDecor( GetX() - 1 , GetY() )) direction = false;
}
else
{
Move( 1 , 0 );
if(CollisionDecor( GetX() + 1 , GetY() )) direction = true;
}
ReverseRender(direction);
}
void Mob_InLine_Jump::UpdateEverySecond()
{
if(couldown < 0)
{
GetBody()->velocity.y = 25 ;
couldown = 80 ;
}
couldown --;
}
void Mob_InLine_Fly::Update()
{
if(direction)
{
Move( - 2 , 0 );
if(CollisionDecor( GetX() - 1 , GetY() )) direction = false;
}
else
{
Move( 2 , 0 );
if(CollisionDecor( GetX() + 1 , GetY() )) direction = true;
}
GetBody()->velocity.y = 9;
ReverseRender(direction);
}
void Mob_Piaf::Update()
{
if( CollisionDecor( GetX() , (GetY() - 1 )))
SetIt(0);
else
SetIt(1);
ReverseRender(direction);
}
void IaPiaf::UpdateEverySecond()
void Mob_Piaf::UpdateEverySecond()
{
if( GetObject()->ORigibody->CollisionDecor( GetX() , (GetY() - 1 )) == 1 && couldown == 0)
{
GetObject()->ORigibody->R_body.velocity.y = 25;
}
if( CollisionDecor( GetX() , (GetY() - 1 )) && !couldown )
GetBody()->velocity.y = 25;
couldown ++;
couldown --;
if(couldown > 3)couldown = 0;
if(couldown < 0)couldown = 4;
}
void IaChamp::Start()
{
time = 0;
}
void IaChamp::Update()
void Mob_Champ::Update()
{
time ++;
couldown --;
if(time > 50)
if(couldown < 0)
{
if(direction == true) direction = false;
else direction = true;
if(direction)
direction = false;
else
direction = true;
GetObject()->ORigibody->R_body.velocity.y = 20;
GetBody()->velocity.y = 20;
time = 0;
couldown = 50;
}
GetObject()->ORender->ReverseRender(direction);
ReverseRender(direction);
}

View File

@ -1,48 +1,57 @@
#ifndef IAMONSTRE
#define IAMONSTRE
#include "..\C-Engine\CHeader.hpp"
#include "..\C-Engine\CEngine.hpp"
// Mob script
class IaOurs: public Script
class Mob: public Script
{
public:
public :
void Start();
void Update();
void UpdateEverySecond();
Mob();
private:
void SetDirection( bool d);
void SetCouldown( int c);
bool direction;
bool direction;
int couldown;
};
class IaPiaf: public Script
class Mob_InLine: public Mob
{
public:
void Start();
void Update();
void UpdateEverySecond();
private:
int couldown;
};
class IaChamp: public Script
class Mob_InLine_Jump: public Mob_InLine
{
public:
void Start();
void UpdateEverySecond();
};
class Mob_InLine_Fly: public Mob_InLine
{
public:
void Update();
};
private:
class Mob_Piaf: public Mob
{
public:
int time;
bool direction;
void Update();
void UpdateEverySecond();
};
class Mob_Champ: public Mob
{
public:
void Update();
};
#endif

185
IA_Whispy.cpp Normal file
View File

@ -0,0 +1,185 @@
#include "IA_Whispy.hpp"
Mob_Whispy::Mob_Whispy()
{
direction = false;
choix = 0;
life = 6;
couldown = 0;
}
void Mob_Whispy::Update()
{
switch(choix)
{
case 0:
SetIt(0);
break;
case 1:
SetIt(0);
if(!rand_int(80))
{
Object * Buffer = new Object;
Ia_Apple * Buffer_Script = new Ia_Apple;
Buffer->AffectScript(Buffer_Script);
Buffer->GetTransform()->SetXY( rand_int_ab(16,80) , 140);
Buffer->AddRigidBody();
Buffer->GetRigidBody()->SetMass(1);
Buffer->GetRender()->SetRender(A_Apple);
Buffer->AffectTag("Ennemis");
GetEngine()->AddObject(Buffer);
couldown --;
}
if(!couldown)choix = 0;
break;
case 2:
SetIt(1);
if(!rand_int(50))
{
Object * Buffer = new Object;
Ia_Souffle * Buffer_Script = new Ia_Souffle;
Buffer->AffectScript(Buffer_Script);
Buffer->GetTransform()->SetXY( GetX() - 16 , GetY() + 2);
Buffer->AddRigidBody();
Buffer->GetRender()->SetRender(A_Souffle);
Buffer->GetRender()->ReverseRender(true);
Buffer->AffectTag("Boss");
GetEngine()->AddObject(Buffer);
couldown --;
}
if(!couldown)choix = 0;
break;
case 3:
SetIt(2);
couldown--;
if(!couldown)choix = 0;
break;
default: break;
}
GetEngine()->UpdateRelativePosition();
int x = GetObject()->GetTransform()->GetRelativeX() + 16;
int y = 64 - GetObject()->GetTransform()->GetRelativeY() + 6;
for(int i = 0 ; i < life ; i++)
{
ML_rectangle( x + i * 4 , y , x + 2 + i * 4, y - 3 , 1 , ML_BLACK , ML_BLACK);
}
Object * Star = GetObject()->GetObjectCollisionTag("Star");
if(Star)
{
GetEngine()->DelObject(Star);
life --;
choix = 3;
couldown = 35;
if(life < 1)
{
choix = -1;
SetIt(2);
GetObject()->AffectTag(" ");
}
}
}
void Mob_Whispy::UpdateEverySecond()
{
Object * Kirby;
for(int i = 0 ; i < GetEngine()->GetCurrentLevel()->GetNbObject() ; i++ )
{
if(!strcmp(GetEngine()->GetCurrentLevel()->GetListeObject()[i]->GetTag(), "Kirby"))Kirby = GetEngine()->GetCurrentLevel()->GetListeObject()[i];
}
int y = Kirby->GetTransform()->GetY();
if(!choix && y < 200)
{
choix = rand_int(6);
if(choix > 2)choix = 0;
couldown = 3;
}
}
Ia_Apple::Ia_Apple()
{
rebond = 1;
}
void Ia_Apple::Update()
{
const unsigned char Arrow[]={0xff, 0xff, 0x6f, };
if(!GetObject()->IsOnScreen() && GetY() > 32)
{
ML_bmp_or_cl(Arrow,GetObject()->GetTransform()->GetRelativeX() + 6 , 1 , 4 , 3);
}
GetObject()->GetRender()->SetDirection(GetObject()->GetRender()->GetDirection() + 20);
if(CollisionDecor( GetX() , GetY() - 1 ) )
{
if(rebond)
{
GetBody()->velocity.y = 12;
GetBody()->velocity.x = 12;
rebond --;
}
else
{
GetEngine()->DelObject(GetObject());
}
}
}
void Ia_Souffle::Update()
{
Move( - 3 , rand_int_ab(-1,1));
if(CollisionDecor( GetX() - 1, GetY() ) )GetEngine()->DelObject(GetObject());
}

53
IA_Whispy.hpp Normal file
View File

@ -0,0 +1,53 @@
#ifndef IAWHISPY
#define IAWHISPY
#include "..\C-Engine\CEngine.hpp"
#include "IA_Monstre.hpp"
// Mob script
class Mob_Whispy: public Mob
{
public:
Mob_Whispy();
void Update();
void UpdateEverySecond();
Animation A_Souffle;
Animation A_Apple;
private:
int choix;
int life;
int couldown;
};
class Ia_Apple: public Script
{
public:
Ia_Apple();
void Update();
private :
int rebond;
};
class Ia_Souffle: public Script
{
public:
void Update();
};
#endif

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,8 @@
#include "Script_Control.hpp"
#include "IA_Monstre.hpp"
//Kirby script
void Control::Start()
@ -11,6 +13,8 @@ void Control::Start()
isfull = 0;
ishurt = 0;
compteur = 0;
direction = 0;
GetEngine()->AddObject(OAspi);
@ -21,8 +25,10 @@ void Control::Start()
GetObject()->AffectTag("Kirby");
oldx = GetObject()->GetTransform()->GetX();
oldy = GetObject()->GetTransform()->GetY();
oldx = GetX();
oldy = GetY();
boss = false;
}
void Control::Teleport( int x , int y , int level )
@ -42,7 +48,7 @@ void Control::Teleport( int x , int y , int level )
GetEngine()->MoveObject(GetObject(),level);
GetEngine()->MoveObject(OAspi,level);
GetEngine()->SetCurrentLevel(level);
GetObject()->GetTransform()->SetXY(x,y);
SetXY(x,y);
input_update();
}
@ -50,28 +56,36 @@ void Control::Teleport( int x , int y , int level )
void Control::Update()
{
if(GetEngine()->GetIdCurrentLevel() < 3)GenerateMonster();
boss = false;
for(int i = 0 ; i < GetEngine()->GetCurrentLevel()->GetNbObject() ; i++ )
{
if(!strcmp(GetEngine()->GetCurrentLevel()->GetListeObject()[i]->GetTag(), "Boss")) boss = true;
}
if(GetEngine()->GetIdCurrentLevel() < 3 && !boss)GenerateMonster();
//Check si on touche le sol ou une plateforme
isground = GetObject()->GetRigidBody()->CollisionDecor( GetObject()->GetTransform()->GetX() , GetObject()->GetTransform()->GetY() - 1 );
isground = CollisionDecor( GetX() , GetY() - 1 );
if(!mod(GetObject()->GetTransform()->GetY() , 16) && GetObject()->GetRigidBody()->GetBody()->velocity.y < 11 )
if(!mod(GetY() , 16) && GetBody()->velocity.y < 11 )
{
int cas1 = GetEngine()->GetCurrentLevel()->GetIdMap( GetObject()->GetTransform()->GetX() , GetObject()->GetTransform()->GetY() - 1 , true );
int cas2 = GetEngine()->GetCurrentLevel()->GetIdMap( GetObject()->GetTransform()->GetX() + 16 , GetObject()->GetTransform()->GetY() - 1 , true );
int cas1 = GetEngine()->GetCurrentLevel()->GetIdMap( GetX() , GetY() - 1 , true );
int cas2 = GetEngine()->GetCurrentLevel()->GetIdMap( GetX() + 16 , GetY() - 1 , true );
if(cas1 == 58)cas1 = 56;
if(cas2 == 58)cas2 = 56;
if(cas1 == 56 || ( mod(GetObject()->GetTransform()->GetX() , 16) && cas2 == 56) )
if(cas1 == 56 || ( mod(GetX() , 16) && cas2 == 56) )
{
GetObject()->GetRigidBody()->GetBody()->velocity.y = 10;
GetBody()->velocity.y = 10;
isground = true;
if(input_press(K_DOWN))
{
GetObject()->GetRigidBody()->GetBody()->velocity.y = - 11;
GetBody()->velocity.y = - 11;
isground = false;
}
}
@ -89,25 +103,26 @@ void Control::Update()
if(ishurt > 15)
{
GetObject()->GetRigidBody()->GetBody()->velocity.x = 40 * ((direction) - (!direction));
GetObject()->GetRigidBody()->GetBody()->velocity.y = 45;
GetBody()->velocity.x = 40 * ((direction) - (!direction));
GetBody()->velocity.y = 45;
}
else
{
GetObject()->GetRigidBody()->GetBody()->velocity.x = 0;
GetObject()->GetRigidBody()->GetBody()->velocity.y = 0;
GetBody()->velocity.x = 0;
GetBody()->velocity.y = 0;
}
ishurt --;
}
else //Sinon le joueur peut le controller
{
Object * Ennemi = GetObject()->GetObjectCollisionTag("Ennemis");
Object * Boss = GetObject()->GetObjectCollisionTag("Boss");
//Test de sui on touche un ennemi
if(Ennemi)
{
GetEngine()->DelObject(Ennemi);
GetEngine()->DelObject(Ennemi,true);
if(!isaspi)
{
@ -116,6 +131,8 @@ void Control::Update()
Interface->AddScore(400);
Interface->DelVie(1);
if(Interface->GetVie() == 6 )ishurt = 0;
}
else
{
@ -125,6 +142,16 @@ void Control::Update()
}
if(Boss)
{
isfull = 0;
ishurt = 20;
Interface->DelVie(1);
if(Interface->GetVie() == 6 )ishurt = 0;
}
//Test de si kirby aspire
if(input_press(K_OPTN) && !isfull)isaspi = true;
@ -136,16 +163,16 @@ void Control::Update()
if(direction)
{
OAspi->GetTransform()->SetXY( GetObject()->GetTransform()->GetX() - 40 , GetObject()->GetTransform()->GetY());
OAspi->GetTransform()->SetXY( GetX() - 40 , GetY());
OAspi->GetRender()->ReverseRender(true);
}
else
{
OAspi->GetTransform()->SetXY( GetObject()->GetTransform()->GetX() + 16 , GetObject()->GetTransform()->GetY());
OAspi->GetTransform()->SetXY( GetX() + 16 , GetY());
OAspi->GetRender()->ReverseRender(false);
}
GetObject()->GetRender()->SetIt(3);
SetIt(3);
isdo = true;
}
@ -155,7 +182,7 @@ void Control::Update()
if(input_trigger(K_OPTN))
{
GetObject()->GetRender()->SetIt(8);
SetIt(8);
Object * Buffer = new Object;
@ -180,6 +207,7 @@ void Control::Update()
Buffer->GetRender()->SetRender(RenderEtoile);
Buffer->AffectScript(ScriptStar);
Buffer->AddRigidBody();
Buffer->AffectTag("Star");
if(!direction)ScriptStar->direction = false;
else ScriptStar->direction = true;
@ -192,46 +220,50 @@ void Control::Update()
if(!direction)
{
Buffer->GetTransform()->SetXY( GetObject()->GetTransform()->GetX() + 16 , GetObject()->GetTransform()->GetY() + 8 );
Buffer->GetTransform()->SetXY( GetX() + 16 , GetY() + 8 );
Buffer->GetRender()->ReverseRender(false);
}
else
{
Buffer->GetTransform()->SetXY( GetObject()->GetTransform()->GetX(), GetObject()->GetTransform()->GetY() + 8 );
Buffer->GetTransform()->SetXY( GetX(), GetY() + 8 );
Buffer->GetRender()->ReverseRender(true);
}
isfull = 0;
isdo = true;
Buffer = NULL;
ScriptSouffle = NULL;
ScriptStar = NULL;
}
//Test des directions
if(input_press(K_RIGHT))
{
GetObject()->GetRigidBody()->Move( 2 , 0 );
Move( 1 + (isfull != 1) , 0 );
direction = false;
if(isfull)
{
if(isground)GetObject()->GetRender()->SetIt(5);
if(isground)SetIt(5);
}
else
GetObject()->GetRender()->SetIt(1);
SetIt(1);
isdo = true;
}
else if(input_press(K_LEFT))
{
GetObject()->GetRigidBody()->Move( -2 , 0 );
Move( - 1 - (isfull != 1) , 0 );
direction = true;
if(isfull)
{
if(isground)GetObject()->GetRender()->SetIt(5);
if(isground)SetIt(5);
}
else
GetObject()->GetRender()->SetIt(1);
SetIt(1);
isdo = true;
}
@ -240,12 +272,12 @@ void Control::Update()
if(input_trigger(K_SHIFT) && isground)
{
GetObject()->GetRigidBody()->GetBody()->velocity.y = 42;
GetBody()->velocity.y = 42;
if(isfull)
GetObject()->GetRender()->SetIt(6);
SetIt(6);
else
GetObject()->GetRender()->SetIt(2);
SetIt(2);
isdo = true;
}
@ -254,23 +286,27 @@ void Control::Update()
if(input_press(K_DOWN) && !isdo && !isfull)
{
GetObject()->GetRender()->SetIt(10);
SetIt(10);
GetObject()->GetRigidBody()->UseFixeBody(16,8);
isdo = true;
}
else
{
GetObject()->GetRigidBody()->UseFixeBody(16,16);
}
if(isfull)
{
if(!isground)
{
if(GetObject()->GetRender()->GetIt() != 6 )GetObject()->GetRender()->SetIt(7);
if(GetObject()->GetRender()->GetIt() != 6 )SetIt(7);
}
else if(!isdo)GetObject()->GetRender()->SetIt(4);
else if(!isdo)SetIt(4);
}
else
{
if(!isground)GetObject()->GetRender()->SetIt(2);
else if(!isdo)GetObject()->GetRender()->SetIt(0);
if(!isground)SetIt(2);
else if(!isdo)SetIt(0);
}
if(input_trigger(K_UP))
@ -278,14 +314,14 @@ void Control::Update()
if(isfull == 1)
{
GetObject()->GetRigidBody()->GetBody()->velocity.y = 35;
GetObject()->GetRender()->SetIt(7);
GetBody()->velocity.y = 35;
SetIt(7);
}
if(!isfull)
{
isfull = 1;
GetObject()->GetRender()->SetIt(9);
SetIt(9);
}
isdo = true;
}
@ -296,14 +332,20 @@ void Control::Update()
GetObject()->GetRender()->ReverseRender(direction);
if( GetObject()->GetTransform()->GetY() < 3)
if( GetY() < 3)
{
isfull = 0;
Interface->DelVie(6);
direction = false;
}
GetEngine()->MiddleScreen( GetObject()->GetTransform()->GetX() + 12, (GetObject()->GetTransform()->GetY() + 16));
if(boss && GetX() > 160)
{
SetX(160);
}
GetEngine()->MiddleScreen( GetX() + 8 , GetY() + 10 );
}
void Control::Initialisation(Animation E, Animation S , Object * A , Script_GUI * G)
@ -318,26 +360,153 @@ void Control::Initialisation(Animation E, Animation S , Object * A , Script_GUI
void Control::GenerateMonster()
{
if(abs(oldx - GetObject()->GetTransform()->GetX()) > 15 || abs(oldy - GetObject()->GetTransform()->GetY()) > 15)
{
if(!rand_int(8))
if(abs(oldx - GetX()) > 15 || abs(oldy - GetY()) > 15)
{
int sgnx = sgn(oldx - GetX());// Si 1 alors le perso se déplace vers la gauche Si -1 alors le perso se déplace vers la droite
int sgny = sgn(oldy - GetY());// Si 1 alors le perso se déplace vers le bas Si -1 alors le perso se déplace vers le ha
if(abs(oldx - GetX()) < 15)sgnx = 0;
if(abs(oldx - GetY()) < 15)sgny = 0;
int needground = true;
oldx = GetX();
oldy = GetY();
if(!rand_int(4))// On détermine si il faut ou non faire poper un monstre. Le nombre diminue en fonction de la difficulté.
{
Object * Buffer = new Object;
Buffer->GetTransform()->SetXY(16,32);
Buffer->AddRigidBody();
Buffer->GetRender()->CopieRender(RenderEtoile);
Buffer->GetRigidBody()->SetMass(1);
Mob_InLine * Buffer_Script1 = new Mob_InLine;
Mob_Piaf * Buffer_Script2 = new Mob_Piaf;
Mob_Champ * Buffer_Script3 = new Mob_Champ;
Mob_InLine_Fly * Buffer_Script4 = new Mob_InLine_Fly;
Mob_InLine * Buffer_Script5 = new Mob_InLine;
Mob_InLine_Jump * Buffer_Script6 = new Mob_InLine_Jump;
switch(rand_int(6))
{
case 0:
Buffer->GetRender()->CopieRender(AOurs);
if(sgnx == -1)
Buffer_Script1->SetDirection(true);
else
Buffer_Script1->SetDirection(false);
Buffer->AffectScript(Buffer_Script1);
break;
case 1:
Buffer->GetRender()->SetRender(APiaf,2);
needground = false;
if(sgnx == -1)
Buffer_Script2->SetDirection(true);
else
Buffer_Script2->SetDirection(false);
Buffer->AffectScript(Buffer_Script2);
break;
case 2:
Buffer->GetRender()->SetRender(AChamp,2);
Buffer->AffectScript(Buffer_Script3);
break;
case 3:
Buffer->GetRender()->CopieRender(AOupa);
needground = false;
if(sgnx == -1)
Buffer_Script4->SetDirection(true);
else
Buffer_Script4->SetDirection(false);
Buffer->AffectScript(Buffer_Script4);
break;
case 4:
Buffer->GetRender()->CopieRender(ABaby);
if(sgnx == -1)
Buffer_Script5->SetDirection(true);
else
Buffer_Script5->SetDirection(false);
Buffer->AffectScript(Buffer_Script5);
break;
case 5:
Buffer->GetRender()->CopieRender(AGhost);
if(sgnx == -1)
Buffer_Script6->SetDirection(true);
else
Buffer_Script6->SetDirection(false);
Buffer->AffectScript(Buffer_Script6);
break;
default:
break;
}
if( Buffer_Script1 != Buffer->GetScript())delete Buffer_Script1;
if( Buffer_Script2 != Buffer->GetScript())delete Buffer_Script2;
if( Buffer_Script3 != Buffer->GetScript())delete Buffer_Script3;
if( Buffer_Script4 != Buffer->GetScript())delete Buffer_Script4;
if( Buffer_Script5 != Buffer->GetScript())delete Buffer_Script5;
if( Buffer_Script6 != Buffer->GetScript())delete Buffer_Script6;
GetEngine()->AddObject(Buffer);
int end = 0;
do
{
do
{
do
{
Buffer->GetTransform()->SetXY( ((oldx - mod(oldx , 16))/16 + rand_int_ab( 8 , 12) * - sgnx ) * 16 , ((oldy - mod(oldy , 16))/16 + rand_int_ab( -2 , 6 ) * - sgny ) * 16 );
end ++;
if(end > 50)
{
GetEngine()->DelObject(Buffer);
return;
}
}
while( Buffer->IsOnScreen());
}
while( needground && ! Buffer->GetRigidBody()->CollisionDecor( Buffer->GetTransform()->GetX() , Buffer->GetTransform()->GetY() - 1) );
}while( Buffer->GetRigidBody()->CollisionDecor( Buffer->GetTransform()->GetX() , Buffer->GetTransform()->GetY()) );
Buffer->AffectTag("Ennemis");
GetEngine()->AddObject(Buffer);
}
Buffer = NULL;
oldx = GetObject()->GetTransform()->GetX();
oldy = GetObject()->GetTransform()->GetY();
}
}
}
void SAspi::Update()
{
Object * Buffer = NULL;
@ -361,8 +530,8 @@ void SSoufle::Update()
{
if(time > 0)
{
if(direction == true)GetObject()->GetTransform()->SetXY( GetObject()->GetTransform()->GetX() - 3 , GetObject()->GetTransform()->GetY() );
else GetObject()->GetTransform()->SetXY( GetObject()->GetTransform()->GetX() + 3 , GetObject()->GetTransform()->GetY() );
if(direction)SetXY( GetX() - 3 , GetY() );
else SetXY( GetX() + 3 , GetY() );
}
time--;
@ -371,8 +540,8 @@ void SSoufle::Update()
if(Buffer != NULL)
{
GetEngine()->DelObject(Buffer);
GetEngine()->DelObject(GetObject());
GetEngine()->DelObject(Buffer,true);
time = -11;
Interface->AddScore(200);
return;
@ -387,37 +556,36 @@ void SSoufle::Update()
void SStar::Update()
{
Object * Buffer = GetObject()->GetObjectCollisionTag("Ennemis");
if(direction == true)
if(Buffer != NULL)
{
GetObject()->GetTransform()->SetXY( GetObject()->GetTransform()->GetX() - 3 , GetObject()->GetTransform()->GetY() );
if(GetObject()->GetRigidBody()->CollisionDecor(GetObject()->GetTransform()->GetX() - 3 , GetObject()->GetTransform()->GetY()))
GetEngine()->DelObject(Buffer);
SetXY(-50,-50);
Interface->AddScore(400);
return;
}
if(direction)
{
SetXY( GetX() - 3 , GetY() );
if(CollisionDecor(GetX() - 3 , GetY()))
{
GetEngine()->DelObject(GetObject());return;
}
}
else
{
GetObject()->GetTransform()->SetXY( GetObject()->GetTransform()->GetX() + 3 , GetObject()->GetTransform()->GetY() );
if(GetObject()->GetRigidBody()->CollisionDecor(GetObject()->GetTransform()->GetX() + 3 , GetObject()->GetTransform()->GetY()))
if(GetObject()->GetRigidBody()->CollisionDecor(GetObject()->GetTransform()->GetX() + 3 , GetObject()->GetTransform()->GetY()))
if(GetObject()->GetRigidBody()->CollisionDecor(GetObject()->GetTransform()->GetX() + 3 , GetObject()->GetTransform()->GetY()))
SetXY( GetX() + 3 , GetY() );
if(CollisionDecor(GetX() + 3 , GetY()))
if(CollisionDecor(GetX() + 3 , GetY()))
if(CollisionDecor(GetX() + 3 , GetY()))
{
GetEngine()->DelObject(GetObject());return;
}
}
Object * Buffer = GetObject()->GetObjectCollisionTag("Ennemis");
if(Buffer != NULL)
{
GetEngine()->DelObject(Buffer);
GetEngine()->DelObject(GetObject());
Interface->AddScore(400);
return;
}
}

View File

@ -46,6 +46,14 @@ class Control: public Script
void Teleport( int x , int y , int level );
void GenerateMonster();
Animation AOurs;
Animation ABaby;
Animation AGhost;
Animation AOupa;
Animation * APiaf;
Animation * AChamp;
private:
bool isground; // Si Touche le sol True
@ -66,6 +74,10 @@ class Control: public Script
Script_GUI * Interface;
int compteur;
bool boss;
};
#endif // SCRIPTCONTROL

File diff suppressed because one or more lines are too long