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.

150 lines
2.6KB

  1. #include "..\C-Engine\CHeader.hpp"
  2. class Control: public Script
  3. {
  4. public:
  5. void Update();
  6. };
  7. void Control::Update()
  8. {
  9. bool isground = GetObject()->ORigibody->CollisionDecor(GetX(),GetY()-1);
  10. bool isdo = false;
  11. if(input_press(K_RIGHT))
  12. {
  13. Move(1,0);
  14. SetIt(1);
  15. isdo = true;
  16. }
  17. else if(input_press(K_LEFT))
  18. {
  19. Move(-1,0);
  20. SetIt(2);
  21. isdo = true;
  22. }
  23. else if(input_press(K_UP) && isground == true)
  24. {
  25. GetObject()->ORigibody->R_body.velocity.y = 50 ;
  26. }
  27. else if(input_press(K_SHIFT) && isground == false)
  28. {
  29. SetIt(12);
  30. isdo = true;
  31. }
  32. else if(input_press(K_OPTN) && isground == false)
  33. {
  34. SetIt(13);
  35. isdo = true;
  36. }
  37. else if(input_press(K_DOWN) && input_press(K_SHIFT))
  38. {
  39. SetIt(7);
  40. isdo = true;
  41. }
  42. else if(input_press(K_DOWN) && input_press(K_OPTN))
  43. {
  44. SetIt(8);
  45. isdo = true;
  46. }
  47. else if(input_press(K_DOWN) && input_press(K_VARS))
  48. {
  49. SetIt(9);
  50. isdo = true;
  51. }
  52. else if(input_press(K_DOWN))
  53. {
  54. SetIt(6);
  55. isdo = true;
  56. }
  57. else if(input_press(K_SHIFT))
  58. {
  59. SetIt(3);
  60. isdo = true;
  61. }
  62. else if(input_press(K_OPTN))
  63. {
  64. SetIt(4);
  65. isdo = true;
  66. }
  67. else if(input_press(K_VARS))
  68. {
  69. SetIt(5);
  70. isdo = true;
  71. }
  72. if(isground == false)
  73. {
  74. if(GetObject()->ORender->GetIt() != 12 && GetObject()->ORender->GetIt() != 13) SetIt(11);
  75. }
  76. if(isdo != true && isground == true)SetIt(0);
  77. }
  78. int Jeu()
  79. {
  80. #include "Sources\Sprite.hpp" // Inclusion des sprites.
  81. //*****************Creation des objects******************
  82. Object Player1;
  83. Player1.OTransforms->SetXY(50, 24);
  84. Player1.ORender->SetRender(A_Ken , 14);
  85. Player1.ORigibody = new Rigibody(&Player1);
  86. Player1.ORigibody->SetMass(1);
  87. Control ScriptControl;
  88. Player1.AffectScript(ScriptControl);
  89. //**************Assignation des objects************
  90. Engine Game;
  91. Game.AddObject( & Player1);
  92. Map Niveau;
  93. Niveau.SetMap(tileset , level , prop , 12 , 12 , 15 ,10);
  94. Game.AffectMap( &Niveau);
  95. Niveau.AffectEngine( &Game);
  96. Game.SetFpsWish(2);
  97. Game.SetType(1);
  98. Game.Game();
  99. return 1;
  100. }
  101. extern "C"
  102. {
  103. int AddIn_main(int isAppli, unsigned short OptionNum)
  104. {
  105. Jeu();
  106. return 1;
  107. }
  108. #pragma section _BR_Size
  109. unsigned long BR_Size;
  110. #pragma section
  111. #pragma section _TOP
  112. int InitializeSystem(int isAppli, unsigned short OptionNum)
  113. {
  114. return INIT_ADDIN_APPLICATION(isAppli, OptionNum);
  115. }
  116. #pragma section
  117. }