Guest User

Untitled

a guest
May 24th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. #include <conio.h>
  2. #include <windows.h>
  3.  
  4. using namespace std; // <- ??
  5.  
  6. // Eigentlich sollte die beim Start in ein bool-Array umgewandelt werden.
  7. // Das hat aber nicht geklappt, also gehe ich den elit‰ren Weg und checke
  8. // jedes Mal diesen blˆden String durch.
  9.  
  10. char *map =
  11. "################################################################################"
  12. "# #"
  13. "# #"
  14. "# #"
  15. "# #"
  16. "# #"
  17. "# #"
  18. "# #"
  19. "# #"
  20. "# ######### #"
  21. "# ## ## ##_____## ## ####################### #"
  22. "# ## ## ## ## ## ## ##___________________## #"
  23. "# ## ## ## #"
  24. "# ## #"
  25. "# ################# #######"
  26. "### ################# #######"
  27. "### ## ## THX TO ## ###"
  28. "#/ ## ## FLGR ## ###"
  29. "# ##### ## ##################### ###"
  30. "######################## ##### ## ##################### ###"
  31. "# ANOTHER QUALITY GAME # #### ########### #"
  32. "# BY JULIAN RASCHKE # #### ########### #"
  33. "################################################################################";
  34.  
  35. class player
  36. {
  37. private:
  38. int _x, _y;
  39. float _vy;
  40. public:
  41. player(int x, int y);
  42. inline int x() { return _x; };
  43. inline int y() { return _x; };
  44. inline float vy() { return _vy; };
  45. void update();
  46. };
  47.  
  48. player::player(int x, int y)
  49. {
  50. _x = x;
  51. _y = y;
  52. _vy = 0;
  53. }
  54.  
  55. void player::update()
  56. {
  57. puttext(_x + 1, _y + 1, _x + 1, _y + 1, " ");
  58.  
  59. _vy += 0.2;
  60.  
  61. for (int i = 0; i < _vy; i++)
  62. {
  63. if (map[80 + _y * 80 + _x] == ' ')
  64. {
  65. _y++;
  66. Beep(_vy * 100, 1);
  67. }
  68. else
  69. {
  70. _vy = 0;
  71. }
  72. };
  73.  
  74. for (int i = 0; i > _vy / 5; i--)
  75. {
  76. if (map[-80 + _y * 80 + _x] == ' ')
  77. {
  78. _y--;
  79. Beep(-_vy * 100, 1);
  80. }
  81. else
  82. {
  83. _vy = 0.2;
  84. }
  85. };
  86.  
  87. if ((GetAsyncKeyState(VK_UP) & 0x8000) && map[80 + _y * 80 + _x] != ' ')
  88. {
  89. _vy = -2;
  90. Beep(100, 50);
  91. }
  92.  
  93. if ((GetAsyncKeyState(VK_LEFT) & 0x8000) && map[_y * 80 + _x - 1] == ' ')
  94. {
  95. _x -= 1;
  96. Beep(700, 10);
  97. }
  98.  
  99. if ((GetAsyncKeyState(VK_RIGHT) & 0x8000) && map[_y * 80 + _x + 1] == ' ')
  100. {
  101. _x += 1;
  102. Beep(900, 10);
  103. }
  104.  
  105. if (map[80 + _y * 80 + _x] == ' ')
  106. {
  107. puttext(_x + 1, _y + 1, _x + 1, _y + 1, "H");
  108. }
  109. else
  110. {
  111. puttext(_x + 1, _y + 1, _x + 1, _y + 1, "A");
  112. }
  113. }
  114.  
  115. int main(int argc, char *argv[])
  116. {
  117. puttext(1, 1, 80, 25, map);
  118.  
  119. player plr(40, 3);
  120.  
  121. while (true)
  122. {
  123. plr.update();
  124.  
  125. Sleep(30);
  126. }
  127.  
  128. return 0;
  129. }
Add Comment
Please, Sign In to add comment