Advertisement
Guest User

Untitled

a guest
May 24th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. void Game::OnRender(Context &ctx) {
  2. goname->DrawMyName(ctx);
  3. ReadyToStart(ctx);
  4. hero->Intersect(ctx);
  5. if (help->Lflag) {
  6. DeleteAwalls(ctx);
  7. help->Lflag = false;
  8. DrawingFourLines(ctx);
  9. }
  10. if (help->Uflag) {
  11. DeleteAwalls(ctx);
  12. help->Uflag = false;
  13. DrawingFourLines(ctx);
  14. }
  15. if (hero->intersectwith) {
  16. PlaySFX(ctx, "pick.wav");
  17. tabletss[0] = new Tablets(5 + rand() % 230, 5 + rand() % 125, 5,5);
  18. hero->intersectwith = false;
  19. }
  20. if (hero->isWin()) {
  21. StopMusic(ctx, "back.wav");
  22. StopSFX(ctx, "pick.wav");
  23. DrawClearScreen(ctx, PALETTE[0]);
  24. DrawSprite(ctx, id, 0, 0, 0, 0, GetDisplayWidth(ctx), GetDisplayHeight(ctx));
  25. ostringstream ost;
  26. ost << help->lvl;
  27. string aa = ost.str();
  28. Print(ctx, "Level " + aa + " Passed!", 45, 25, PALETTE[7], 2);
  29. Print(ctx, "Tap Space", 65, 45, PALETTE[7],2);
  30. Print(ctx, "To next LVL", 55, 65, PALETTE[7], 2);
  31. tabletss.clear();
  32. if (IsClicked(ctx, Button::KEY_SPACE)) {
  33. isGameRestarted = true;
  34. }
  35. awalls.clear();
  36. }
  37. if (hero->isGameover()) {
  38. StopMusic(ctx, "back.wav");
  39. DrawClearScreen(ctx, PALETTE[0]);
  40. DrawSprite(ctx, id, 0, 0, 0, 0, GetDisplayWidth(ctx), GetDisplayHeight(ctx));
  41. Print(ctx, "Game Over",GetDisplayHeight(ctx)/2,25,PALETTE[7],2);
  42. Print(ctx, "Press SPACE to Restart",67,60,PALETTE[7],1);
  43. ostringstream ost;
  44. ost << help->lvl;
  45. string aa = ost.str();
  46. Print(ctx,goname->sname + ", your Highest LVL is : " + aa,45,100,PALETTE[7],1);
  47. if (IsClicked(ctx, Button::KEY_SPACE)) {
  48. isGameRestarted = true;
  49. }
  50. if (IsClicked(ctx, Button::KEY_ESCAPE)) {
  51. hero->tr = true;
  52. srecord.push_back(new Record(help->lvl, goname->sname));
  53. }
  54. DeleteAwalls(ctx);
  55. tabletss.clear();
  56. }
  57. if (isGameRestarted) {
  58. if (hero->isGameover()) {
  59. help->needtocatch = 4;
  60. help->lvl = 0;
  61. }
  62. PlayMusic(ctx, "back.wav");
  63. StopSFX(ctx, "respawn.wav");
  64. help->lvl++;
  65. help->needtocatch++;
  66. delete(hero);
  67. hero = new Player(GetDisplayWidth(ctx)/2+10,GetDisplayHeight(ctx)/2, 6, 150, 150, nwalls, awalls,tabletss, help);
  68. DeleteTablets(ctx);
  69. tabletss[0] = new Tablets(5 + rand() % 250, 5 + rand() % 135, 5,5);
  70. awalls.clear();
  71. hero->win = false;
  72. hero->gameover = false;
  73. hero->startgame = true;
  74. DrawEnemy(ctx);
  75. isGameRestarted = false;
  76. }
  77. if (hero->tr) {
  78. PrintTable(ctx);
  79. if (IsClicked(ctx, Button::KEY_BACKSPACE)) {
  80. hero->tr = false;
  81. isGameRestarted = true;
  82. }
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement