Browse Source

Mise à jour pour le nouveau C-Engine

master
Fife 3 years ago
parent
commit
cc1c05c508
10 changed files with 845 additions and 0 deletions
  1. 22
    0
      GUI.cpp
  2. 20
    0
      GUI.hpp
  3. 134
    0
      GoldQuest.cpp
  4. 178
    0
      Perso.cpp
  5. 31
    0
      Perso.hpp
  6. 176
    0
      Sprites.hpp
  7. 175
    0
      generateur.cpp
  8. 57
    0
      generateur.hpp
  9. 31
    0
      monstres.cpp
  10. 21
    0
      monstres.hpp

+ 22
- 0
GUI.cpp View File

@@ -0,0 +1,22 @@
#include "GUI.hpp"

void GUI:: Start()
{
po = 0;
}

void GUI:: Update()
{
PrintMini(5,5,"PO :",0);
PrintV(25,5,po);
}

void GUI::AddOr(int v)
{
if(v > 0)po += v;
}

void GUI::DelOr(int v)
{
if(v > 0)po -= v;
}

+ 20
- 0
GUI.hpp View File

@@ -0,0 +1,20 @@
#ifndef GQGUI
#define GQGUI

#include "..\C-Engine\CEngine.hpp"

class GUI: public Script
{
public:

void Start();
void Update();
void AddOr(int v);
void DelOr(int v);

private:

int po;
};

#endif // GQGUI

+ 134
- 0
GoldQuest.cpp View File

@@ -0,0 +1,134 @@
#include "..\C-Engine\CEngine.hpp"
#include "generateur.hpp"
#include "monstres.hpp"
#include "GUI.hpp"
#include "Perso.hpp"

int Jeu()
{

//*************Sprites*************\\

#include "Sprites.hpp"

//*************Object*************\\

Object * Perso = new Object;
Perso->GetTransform()->SetXY( 20, 20 );
Perso->GetRender()->SetRender( A_Perso , 9);
Perso->AffectTag("Perso");
Perso->AddRigidBody();

Control * ScriptPerso = new Control;
Perso->AffectScript(ScriptPerso);

Object * epee = new Object;
epee->GetRender ()->SetRender (A_epee);
ScriptPerso->p_epee = epee;

//***********Generateur************\\

MonsterPattern P_Slime("Slime",A_Slime,3,10,10,0);
MonsterPattern P_Tab[]={P_Slime};

Object * GenerateurSlime1 = new Object;
Generateur * ScriptGenerateur1 = new Generateur;
GenerateurSlime1->AffectScript(ScriptGenerateur1);

Object * GenerateurSlime2 = new Object;
Generateur * ScriptGenerateur2 = new Generateur;
GenerateurSlime2->AffectScript(ScriptGenerateur2);

Object * GenerateurSlime3 = new Object;
Generateur * ScriptGenerateur3 = new Generateur;
GenerateurSlime3->AffectScript(ScriptGenerateur3);

ScriptGenerateur1->SetBox(0,156,210,419);
ScriptGenerateur1->ShowBox();
ScriptGenerateur1->SetTab(1,P_Tab);

ScriptGenerateur2->SetBox(322,419,308,419);
ScriptGenerateur2->SetTab(1,P_Tab);

ScriptGenerateur3->SetBox(266,419,0,56);
ScriptGenerateur3->SetTab(1,P_Tab);

//*************Map*************\\

Level * mapPrincipal = new Level;
mapPrincipal->SetMap(tileset , M_mapprincipal, tileprop , 14 , 14 ,30,30);

Level * maison1 = new Level;
maison1->SetMap(tilesethouse, M_maison1 , tileprophouse , 14 , 14 , 15 , 6);

Level * maison2 = new Level;
maison2->SetMap(tilesethouse, M_maison2 , tileprophouse , 14 , 14 , 9 , 6);

Level * maison3 = new Level;
maison3->SetMap(tilesethouse, M_maison3 , tileprophouse , 14 , 14 , 11 , 6);

Level * world[]={mapPrincipal,maison1,maison2,maison3};

Object * Trigger1 = new Object; Trigger1->GetTransform()->SetXY(170,97); Trigger1->AddRigidBody();Trigger1->GetRigidBody()->UseFixeBody(10,2);Trigger1->AffectTag("T1");
Object * Trigger2 = new Object; Trigger2->GetTransform()->SetXY(30,1); Trigger2->AddRigidBody();Trigger2->GetRigidBody()->UseFixeBody(10,2);Trigger2->AffectTag("T2");
Object * Trigger3 = new Object; Trigger3->GetTransform()->SetXY(198,97); Trigger3->AddRigidBody();Trigger3->GetRigidBody()->UseFixeBody(10,2);Trigger3->AffectTag("T3");
Object * Trigger4 = new Object; Trigger4->GetTransform()->SetXY(170,1); Trigger4->AddRigidBody();Trigger4->GetRigidBody()->UseFixeBody(10,2);Trigger4->AffectTag("T4");
Object * Trigger5 = new Object; Trigger5->GetTransform()->SetXY(58,83); Trigger5->AddRigidBody();Trigger5->GetRigidBody()->UseFixeBody(10,2);Trigger5->AffectTag("T5");
Object * Trigger6 = new Object; Trigger6->GetTransform()->SetXY(58,1); Trigger6->AddRigidBody();Trigger6->GetRigidBody()->UseFixeBody(10,2);Trigger6->AffectTag("T6");
Object * Trigger7 = new Object; Trigger7->GetTransform()->SetXY(72,125); Trigger7->AddRigidBody();Trigger7->GetRigidBody()->UseFixeBody(10,2);Trigger7->AffectTag("T7");
Object * Trigger8 = new Object; Trigger8->GetTransform()->SetXY(114,1); Trigger8->AddRigidBody();Trigger8->GetRigidBody()->UseFixeBody(10,2);Trigger8->AffectTag("T8");

//*************Moteur*************\\


Engine Game;

Game.SetLevel(world,4);

Game.AddObject(GenerateurSlime1,0);
Game.AddObject(GenerateurSlime2,0);
Game.AddObject(GenerateurSlime3,0);

Game.AddObject(Perso , 0);
Game.AddObject(epee , 0);

Game.AddObject(Trigger1,0);
Game.AddObject(Trigger2,1);
Game.AddObject(Trigger3,0);
Game.AddObject(Trigger4,1);
Game.AddObject(Trigger5,0);
Game.AddObject(Trigger6,2);
Game.AddObject(Trigger7,0);
Game.AddObject(Trigger8,3);

Game.StartGame();


return 1;
}

extern "C"
{
int AddIn_main(int isAppli, unsigned short OptionNum)
{
Jeu();
return 1;
}
#pragma section _BR_Size


unsigned long BR_Size;
#pragma section


#pragma section _TOP

int InitializeSystem(int isAppli, unsigned short OptionNum)
{
return INIT_ADDIN_APPLICATION(isAppli, OptionNum);
}

#pragma section
}



+ 178
- 0
Perso.cpp View File

@@ -0,0 +1,178 @@

#include "Perso.hpp"

void Control ::Start()
{
couldown = 0;
Vie=40;
BarreVie=0;
VieMax=40;


p_epee->Disable();
p_epee->AffectTag("Epee");
}

void Control::Update()
{
BarreVie=Vie*40/VieMax;
ML_line (126,40,126,40-BarreVie,ML_BLACK);
ML_line (125,1,125,41,ML_BLACK);
ML_line (127,1,127,42,ML_BLACK);
ML_line (125,1,127,1,ML_BLACK);
ML_line (125,41,127,41,ML_BLACK);


Object * Buffer = GetObject()->GetObjectCollisionTag("Slime");
if(Buffer != NULL)
{
Vie--;
int difx = GetObject()->GetTransform()->GetX() - Buffer->GetTransform()->GetX();
int dify = GetObject()->GetTransform()->GetY() - Buffer->GetTransform()->GetY();

GetObject()->GetRigidBody()->Move(difx * 2 ,dify * 2);
}
if (input_trigger(K_SHIFT) || couldown > 0)
{
couldown --;
if(couldown < 0) couldown = 10;

switch (Direction_p)
{
case 1:
GetObject()->GetRender()->SetIt(7);
p_epee->GetTransform()->SetXY(GetObject()->GetTransform()->GetX() + 1,GetObject()->GetTransform()->GetY() + 12);
p_epee->GetRender()->SetDirection(0);
break;
case 2:
GetObject()->GetRender()->SetIt(8);
GetObject()->GetRender()->ReverseRender(true);
p_epee->GetTransform()->SetXY(GetObject()->GetTransform()->GetX()+14,GetObject()->GetTransform()->GetY()-2);
p_epee->GetRender()->SetDirection(270);
break;
case 3:
GetObject()->GetRender()->SetIt(6);
p_epee->GetTransform()->SetXY(GetObject()->GetTransform()->GetX() + 6,GetObject()->GetTransform()->GetY() - 12);
p_epee->GetRender()->SetDirection(180);
break;
case 4:
GetObject()->GetRender()->SetIt(8);
GetObject()->GetRender()->ReverseRender(false);
p_epee->GetTransform()->SetXY(GetObject()->GetTransform()->GetX() - 8,GetObject()->GetTransform()->GetY() - 3);
p_epee->GetRender()->SetDirection(90);
break;
}

p_epee->Enable();
}
else
{
p_epee->Disable();

if(input_press(K_RIGHT))
{
GetObject()->GetRigidBody()->Move(1,0);
GetObject()->GetRender()->SetIt(5);
GetObject()->GetRender()->ReverseRender(true);
Direction_p=2;
}
else if(input_press(K_LEFT))
{
GetObject()->GetRigidBody()->Move(-1,0);
GetObject()->GetRender()->SetIt(5);
GetObject()->GetRender()->ReverseRender(false);
Direction_p=4;
}
else if(input_press(K_UP))
{
GetObject()->GetRigidBody()->Move (0,1);
GetObject()->GetRender()->SetIt(3);
Direction_p=1;
}
else if(input_press(K_DOWN))
{
GetObject()->GetRigidBody()->Move (0,-1);
GetObject()->GetRender()->SetIt(1);
Direction_p=3;
}
else
{
switch (Direction_p)
{
case 1:GetObject()->GetRender()->SetIt(2);break;
case 2:GetObject()->GetRender()->SetIt(4);break;
case 3:GetObject()->GetRender()->SetIt(0);break;
case 4:GetObject()->GetRender()->SetIt(4);break;
}
}
}

if(GetObject()->GetCollisionTag("T1"))
{
GetEngine()->MoveObject(GetObject(),1);
GetEngine()->MoveObject(p_epee,1);
GetEngine()->SetCurrentLevel(1);
GetObject()->GetTransform()->SetXY(29,3);
}

if(GetObject()->GetCollisionTag("T2"))
{
GetEngine()->MoveObject(GetObject(),0);
GetEngine()->MoveObject(p_epee,0);
GetEngine()->SetCurrentLevel(0);
GetObject()->GetTransform()->SetXY(169,86);
}

if(GetObject()->GetCollisionTag("T3"))
{
GetEngine()->MoveObject(GetObject(),1);
GetEngine()->MoveObject(p_epee,1);
GetEngine()->SetCurrentLevel(1);
GetObject()->GetTransform()->SetXY(169,3);
}

if(GetObject()->GetCollisionTag("T4"))
{
GetEngine()->MoveObject(GetObject(),0);
GetEngine()->MoveObject(p_epee,0);
GetEngine()->SetCurrentLevel(0);
GetObject()->GetTransform()->SetXY(197,86);
}

if(GetObject()->GetCollisionTag("T5"))
{
GetEngine()->MoveObject(GetObject(),2);
GetEngine()->MoveObject(p_epee,2);
GetEngine()->SetCurrentLevel(2);
GetObject()->GetTransform()->SetXY(57,3);
}

if(GetObject()->GetCollisionTag("T6"))
{
GetEngine()->MoveObject(GetObject(),0);
GetEngine()->MoveObject(p_epee,0);
GetEngine()->SetCurrentLevel(0);
GetObject()->GetTransform()->SetXY(57,69);
}

if(GetObject()->GetCollisionTag("T7"))
{
GetEngine()->MoveObject(GetObject(),3);
GetEngine()->MoveObject(p_epee,3);
GetEngine()->SetCurrentLevel(3);
GetObject()->GetTransform()->SetXY(113,3);
}

if(GetObject()->GetCollisionTag("T8"))
{
GetEngine()->MoveObject(GetObject(),0);
GetEngine()->MoveObject(p_epee,0);
GetEngine()->SetCurrentLevel(0);
GetObject()->GetTransform()->SetXY(71,113);
}

if (input_press(K_EXIT))GetEngine()->StopGame();

GetEngine()->MiddleScreen(GetObject()->GetTransform()->GetX() + 6 , GetObject()->GetTransform()->GetY() + 6);
}


+ 31
- 0
Perso.hpp View File

@@ -0,0 +1,31 @@


#ifndef GQPERSO
#define GQPERSO

#include "..\C-Engine\CEngine.hpp"
#include "GUI.hpp"

class Control: public Script
{
public:

void Start();
void Update();


GUI * S_GUI;
Object * p_epee;

private:

int couldown;
int Direction_p;
int Vie;
int VieMax;
int BarreVie;

};

#endif // GQPERSO


+ 176
- 0
Sprites.hpp View File

@@ -0,0 +1,176 @@

const unsigned char avant_normale_n[]={0x3f, 0x83, 0x7f, 0xc7, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0x7f, 0xc7, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, };
const unsigned char avant_marche_1_n[]={0x3f, 0x83, 0x7f, 0xc7, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0x7f, 0xc7, 0xff, 0xef, 0xff, 0xef, 0xfc, 0x0, };
const unsigned char avant_marche_2_n[]={0x3f, 0x8f, 0x7f, 0xcf, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0x7f, 0xcf, 0xff, 0xef, 0xff, 0xef, 0x7, 0xef, };

const unsigned char arriere_normale_n[]={0x3f, 0x83, 0x7f, 0xc7, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0x7f, 0xc7, 0xff, 0xef, 0xff, 0xef, 0xff, 0xe0, };
const unsigned char arriere_marche_1_n[]={0x3f, 0x83, 0x7f, 0xc7, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0x7f, 0xc7, 0xff, 0xef, 0xff, 0xef, 0x7, 0xef, };
const unsigned char arriere_marche_2_n[]={0x3f, 0x8f, 0x7f, 0xcf, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0x7f, 0xcf, 0xff, 0xef, 0xff, 0xef, 0xfc, 0xf, };

const unsigned char cote_normal_n[]={0x7f, 0x87, 0xff, 0xcf, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0x7f, 0xc7, 0x3f, 0xc3, 0x3f, 0x7, 0x3e, 0x7, };
const unsigned char cote_marche_1_n[]={0x7f, 0x87, 0xff, 0xcf, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0x7f, 0xc7, 0x3f, 0xc3, 0x7f, 0xe7, 0x79, 0xe7, };
const unsigned char cote_marche_2_n[]={0x7f, 0x8f, 0xff, 0xcf, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0xff, 0xef, 0x7f, 0xcf, 0x3f, 0xcf, 0x7f, 0xef, 0x79, 0xef, };

const unsigned char avant_normale[]={0xff, 0xff, 0xe0, 0xfe, 0xc0, 0x7c, 0x9b, 0x39, 0xb5, 0xbb, 0xb5, 0xbb, 0x9f, 0x39, 0xce, 0x7c, 0xe0, 0xfe, 0xbb, 0xbb, 0x84, 0x38, 0xff, 0xff, };
const unsigned char avant_marche_1[]={0xff, 0xff, 0xe0, 0xfe, 0xc0, 0x7c, 0x9b, 0x39, 0xb5, 0xbb, 0xb5, 0xbb, 0x9f, 0x39, 0xce, 0x7c, 0xe0, 0xfe, 0xbb, 0xbb, 0x87, 0xff, 0xff, 0xff, };
const unsigned char avant_marche_2[]={0xff, 0xff, 0xe0, 0xff, 0xc0, 0x7f, 0x9b, 0x3f, 0xb5, 0xbf, 0xb5, 0xbf, 0x9f, 0x3f, 0xce, 0x7f, 0xe0, 0xff, 0xbb, 0xbf, 0xfc, 0x3f, 0xff, 0xff, };

const unsigned char arriere_normale[]={0xff, 0xff, 0xe0, 0xfe, 0xc0, 0x7c, 0x80, 0x38, 0x80, 0x38, 0x80, 0x38, 0x80, 0x38, 0xc0, 0x7c, 0xe0, 0xfe, 0xbb, 0xbb, 0x84, 0x3f, 0xff, 0xff, };
const unsigned char arriere_marche_1[]={0xff, 0xff, 0xe0, 0xfe, 0xc0, 0x7c, 0x80, 0x38, 0x80, 0x38, 0x80, 0x38, 0x80, 0x38, 0xc0, 0x7c, 0xe0, 0xfe, 0xbb, 0xbb, 0xfc, 0x38, 0xff, 0xff, };
const unsigned char arriere_marche_2[]={0xff, 0xff, 0xe0, 0xff, 0xc0, 0x7f, 0x80, 0x3f, 0x80, 0x3f, 0x80, 0x3f, 0x80, 0x3f, 0xc0, 0x7f, 0xe0, 0xff, 0xbb, 0xbf, 0x87, 0xff, 0xff, 0xff, };

const unsigned char cote_normal[]={0xff, 0xff, 0xf4, 0xff, 0xf4, 0x7f, 0xb4, 0x3b, 0xb4, 0x3b, 0xf4, 0x3f, 0xe8, 0x3e, 0xe8, 0x7e, 0xf0, 0xff, 0xfb, 0xff, 0xe5, 0xfc, 0xff, 0xff, };
const unsigned char cote_marche_1[]={0xff, 0xff, 0xf4, 0xff, 0xf4, 0x7f, 0xb4, 0x3b, 0xb4, 0x3b, 0xf4, 0x3f, 0xe8, 0x3e, 0xe8, 0x7e, 0xf0, 0xff, 0xfb, 0xff, 0xc7, 0xff, 0xf9, 0xff, };
const unsigned char cote_marche_2[]={0xff, 0xff, 0xf4, 0xff, 0xf4, 0x7f, 0xb4, 0x3f, 0xb4, 0x3f, 0xf4, 0x3f, 0xe8, 0x3f, 0xe8, 0x7f, 0xf0, 0xff, 0xfb, 0xff, 0xff, 0x3f, 0xf9, 0xff, };

const unsigned char epee_av[]={0xff, 0xff, 0xe0, 0xff, 0xc0, 0x7f, 0x9b, 0x3f, 0xb5, 0xbf, 0xb5, 0xbf, 0x9f, 0x3f, 0xce, 0x7f, 0xe0, 0xff, 0xbb, 0xff, 0x85, 0xff, 0xff, 0xff, };
const unsigned char epee_av_n[]={0x3f, 0x9f, 0x7f, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,};

const unsigned char epee_ar[]={0xff, 0xff, 0xe0, 0xff, 0xc0, 0x7f, 0x80, 0x3f, 0x80, 0x3f, 0x80, 0x3f, 0x80, 0x3f, 0xc0, 0x7f, 0xe0, 0xff, 0xbb, 0xbf, 0x84, 0x3f, 0xff, 0xff,};
const unsigned char epee_ar_n[]={0x7f, 0x9f, 0xff, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,};
const unsigned char epee_c[]={0xff, 0xff, 0xf4, 0xff, 0xf4, 0x7f, 0xb4, 0x3f, 0xb4, 0x3f, 0xf4, 0x3f, 0xe8, 0x3f, 0xe8, 0x7f, 0xf0, 0xff, 0xfb, 0xff, 0xe5, 0xff, 0xff, 0xff, };
const unsigned char epee_c_n[]={0x7f, 0x9f, 0xff, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xdf, 0x3f, 0x1f, 0x3e, 0x1f, };

const unsigned char epee_normale[]={0xff, 0xdf, 0xdf, 0xdf, 0xdf, 0xdf, 0xdf, 0xdf, 0xff, 0x8f, 0xdf, 0xff};
const unsigned char epee_normale_n[]={0x27, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0xff, 0xff, 0x77, 0x77, };

Sprite S_epee (epee_normale,epee_normale_n,5,12);
Animation A_epee (S_epee);

Sprite S_e_av ( epee_av , epee_av_n,11,12);
Sprite S_e_ar ( epee_ar , epee_ar_n ,11,12);
Sprite S_e_c ( epee_c,epee_c_n ,11,12);S_e_c.CreateReverse();

Animation A_e_av (S_e_av);
Animation A_e_ar (S_e_ar);
Animation A_e_c (S_e_c);

Sprite S_a_n (avant_normale, avant_normale_n,11,12);
Sprite S_a_m1(avant_marche_1,avant_marche_1_n,11,12);
Sprite S_a_m2(avant_marche_2,avant_marche_2_n,11,12);
Sprite S_ar_n(arriere_normale,arriere_normale_n,11,12);
Sprite S_ar_m1(arriere_marche_1,arriere_marche_1_n,11,12);
Sprite S_ar_m2( arriere_marche_2, arriere_marche_2_n,11,12);
Sprite S_c_n(cote_normal,cote_normal_n,11,12);S_c_n.CreateReverse();
Sprite S_c_m1(cote_marche_1,cote_marche_1_n,11,12);S_c_m1.CreateReverse();
Sprite S_c_m2(cote_marche_2,cote_marche_2_n,11,12);S_c_m2.CreateReverse();

Sprite S_marche_a[]={S_a_m1,S_a_n,S_a_m2,S_a_n};
Sprite S_marche_ar[]={S_ar_m1,S_ar_n,S_ar_m2,S_ar_n};
Sprite S_marche_c[]={S_c_m1,S_c_n,S_c_m2,S_c_n};

Animation A_a_n (S_a_n);
Animation A_a_m(S_marche_a,4,200);
Animation A_ar_n(S_ar_n);
Animation A_ar_m(S_marche_ar,4,200);
Animation A_c_n(S_c_n);
Animation A_c_m(S_marche_c,4,200);

Animation A_Perso[]={ A_a_n , A_a_m , A_ar_n , A_ar_m , A_c_n , A_c_m , A_e_av , A_e_ar , A_e_c};

const unsigned char scoffre[]={0xff, 0xff, 0xa9, 0x5f, 0xa9, 0x5f, 0xa9, 0x5f, 0xbf, 0xdf, 0x80, 0x1f, 0xf9, 0xff, 0x89, 0x1f, 0xaf, 0x5f, 0xa0, 0x5f, 0xf0, 0xff, 0xff, 0xff, };

Sprite s_coffre(scoffre , 12 , 12);
Animation A_coffre(s_coffre);

const unsigned char slime0[]={0xfe, 0xee, 0xc6, 0x83, 0xab, 0x83, 0xfe, };
const unsigned char slime1[]={0x11, 0x39, 0x7d, 0xff, 0xff, 0xff, 0x7d, };
const unsigned char slime2[]={0xfe, 0xfe, 0xee, 0xc6, 0xab, 0x83, 0xfe, };
const unsigned char slime3[]={0x1, 0x11, 0x39, 0x7d, 0xff, 0xff, 0x7d, };
const unsigned char slime4[]={0xfe, 0xee, 0xc6, 0x83, 0x83, 0x83, 0xfe, };
const unsigned char slime5[]={0x11, 0x39, 0x7d, 0xff, 0xff, 0xff, 0x7d, };
const unsigned char slime6[]={0xfe, 0xfe, 0xee, 0xc6, 0x83, 0x83, 0xfe, };
const unsigned char slime7[]={0x1, 0x11, 0x39, 0x7d, 0xff, 0xff, 0x7d, };
const unsigned char slime8[]={0xfe, 0xee, 0xc6, 0x83, 0xa3, 0x83, 0xfe, };
const unsigned char slime9[]={0x19, 0x39, 0x7d, 0xff, 0xff, 0xff, 0x7d, };
const unsigned char slime10[]={0xfe, 0xfe, 0xee, 0xc6, 0xa3, 0x83, 0xfe, };
const unsigned char slime11[]={0x1, 0x19, 0x39, 0x7d, 0xff, 0xff, 0x7d, };

Sprite S_Slime1(slime0,slime1,7,7);S_Slime1.CreateReverse();
Sprite S_Slime2(slime2,slime3,7,7);S_Slime2.CreateReverse();
Sprite S_Slime3(slime4,slime5,7,7);S_Slime3.CreateReverse();
Sprite S_Slime4(slime6,slime7,7,7);S_Slime4.CreateReverse();
Sprite S_Slime5(slime8,slime9,7,7);S_Slime5.CreateReverse();
Sprite S_Slime6(slime10,slime11,7,7);S_Slime6.CreateReverse();


Sprite S_SlimeFace[]={S_Slime1,S_Slime2};
Sprite S_SlimeDos[]={S_Slime3,S_Slime4};
Sprite S_SlimeCote[]={S_Slime5,S_Slime6};

Animation A_SlimeFace(S_SlimeFace,2,200);
Animation A_SlimeDos(S_SlimeDos,2,200);
Animation A_SlimeCote(S_SlimeCote,2,200);


Animation A_Slime[]={A_SlimeFace,A_SlimeDos,A_SlimeCote};

const unsigned char tileset[]={0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0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 0x3, 0x0, 0x3, 0x20, 0x13, 0x0, 0x3, 0x0, 0x3, 0x2, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, };

bool tileprop[]={ 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0};

unsigned char M_mapprincipal[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x00,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x14,
0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x12,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x14,0x12,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x05,0x07,0x06,0x00,0x00,0x00,0x09,0x12,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x11,0x01,0x03,0x02,0x00,0x00,0x00,0x09,0x00,0x00,0x14,0x00,0x00,0x14,0x00,
0x00,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x12,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x15,0x15,0x00,0x00,0x00,0x00,0x09,0x00,0x12,0x00,0x00,0x00,0x00,0x00,
0x14,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x0B,0x08,0x08,0x08,0x0C,0x00,0x15,0x00,0x0B,0x08,0x08,0x0C,0x00,0x00,0x00,0x14,0x00,0x12,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x00,0x15,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x00,0x14,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x00,
0x14,0x00,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x15,0x00,0x00,0x15,0x00,0x15,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x15,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x14,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x15,0x00,0x00,0x12,0x00,0x00,0x00,
0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x0C,0x15,0x00,0x0B,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,
0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,
0x09,0x00,0x00,0x05,0x07,0x07,0x06,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x15,0x15,0x14,0x00,0x00,0x00,0x00,
0x09,0x00,0x00,0x01,0x04,0x03,0x02,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x09,0x00,0x00,0x00,0x00,0x15,0x15,0x00,0x15,0x15,0x00,0x05,0x07,0x07,0x07,0x06,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x12,0x00,0x00,
0x09,0x00,0x00,0x05,0x07,0x06,0x00,0x00,0x15,0x00,0x00,0x01,0x03,0x04,0x03,0x02,0x11,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x09,0x00,0x00,0x01,0x03,0x02,0x11,0x00,0x00,0x15,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x0A,0x11,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x14,0x00,0x00,
0x09,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x15,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,
0x09,0x00,0x00,0x00,0x15,0x15,0x00,0x15,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x00,
0x09,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15,0x00,0x00,0x00,0x00,0x00,0x0D,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x00,0x00,
0x09,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x10,0x15,0x15,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x12,0x00,
0x09,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x15,0x15,0x15,0x00,0x09,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x14,0x00,0x00,
0x0B,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0C,0x00,0x00,0x00,0x14,0x00,0x12,0x00,0x00,0x00,0x00,0x00,
};

const unsigned char tilesethouse[]={0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x7, 0x80, 0x7, 0xff, 0xff, 0x80, 0x7, 0xbf, 0xf7, 0xa0, 0x17, 0xa0, 0x17, 0xbf, 0xf7, 0xa0, 0x17, 0xa0, 0x17, 0xbf, 0xf7, 0x80, 0x7, 0xff, 0xff, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x3f, 0xf3, 0x40, 0xb, 0x5f, 0xeb, 0x5f, 0xeb, 0x5f, 0xeb, 0x40, 0xb, 0x40, 0xb, 0x5f, 0xeb, 0x50, 0x2b, 0x50, 0x2b, 0x70, 0x3b, 0x0, 0x3, 0x0, 0x3, 0x7, 0x83, 0x18, 0x63, 0x20, 0x13, 0x40, 0xb, 0x47, 0x8b, 0x68, 0x5b, 0x90, 0x27, 0x90, 0x27, 0x90, 0x27, 0x63, 0x1b, 0x18, 0x63, 0x7, 0x83, 0xff, 0xff, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0xff, 0xff, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0xff, 0xff, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0xff, 0xff, 0x0, 0x3, 0xff, 0xff, 0x90, 0x27, 0xa0, 0x17, 0x90, 0x27, 0xa0, 0x17, 0x90, 0x27, 0xa0, 0x17, 0x90, 0x27, 0xa0, 0x17, 0x90, 0x27, 0xa0, 0x17, 0x90, 0x27, 0xa0, 0x17, 0xff, 0xff, };

bool tileprophouse[]={ 0,1,1,1,1,1,6,};

unsigned char M_maison1[]={
0x01,0x05,0x05,0x05,0x05,0x05,0x05,0x06,0x05,0x05,0x05,0x05,0x05,0x05,0x01,
0x01,0x00,0x00,0x00,0x00,0x02,0x02,0x06,0x02,0x00,0x04,0x00,0x04,0x00,0x01,
0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x03,0x00,0x01,
0x01,0x00,0x00,0x00,0x00,0x03,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x01,0x01,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x01,0x01,
};

unsigned char M_maison2[]={
0x01,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x01,
0x01,0x00,0x00,0x00,0x00,0x02,0x02,0x00,0x01,
0x01,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x01,
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x01,0x00,0x02,0x00,0x00,0x03,0x03,0x00,0x01,
0x01,0x01,0x01,0x01,0x00,0x01,0x01,0x01,0x01,
};

unsigned char M_maison3[]={
0x01,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x01,
0x01,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x02,0x02,0x01,
0x01,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x01,0x04,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x01,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x01,0x01,
};



+ 175
- 0
generateur.cpp View File

@@ -0,0 +1,175 @@


#include "..\C-Engine\CEngine.hpp"
#include "generateur.hpp"
#include "monstres.hpp"

MonsterPattern::MonsterPattern(char * vtag , Animation * vanim, int vanimnb, int vfreq, int vmax, int vidscript)
{
tag = vtag;
anim = vanim;
nbanim = vanimnb;
freq = vfreq;
max = vmax;
idscript = vidscript;
}

Generateur::Generateur()
{
M_nombre = 0;
M_Tag = NULL;
M_Anim = NULL;
M_Anim_nb = NULL;
M_Max = NULL;
M_Frequence = NULL;

active = false;
show = false;
}

void Generateur::ShowBox()
{
show = true;
}

void Generateur::SetBox(int x1 , int x2 , int y1 , int y2)
{
if(x1 > x2)
{
int b = x1;
x1 = x2;
x2 = b;
}

if(y1 > y2)
{
int c = y1;
y1 = y2;
y2 = c;
}

GetObject()->GetTransform()->SetXY(x1,y1);
GetObject()->AddRigidBody();
GetObject()->GetRigidBody()->UseFixeBody(x2-x1,y2-y1);
}

void Generateur::SetTab( int nbmonstre , MonsterPattern * tabpattern)
{
if(nbmonstre > 0 && tabpattern != NULL)
{
M_nombre = nbmonstre;
M_Tag = new char*[M_nombre];
M_Anim = new Animation*[M_nombre];
M_Anim_nb = new int[M_nombre];
M_Max = new int[M_nombre];
M_Frequence = new int[M_nombre];
M_Couldown = new int[M_nombre];
M_Id_Script = new int[M_nombre];

for(int i = 0; i < M_nombre ; i++ )
{
M_Tag[i] = tabpattern[i].tag;
M_Anim[i] = tabpattern[i].anim;
M_Anim_nb[i] = tabpattern[i].nbanim;
M_Max[i] = tabpattern[i].max;
M_Frequence[i] = tabpattern[i].freq;
M_Couldown[i] = 0;
M_Id_Script[i] = tabpattern[i].idscript;
}
}
}

void Generateur::Update()
{
if(GetObject()->GetCollisionTag("Perso"))active = true;
else active = false;

if(show)
{
GetEngine()->UpdateRelativePosition();
ML_rectangle(GetObject()->GetTransform()->GetRelativeX(),63 - GetObject()->GetTransform()->GetRelativeY(),GetObject()->GetTransform()->GetRelativeX() + GetObject()->GetRigidBody()->GetWidht() , 63 - GetObject()->GetTransform()->GetRelativeY() - GetObject()->GetRigidBody()->GetHeight(),1, ML_BLACK , ML_WHITE);
}
}

int Generateur::RandX()
{
int min = GetObject()->GetTransform()->GetX();
int max = GetObject()->GetTransform()->GetX() + GetObject()->GetRigidBody()->GetWidht();

return rand_int_ab( min , max );
}

int Generateur::RandY()
{
int min = GetObject()->GetTransform()->GetY();
int max = GetObject()->GetTransform()->GetY() + GetObject()->GetRigidBody()->GetHeight();

return rand_int_ab( min , max );
}

void Generateur::CreateMonster(int id)
{
Object * Buffer = new Object;
Buffer->GetTransform()->SetXY( RandX() , RandY() );
Buffer->AffectTag(M_Tag[id]);
Buffer->GetRender()->SetRender(M_Anim[id], M_Anim_nb[id]);
Buffer->AddRigidBody();

switch(M_Id_Script[id])
{
case 0:
IaSlime * ScriptBuffer = new IaSlime;
Buffer->AffectScript(ScriptBuffer);
break;
case 1:

break;

default: break;
}

GetEngine()->AddObject(Buffer);

while(Buffer->GetRigidBody()->CollisionDecor(Buffer->GetTransform()->GetX(),Buffer->GetTransform()->GetY()))
{
Buffer->GetTransform()->SetXY( RandX() , RandY() );
}
}

void Generateur::UpdateTimer(int id)
{
M_Couldown[id]++;

if(M_Couldown[id] > 60 / M_Frequence[id])
{
CreateMonster(id);
M_Couldown[id] = 0;
}
}

void Generateur::UpdateEverySecond()
{
if(active)
{
for(int i = 0; i < M_nombre; i++)
{
if(CheckNbMonster(i) < M_Max[i])UpdateTimer(i);
}
}
}

int Generateur::CheckNbMonster( int id)
{
int nbmonster = 0;

for(int i = 0; i < GetEngine()->GetNbObject();i++)
{
if(strcmp(GetEngine()->GetListeObject()[i]->GetTag() , M_Tag[id]) == 0 && GetEngine()->GetListeObject()[i]->GetEnable() == true)
{
if(GetObject()->Collision(i))nbmonster++;
}
}

return nbmonster;
}


+ 57
- 0
generateur.hpp View File

@@ -0,0 +1,57 @@
#ifndef GENERATEUR
#define GENERATEUR

#include "..\C-Engine\CEngine.hpp"

class MonsterPattern
{
public:

MonsterPattern(char * vtag , Animation * vanim, int vanimnb, int vfreq, int vmax, int vidscript);

char * tag;
Animation * anim;
int nbanim;
int freq;
int max;
int idscript;
};

class Generateur: public Script
{
public:

Generateur();

void SetBox(int x1 , int x2 , int y1 , int y2);
void SetTab( int nbmonstre , MonsterPattern * tabpattern);

void Update();
void UpdateEverySecond();

int CheckNbMonster( int id);
void UpdateTimer(int id);
void CreateMonster( int id);

void ShowBox();

int RandX();
int RandY();

private:

int M_nombre; //Le nombre de monstres géré par le générateur.
char** M_Tag; // Un tableau qui contient le tag de tout les monstres.
Animation ** M_Anim; // Tableau des différents animations.
int * M_Anim_nb; //Tableau qui contient le nombre d'animation par pointeur d'animation
int * M_Max; //tableau du nombre max de monstre dans la zone.
int * M_Frequence; // frequence d'apparition des monstres par minute > 0
int * M_Couldown; // tableau nécessaire pour stocker le temps.
int * M_Id_Script; //Tableau qui contient le numéro du script qui doit être executer.

bool active;
bool show;
};

#endif // GQGUI


+ 31
- 0
monstres.cpp View File

@@ -0,0 +1,31 @@
#include "..\C-Engine\CEngine.hpp"

#include "monstres.hpp"

void IaSlime::Start()
{
GetObject()->AddRigidBody();
Direction = 0;
}

void IaSlime::UpdateEverySecond()
{
Direction = rand_int_ab(1, 5);

switch(Direction)
{
case 1 : GetObject()->GetRigidBody()->Move(0,3);GetObject()->GetRender()->SetIt(1);break;
case 2 : GetObject()->GetRigidBody()->Move(3,0);GetObject()->GetRender()->SetIt(2);GetObject()->GetRender()->ReverseRender(true); break;
case 3 : GetObject()->GetRigidBody()->Move(0,-3);GetObject()->GetRender()->SetIt(0);break;
case 4 : GetObject()->GetRigidBody()->Move(-3,0);GetObject()->GetRender()->SetIt(2);GetObject()->GetRender()->ReverseRender(false); break;
}
}

void IaSlime::Update()
{
if(GetObject()->GetCollisionTag("Epee"))
{
GetEngine()->DelObject(GetObject());
}

}

+ 21
- 0
monstres.hpp View File

@@ -0,0 +1,21 @@
#ifndef SLIME
#define SLIME

#include "..\C-Engine\CEngine.hpp"

class IaSlime: public Script
{
public:

void Start();
void UpdateEverySecond();
void Update();

int Direction;

};



#endif


Loading…
Cancel
Save