diff --git a/CEngine.hpp b/CEngine.hpp index f476c40..12b9052 100644 --- a/CEngine.hpp +++ b/CEngine.hpp @@ -34,7 +34,7 @@ //#define CE_RPG #define CE_PLATEFORME //#define CE_NETWORK - #define CE_DELTA1 + //#define CE_DELTA1 #ifdef CE_ALL diff --git a/include/Engine.hpp b/include/Engine.hpp index 521e48b..4ba2e3e 100644 --- a/include/Engine.hpp +++ b/include/Engine.hpp @@ -49,6 +49,7 @@ class Engine void DrawLevel(); void SetCurrentLevel( int id); + int GetIdCurrentLevel(); Level * GetCurrentLevel(); Level * GetLevel(int id); diff --git a/include/Level.hpp b/include/Level.hpp index 4f2fff3..f01487f 100644 --- a/include/Level.hpp +++ b/include/Level.hpp @@ -23,10 +23,11 @@ class Level void SetMap( const unsigned char * userTileset , unsigned char * userMap , bool * userProperties, int userTileWidth , int userTileHeight , int userWorldWidth , int userWorldHeight); - int GetIdMap( int x, int y ); + int GetIdMap( int x, int y , bool relative = false); void ReplaceIdMap( int x , int y, char v ); void DrawMap(); + void DrawLevel(); Object ** GetListeObject(); int GetNbObject(); diff --git a/include/Object.hpp b/include/Object.hpp index 1bfbacf..38b6903 100644 --- a/include/Object.hpp +++ b/include/Object.hpp @@ -69,15 +69,17 @@ class Trigger: public Object ~Trigger(); void CreateTrigger(int x , int y , int width , int height ); - void SetDestination(int x , int y , int level); + void SetDestination(int x , int y , int level , char * onlypass = NULL); Vec2 GetDestination(); int GetDestinationLevel(); + char * GetPass(); private: Vec2 destination; int leveldestination; + char * pass; }; #endif diff --git a/src/Engine.cpp b/src/Engine.cpp index 705268c..0c53907 100644 --- a/src/Engine.cpp +++ b/src/Engine.cpp @@ -29,6 +29,8 @@ Engine::Engine() nbLevel = 0; currentLevel = 0; time = 0; + + engineScript = NULL; } void Engine::StartGame() @@ -367,6 +369,11 @@ void Engine::DrawLevel() if(tabLevel && currentLevel != -1 )tabLevel[currentLevel]->DrawMap(); } +int Engine::GetIdCurrentLevel() +{ + return currentLevel; +} + Level * Engine::GetCurrentLevel() { if(currentLevel != -1) diff --git a/src/Level.cpp b/src/Level.cpp index 5d1de0f..53048b7 100644 --- a/src/Level.cpp +++ b/src/Level.cpp @@ -56,13 +56,20 @@ void Level::SetMap( const unsigned char * userTileset , unsigned char * userMap } -int Level::GetIdMap( int x , int y ) +int Level::GetIdMap( int x , int y , bool relative) { - int id = *(map + levelWidth * y + x); + int id; + int dx = x / tileWidth; + int dy = levelHeight - y / tileHeight - 1; + + if(relative) + id = *(map + levelWidth * dy + dx); + else + id = *(map + levelWidth * y + x); #ifdef CE_DELTA1 - id --; + id --; #endif // CE_DELTA1 @@ -97,6 +104,18 @@ void Level::DrawMap() } } +void Level::DrawLevel() +{ + DrawMap(); + + for( int i = 0 ; i < GetNbObject() ; i++ ) + { + if( GetListeObject()[i]->GetEnable()) + if(GetListeObject()[i]->GetRender()) + GetListeObject()[i]->GetRender()->DrawObject(); + } +} + Object ** Level::GetListeObject() { return listeObject; diff --git a/src/Trigger.cpp b/src/Trigger.cpp index 013d5aa..6f67ff7 100644 --- a/src/Trigger.cpp +++ b/src/Trigger.cpp @@ -40,11 +40,12 @@ void Trigger::CreateTrigger(int x , int y , int width , int height ) ORigidBody->UseFixeBody(width,height); } -void Trigger::SetDestination(int x , int y , int level) +void Trigger::SetDestination(int x , int y , int level , char * onlypass) { destination.x = x; destination.y = y; leveldestination = level; + pass = onlypass; } Vec2 Trigger::GetDestination() @@ -57,6 +58,11 @@ int Trigger::GetDestinationLevel() return leveldestination; } +char * Trigger::GetPass() +{ + return pass; +} + void Trigger_Script::AffectTrigger(Trigger * TV) { TConteneur = TV; @@ -77,8 +83,14 @@ void Trigger_Script::Update() { if(GetObject()->Collision(i, GetEngine()->GetCurrentLevel())) { - if(GetEngine()->GetCurrentLevel()->GetListeObject()[i]->GetScript()) - GetEngine()->GetCurrentLevel()->GetListeObject()[i]->GetScript()->Teleport(TConteneur->GetDestination().x , TConteneur->GetDestination().y , TConteneur->GetDestinationLevel()); + if(GetTrigger()->GetPass()) + { + if(!strcmp(GetEngine()->GetCurrentLevel()->GetListeObject()[i]->GetTag() , GetTrigger()->GetPass())) + { + if(GetEngine()->GetCurrentLevel()->GetListeObject()[i]->GetScript()) + GetEngine()->GetCurrentLevel()->GetListeObject()[i]->GetScript()->Teleport(TConteneur->GetDestination().x , TConteneur->GetDestination().y , TConteneur->GetDestinationLevel()); + } + } } } }