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.

pacman.cpp 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #include "..\C-Engine\CHeader.hpp"
  2. #include "control.hpp"
  3. #include "IaGhost.hpp"
  4. #include "GUI.hpp"
  5. void SetDecor( Engine * Game);
  6. int Jeu();
  7. void Menu()
  8. {
  9. const unsigned char smenu[]={0xff, 0x80, 0x20, 0x1, 0xf0, 0x0, 0x10, 0x8, 0x4, 0x2, 0xf, 0x80, 0xc0, 0x20, 0x6, 0xc, 0x0, 0x18, 0x18, 0x4, 0x3, 0x9, 0x80, 0x40, 0x50, 0x8, 0x2, 0x0, 0x14, 0x28, 0xa, 0x2, 0x89, 0x9e, 0x40, 0x50, 0x10, 0x64, 0x0, 0x12, 0x48, 0xa, 0x2, 0x49, 0x92, 0x40, 0x88, 0x10, 0x68, 0x0, 0x11, 0x88, 0x11, 0x2, 0x29, 0x9e, 0x40, 0x88, 0x20, 0x10, 0x0, 0x10, 0x8, 0x11, 0x2, 0x19, 0x80, 0x41, 0x4, 0x20, 0x20, 0x7f, 0x10, 0x8, 0x20, 0x82, 0x1, 0x80, 0xc1, 0x24, 0x20, 0x40, 0x41, 0x10, 0x8, 0x24, 0x82, 0x1, 0x9f, 0x82, 0x52, 0x20, 0x20, 0x7f, 0x10, 0x8, 0x4a, 0x42, 0x1, 0x90, 0x2, 0x72, 0x20, 0x10, 0x0, 0x11, 0x88, 0x4e, 0x42, 0x41, 0x90, 0x4, 0x1, 0x10, 0x8, 0x0, 0x12, 0x48, 0x80, 0x22, 0x61, 0x90, 0x4, 0x1, 0x10, 0x4, 0x0, 0x12, 0x48, 0x80, 0x22, 0x51, 0x90, 0x8, 0x70, 0x88, 0x2, 0x0, 0x12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 0x0, 0x0, 0x9, 0x0, 0x90, 0x4, 0x1, 0x8, 0x80, 0x0, 0x0, 0x0, 0x0, 0x9, 0x0, 0x9f, 0xc4, 0x1, 0x8, 0x80, 0x0, 0x0, 0x0, 0x0, 0x9, 0x0, 0x80, 0x48, 0x70, 0x91, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0x0, 0x80, 0x48, 0x88, 0x91, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0x0, 0xff, 0xcf, 0x7, 0x9e, 0x0, 0x0, 0x0, };
  10. while(input_press(K_EXE)){}
  11. while(!input_press(K_EXIT))
  12. {
  13. input_update();
  14. ML_clear_vram();
  15. ML_bmp_or(smenu,20,14,88,36);
  16. ML_display_vram();
  17. if(input_trigger(K_SHIFT) || input_trigger(K_EXE))Jeu();
  18. }
  19. }
  20. int Jeu()
  21. {
  22. #include "Sprite.hpp" // Inclusion des sprites.
  23. //*****************Creation des objects******************
  24. Object * PacMan = new Object;
  25. PacMan->GetTransforms()->SetXY( 116, 57);
  26. PacMan->GetRender()->SetRender(A_PacMan,2);
  27. PacMan->AddRigibody();
  28. PacMan->AffectTag("PacMan");
  29. Control * Script_PacMan = new Control;
  30. PacMan->AffectScript(Script_PacMan);
  31. Object * Ghost1 = new Object;
  32. Ghost1->GetTransforms()->SetXY( 99, 129);
  33. Ghost1->GetRender()->SetRender(A_Ghost,2);
  34. Ghost1->AddRigibody();
  35. Ghost1->AffectTag("Ghost");
  36. Object * Ghost2 = new Object;
  37. Ghost2->GetTransforms()->SetXY( 116, 129);
  38. Ghost2->GetRender()->SetRender(A_Ghost,2);
  39. Ghost2->AddRigibody();
  40. Ghost2->AffectTag("Ghost");
  41. Object * Ghost3 = new Object;
  42. Ghost3->GetTransforms()->SetXY( 133, 129);
  43. Ghost3->GetRender()->SetRender(A_Ghost,2);
  44. Ghost3->AddRigibody();
  45. Ghost3->AffectTag("Ghost");
  46. Object * Ghost4 = new Object;
  47. Ghost4->GetTransforms()->SetXY( 116, 156);
  48. Ghost4->GetRender()->SetRender(A_Ghost,2);
  49. Ghost4->AddRigibody();
  50. Ghost4->AffectTag("Ghost");
  51. Object * TP1 = new Object;
  52. TP1->GetTransforms()->SetXY( -14, 140);
  53. TP1->AddRigibody();
  54. TP1->GetRigibody()->UseFixeBody(15,15);
  55. TP1->AffectTag("TP1");
  56. Object * TP2 = new Object;
  57. TP2->GetTransforms()->SetXY( 245, 140);
  58. TP2->AddRigibody();
  59. TP2->GetRigibody()->UseFixeBody(15,15);
  60. TP2->AffectTag("TP2");
  61. Object * Jail = new Object;
  62. Jail->GetTransforms()->SetXY(31 * 3, (91 - 48) * 3);
  63. Jail->AddRigibody();
  64. Jail->GetRigibody()->UseFixeBody(60, 36);
  65. Jail->AffectTag("Jail");
  66. IAG * Script_Ghost1 = new IAG;
  67. IAG * Script_Ghost2 = new IAG;
  68. IAG * Script_Ghost3 = new IAG;
  69. IAG * Script_Ghost4 = new IAG;
  70. Ghost1->AffectScript(Script_Ghost1);
  71. Ghost2->AffectScript(Script_Ghost2);
  72. Ghost3->AffectScript(Script_Ghost3);
  73. Ghost4->AffectScript(Script_Ghost4);
  74. Script_Ghost1->SetGhost(1);
  75. Script_Ghost2->SetGhost(2);
  76. Script_Ghost3->SetGhost(3);
  77. Script_Ghost4->SetGhost(4);
  78. Script_Ghost1->pacmandirection = &Script_PacMan->direction;
  79. Script_Ghost2->pacmandirection = &Script_PacMan->direction;
  80. Script_Ghost3->pacmandirection = &Script_PacMan->direction;
  81. Script_Ghost4->pacmandirection = &Script_PacMan->direction;
  82. //***********Creation de la map***************
  83. Map Niveau1;
  84. Niveau1.SetMap(tileset ,level , tileprop , 3 , 3 , 82 ,91);
  85. //**************Assignation des objects************
  86. Engine Game;
  87. Game.AddObject( PacMan);
  88. Game.AddObject( Ghost1);
  89. Game.AddObject( Ghost2);
  90. Game.AddObject( Ghost3);
  91. Game.AddObject( Ghost4);
  92. Game.AddObject( TP1);
  93. Game.AddObject( TP2);
  94. Game.AddObject( Jail);
  95. Game.AffectMap( &Niveau1);
  96. Niveau1.AffectEngine( &Game);
  97. Script_GUI SGUI;
  98. Game.AffectScript(SGUI);
  99. Script_PacMan->Initialisation(&SGUI);
  100. Script_Ghost1->Initialisation(&SGUI);
  101. Script_Ghost2->Initialisation(&SGUI);
  102. Script_Ghost3->Initialisation(&SGUI);
  103. Script_Ghost4->Initialisation(&SGUI);
  104. Game.SetFpsWish(45);
  105. Game.Game();
  106. return 1;
  107. }
  108. extern "C"
  109. {
  110. int AddIn_main(int isAppli, unsigned short OptionNum)
  111. {
  112. Menu();
  113. return 1;
  114. }
  115. #pragma section _BR_Size
  116. unsigned long BR_Size;
  117. #pragma section
  118. #pragma section _TOP
  119. int InitializeSystem(int isAppli, unsigned short OptionNum)
  120. {
  121. return INIT_ADDIN_APPLICATION(isAppli, OptionNum);
  122. }
  123. #pragma section
  124. }