Fixe de bugs

This commit is contained in:
Fife 2016-07-19 14:38:45 +01:00
parent 382528254d
commit 41d54cbb4a
7 changed files with 163 additions and 4 deletions

View File

@ -32,7 +32,7 @@
//#define CE_ALL
#define CE_BASIC
//#define CE_RPG
//#define CE_PLATEFORME
#define CE_PLATEFORME
//#define CE_NETWORK
#define CE_DELTA1

View File

@ -41,6 +41,11 @@ class Render
int GetBlitX();
int GetBlitY();
bool GetActivate();
void ActivateRender();
void DeActivateRender();
void DrawObject();
private:
@ -56,6 +61,7 @@ class Render
bool reverse;
bool copie;
bool activate;
};
#endif

View File

@ -29,6 +29,32 @@ class Script
Engine * GetEngine();
Object * GetObject();
//Render
void SetIt( int v );
int GetIt();
void ReverseRender( bool v );
bool GetReverse();
//Rigidbody
Body * GetBody();
void Move( int x , int y );
bool CollisionDecor( int x , int y );
//Transforms
int GetX();
int GetY();
void SetX( int x );
void SetY( int y);
void SetXY( int x , int y );
protected:
Object * OConteneur;

View File

@ -121,6 +121,8 @@ void Engine::AddObject( Object * v , int level)
nbobject ++;
delete Tab;
return;
}
void Engine::DelObject( Object * v , bool destroy )
@ -134,6 +136,10 @@ void Engine::DelObject( Object * v , bool destroy )
if(tabLevel[i]->DelObject(v , destroy ))return;
}
}
else
{
return;
}
}
Object ** Tab = listeObject;
@ -201,6 +207,8 @@ void Engine::ExecuteScript()
{
for( int i = 0 ; i < GetCurrentLevel()->GetNbObject() ; i++ )
{
if(i >= GetCurrentLevel()->GetNbObject())return;
if( GetCurrentLevel()->GetListeObject()[i]->GetEnable())
if(GetCurrentLevel()->GetListeObject()[i]->GetScript())
GetCurrentLevel()->GetListeObject()[i]->GetScript()->Update();
@ -210,6 +218,8 @@ void Engine::ExecuteScript()
{
for( int i = 0 ; i < nbobject ; i++ )
{
if(i >= nbobject)return;
if( listeObject[i]->GetEnable())
if(listeObject[i]->GetScript())
listeObject[i]->GetScript()->Update();
@ -416,6 +426,8 @@ void Engine::ExecuteScriptSecond()
{
for( int i = 0 ; i < GetCurrentLevel()->GetNbObject() ; i++ )
{
if(i >= GetCurrentLevel()->GetNbObject())return;
if( GetCurrentLevel()->GetListeObject()[i]->GetEnable())
if(GetCurrentLevel()->GetListeObject()[i]->GetScript())
GetCurrentLevel()->GetListeObject()[i]->GetScript()->UpdateEverySecond();
@ -425,6 +437,8 @@ void Engine::ExecuteScriptSecond()
{
for( int i = 0 ; i < nbobject ; i++ )
{
if(i >= nbobject)return;
if( listeObject[i]->GetEnable())
if(listeObject[i]->GetScript())
listeObject[i]->GetScript()->UpdateEverySecond();

View File

@ -21,23 +21,34 @@ Render::Render(Object * Pointeur)
direction = 0;
copie = false;
activate = false;
}
Render::~Render()
{
if(copie)delete TabAnim;
if(copie)
{
delete TabAnim;
//Bug lorsqu'il y a plusieurs animations
}
}
void Render::SetRender(Animation * v, int nb)
{
TabAnim = v;
nb_anim = nb;
activate = true;
}
void Render::SetRender(Animation & v)
{
TabAnim = &v;
nb_anim = 1;
activate = true;
}
void Render::CopieRender(Animation * v, int nb)
@ -51,6 +62,8 @@ void Render::CopieRender(Animation * v, int nb)
nb_anim = nb;
copie = true;
activate = true;
}
void Render::CopieRender(Animation & v)
@ -61,6 +74,8 @@ void Render::CopieRender(Animation & v)
nb_anim = 1;
copie = true;
activate = true;
}
void Render::SetIt(int v)
@ -133,9 +148,24 @@ int Render::GetBlitY()
else return 0;
}
void Render::ActivateRender()
{
activate = true;
}
void Render::DeActivateRender()
{
activate = false;
}
bool Render::GetActivate()
{
return activate;
}
void Render::DrawObject()
{
if(TabAnim)
if(TabAnim && activate)
{
if(!reverse)
{

View File

@ -25,6 +25,9 @@ RigidBody::RigidBody(Object * Pointeur)
R_body.acceleration.x = 0;
R_body.acceleration.y = 0;
R_body.force.x = 0;
R_body.force.y = 0;
R_body.mass_data.mass = 0;
R_body.mass_data.inv_mass = 0;
}
@ -119,7 +122,7 @@ int RigidBody::TryMove( int x ,int y)
return 1;
}
if( x >= m->tileWidth || y>= m->tileHeight )
if( x >= m->tileWidth || y>= m->tileHeight || x <= - m->tileWidth || y <= - m->tileHeight)
{
TryMove( x / 2 , y / 2 );
TryMove( x / 2 , y / 2 );

View File

@ -59,5 +59,85 @@ Engine * Script::GetEngine()
return EConteneur;
}
//Render
void Script::SetIt( int v )
{
if( GetObject()->GetRender() )GetObject()->GetRender()->SetIt( v );
}
int Script::GetIt()
{
if( GetObject()->GetRender() )return GetObject()->GetRender()->GetIt();
return 0;
}
void Script::ReverseRender( bool v )
{
if( GetObject()->GetRender() )GetObject()->GetRender()->ReverseRender( v );
}
bool Script::GetReverse()
{
if( GetObject()->GetRender() )return GetObject()->GetRender()->GetReverse();
return 0;
}
//Rigidbody
Body * Script::GetBody()
{
if( GetObject()->GetRigidBody() )return GetObject()->GetRigidBody()->GetBody();
return NULL;
}
void Script::Move( int x , int y )
{
if( GetObject()->GetRigidBody() )GetObject()->GetRigidBody()->Move( x , y );
}
bool Script::CollisionDecor( int x , int y )
{
if( GetObject()->GetRigidBody() )return GetObject()->GetRigidBody()->CollisionDecor( x , y );
return 1;
}
//Transforms
int Script::GetX()
{
if( GetObject()->GetTransform())return GetObject()->GetTransform()->GetX();
return 0;
}
int Script::GetY()
{
if( GetObject()->GetTransform())return GetObject()->GetTransform()->GetY();
return 0;
}
void Script::SetX( int x )
{
if( GetObject()->GetTransform()) GetObject()->GetTransform()->SetX( x );
}
void Script::SetY( int y)
{
if( GetObject()->GetTransform()) GetObject()->GetTransform()->SetY( y );
}
void Script::SetXY( int x , int y )
{
if( GetObject()->GetTransform()) GetObject()->GetTransform()->SetXY( x , y );
}