You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EScript.cpp 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. #include "..\C-Engine\CHeader.hpp"
  2. #include "EScript.hpp"
  3. void EngineControl::Update()
  4. {
  5. if(((int)GetEngine()->GetListeObject()[0]->GetTransforms()->GetX() % 12 < 3 && mini == false ) || ((int)GetEngine()->GetListeObject()[0]->GetTransforms()->GetX() % 8 < 3 && mini == true))
  6. {
  7. UpdateScenary();
  8. }
  9. }
  10. void EngineControl::UpdateScenary()
  11. {
  12. int stop = GetEngine()->GetNbObject();
  13. for(int i = 1; i < stop ; i++)
  14. {
  15. if(GetEngine()->GetListeObject()[i]->GetTransforms()->GetX() < (GetEngine()->GetListeObject()[0]->GetTransforms()->GetX() - 36))
  16. {
  17. GetEngine()->DelObject(GetEngine()->GetListeObject()[i]);
  18. i--;
  19. stop --;
  20. }
  21. }
  22. if(!mini)SetDecor(((int)GetEngine()->GetListeObject()[0]->GetTransforms()->GetX() / 12) + 10);
  23. else SetDecor(((int)GetEngine()->GetListeObject()[0]->GetTransforms()->GetX() / 8) + 10);
  24. }
  25. void EngineControl::SetDecor(int i)
  26. {
  27. int dify , difx, w , h , type;
  28. if(GetEngine()->GetMap() == NULL)return;
  29. if(!mini)
  30. {
  31. for( int j = 0 ; j < GetEngine()->GetMap()->nbtiles_hauteur_monde; j++)
  32. {
  33. w = 0 ; h = 0; difx = 0; dify = 0; type = 0;
  34. //Type = 0 rien //Type = 1 pics //Type = 2 jump //Type = 3 doublejump //Type = 4 portail ->navette //Type = 5 portail ->cube
  35. switch(GetEngine()->GetMap()->GetIdMap(i,j))
  36. {
  37. case 7: w = 10 ; h = 10; type = 1; difx = 1;break;//Triangle pics
  38. case 8: w = 10 ; h = 10; type = 1;difx = 1;break;//Triangle pics
  39. case 5: w = 12 ; h = 4; type = 1;break; //Pics
  40. case 6: w = 12 ; h = 4; type = 1;break; //Pics
  41. case 9: w = 10 ; h = 6; type = 1;difx = 1;break; //Petit triangle droit
  42. case 10: w = 10 ; h = 6; dify = 6; type = 1;difx = 1;break; //Petit triangle renverse
  43. case 11: w = 8 ; h = 4; type = 2; break; //jump
  44. case 12: w = 12 ; h = 12; type = 3; break;//Doublejump
  45. case 16: w = 10 ; h = 22; dify = 1; type = 4; break;//Portail
  46. case 18: w = 10 ; h = 22; dify = 1; type = 5; break;
  47. case 20: w = 10 ; h = 10; type = 1; difx = 2; dify = 1; break;
  48. case 21: w = 10 ; h = 10; type = 1; difx = 2; dify = 1; break;
  49. default: w = 0 ; h = 0; type = 0; break;
  50. }
  51. if(type == 1)
  52. {
  53. Object * Buffer = new Object;
  54. Buffer->GetTransforms()->SetXY( i * 12 + difx, ((GetEngine()->GetMap()->nbtiles_hauteur_monde - 1)* 12) - (j * 12) + 2 + dify);
  55. Buffer->AddRigibody();
  56. Buffer->GetRigibody()->UseFixeBody(w,h);
  57. Buffer->AffectTag("Pic");
  58. GetEngine()->AddObject(Buffer);
  59. }
  60. if(type == 2)
  61. {
  62. Object * Buffer = new Object;
  63. Buffer->GetTransforms()->SetXY( i * 12 + 2 , ((GetEngine()->GetMap()->nbtiles_hauteur_monde - 1)* 12) - (j * 12) + 2 + dify);
  64. Buffer->AddRigibody();
  65. Buffer->GetRigibody()->UseFixeBody(w,h);
  66. Buffer->AffectTag("Jump");
  67. GetEngine()->AddObject(Buffer);
  68. }
  69. if(type == 3)
  70. {
  71. Object * Buffer = new Object;
  72. Buffer->GetTransforms()->SetXY( i * 12 , ((GetEngine()->GetMap()->nbtiles_hauteur_monde - 1)* 12) - (j * 12) + 2 + dify);
  73. Buffer->AddRigibody();
  74. Buffer->GetRigibody()->UseFixeBody(w,h);
  75. Buffer->AffectTag("DJ");
  76. GetEngine()->AddObject(Buffer);
  77. }
  78. if(type == 4)
  79. {
  80. Object * Buffer = new Object;
  81. Buffer->GetTransforms()->SetXY( i * 12 + 1, ((GetEngine()->GetMap()->nbtiles_hauteur_monde - 1)* 12) - (j * 12) + 2 + dify);
  82. Buffer->AddRigibody();
  83. Buffer->GetRigibody()->UseFixeBody(w,h);
  84. Buffer->AffectTag("PN");
  85. GetEngine()->AddObject(Buffer);
  86. }
  87. if(type == 5)
  88. {
  89. Object * Buffer = new Object;
  90. Buffer->GetTransforms()->SetXY( i * 12 + 1, ((GetEngine()->GetMap()->nbtiles_hauteur_monde - 1)* 12) - (j * 12) + 2 + dify);
  91. Buffer->AddRigibody();
  92. Buffer->GetRigibody()->UseFixeBody(w,h);
  93. Buffer->AffectTag("PC");
  94. GetEngine()->AddObject(Buffer);
  95. }
  96. }
  97. }
  98. else
  99. {
  100. for( int j = 0 ; j < GetEngine()->GetMap()->nbtiles_hauteur_monde; j++)
  101. {
  102. w = 0 ; h = 0; difx = 0; dify = 0; type = 0;
  103. //Type = 0 rien //Type = 1 pics //Type = 2 jump //Type = 3 doublejump //Type = 4 portail ->navette //Type = 5 portail ->cube
  104. switch(GetEngine()->GetMap()->GetIdMap(i,j))
  105. {
  106. case 7: w = 6 ; h = 6; type = 1; difx = 1;break;//Triangle pics
  107. case 8: w = 6 ; h = 6; type = 1;difx = 1;break;//Triangle pics
  108. case 5: w = 8 ; h = 3; type = 1;break; //Pics
  109. case 6: w = 8 ; h = 3; type = 1;break; //Pics
  110. case 9: w = 6 ; h = 4; type = 1;difx = 1;break; //Petit triangle droit
  111. case 10: w = 6 ; h = 4; dify = 4; type = 1;difx = 1;break; //Petit triangle renverse
  112. case 11: w = 6 ; h = 3; type = 2; break; //jump
  113. case 12: w = 8 ; h = 8; type = 3; break;//Doublejump
  114. case 16: w = 8 ; h = 22; dify = 1; type = 4; break;//Portail
  115. case 18: w = 8 ; h = 22; dify = 1; type = 5; break;
  116. case 20: w = 6; h = 6; type = 1; difx = 2; dify = 1; break;
  117. case 21: w = 6; h = 6; type = 1; difx = 2; dify = 1; break;
  118. default: w = 0 ; h = 0; type = 0; break;
  119. }
  120. if(type == 1)
  121. {
  122. Object * Buffer = new Object;
  123. Buffer->GetTransforms()->SetXY( i * 8 + difx, ((GetEngine()->GetMap()->nbtiles_hauteur_monde - 1)* 8) - (j * 8) + 2 + dify);
  124. Buffer->AddRigibody();
  125. Buffer->GetRigibody()->UseFixeBody(w,h);
  126. Buffer->AffectTag("Pic");
  127. GetEngine()->AddObject(Buffer);
  128. }
  129. if(type == 2)
  130. {
  131. Object * Buffer = new Object;
  132. Buffer->GetTransforms()->SetXY( i * 8 + 2 , ((GetEngine()->GetMap()->nbtiles_hauteur_monde - 1)* 8) - (j * 8) + 2 + dify);
  133. Buffer->AddRigibody();
  134. Buffer->GetRigibody()->UseFixeBody(w,h);
  135. Buffer->AffectTag("Jump");
  136. GetEngine()->AddObject(Buffer);
  137. }
  138. if(type == 3)
  139. {
  140. Object * Buffer = new Object;
  141. Buffer->GetTransforms()->SetXY( i * 8 , ((GetEngine()->GetMap()->nbtiles_hauteur_monde - 1)* 8) - (j * 8) + 2 + dify);
  142. Buffer->AddRigibody();
  143. Buffer->GetRigibody()->UseFixeBody(w,h);
  144. Buffer->AffectTag("DJ");
  145. GetEngine()->AddObject(Buffer);
  146. }
  147. if(type == 4)
  148. {
  149. Object * Buffer = new Object;
  150. Buffer->GetTransforms()->SetXY( i * 8 + 1, ((GetEngine()->GetMap()->nbtiles_hauteur_monde - 1)* 8) - (j * 8) + 2 + dify);
  151. Buffer->AddRigibody();
  152. Buffer->GetRigibody()->UseFixeBody(w,h);
  153. Buffer->AffectTag("PN");
  154. GetEngine()->AddObject(Buffer);
  155. }
  156. if(type == 5)
  157. {
  158. Object * Buffer = new Object;
  159. Buffer->GetTransforms()->SetXY( i * 8 + 1, ((GetEngine()->GetMap()->nbtiles_hauteur_monde - 1)* 8) - (j * 8) + 2 + dify);
  160. Buffer->AddRigibody();
  161. Buffer->GetRigibody()->UseFixeBody(w,h);
  162. Buffer->AffectTag("PC");
  163. GetEngine()->AddObject(Buffer);
  164. }
  165. }
  166. }
  167. }