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.

182 lines
2.9 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. #ifndef __BETACORE_GAME_HPP__
  2. #define __BETACORE_GAME_HPP__
  3. #ifdef _WIN32
  4. #define SDL_MAIN_HANDLED
  5. #include <Windows.h>
  6. #include <GLU.h>
  7. #include <GL/gl.h>
  8. #elif linux
  9. #include <GL/glu.h>
  10. #endif
  11. #include <SDL2/SDL.h>
  12. #include <SDL2/SDL_opengl.h>
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include <string>
  16. #include <math.h>
  17. #define PI 3.14159265359
  18. #include "common.hpp"
  19. #include "client.hpp"
  20. namespace betacore
  21. {
  22. class Game
  23. {
  24. private:
  25. SDL_Window *WINDOW = NULL;
  26. SDL_GLContext glContext;
  27. const int SCREEN_WIDTH = 800;
  28. const int SCREEN_HEIGHT = 600;
  29. int MONITOR_WIDTH = 1920;
  30. int MONITOR_HEIGHT = 1080;
  31. const char *TITLE;
  32. bool KEEP_ALIVE = true;
  33. bool SHOW_GRID = false;
  34. SHAPE USER_CURRENT = NONE;
  35. SHAPE GUST_CURRENT = NONE;
  36. MODE ME;
  37. bool KEY_UP_ARROW_ACTIVE = false;
  38. bool KEY_DOWN_ARROW_ACTIVE = false;
  39. bool KEY_LEFT_ARROW_ACTIVE = false;
  40. bool KEY_RIGHT_ARROW_ACTIVE = false;
  41. bool KEY_SPACE_ACTIVE = false;
  42. bool KEY_RETURN_ACTIVE = false;
  43. bool FULL_SCREEN = false;
  44. Client *client = nullptr;
  45. public:
  46. Game(MODE mode,
  47. int port,
  48. std::string url);
  49. ~Game();
  50. int init();
  51. int initGL();
  52. /**
  53. * Draws box for use with guest \ current screens
  54. */
  55. void box();
  56. /**
  57. * Close the application
  58. */
  59. void close();
  60. /*
  61. * Draw a grid on the screen (G key)
  62. */
  63. void grid();
  64. /*
  65. * Paint the gl context
  66. */
  67. void paint();
  68. /*
  69. * SDL Context
  70. */
  71. void events(SDL_Event &event);
  72. /*
  73. * On key down events
  74. */
  75. void key_down(SDL_Keycode key_code);
  76. /*
  77. * On key up events
  78. */
  79. void key_up(SDL_Keycode key_code);
  80. /*
  81. * Resize the window to width : height
  82. */
  83. void resize(int width, int height);
  84. /**
  85. * Draw a filled triange
  86. */
  87. void triangle();
  88. /*
  89. * Draw a filled or wireframe triangle
  90. */
  91. void triangle(bool filled);
  92. /*
  93. * Draw a filled or wireframe square
  94. */
  95. void square();
  96. /*
  97. * Draw a filled or wireframe square
  98. */
  99. void square(bool filled);
  100. /*
  101. * Draw a filled or wireframe circle
  102. */
  103. void circle();
  104. /*
  105. * Draw a filled or wireframe circle
  106. */
  107. void circle(bool filled);
  108. /*
  109. * Draw a filled or wireframe pentagon
  110. */
  111. void pentagon();
  112. /*
  113. * Draw a filled or wireframe pentagon
  114. */
  115. void pentagon(bool filled);
  116. /*
  117. * Draw a wireframe rectangle
  118. */
  119. void rectangle();
  120. /*
  121. * Draw a filled or wireframe cross
  122. */
  123. void cross(bool filled);
  124. /*
  125. * Draw the key pad compass
  126. */
  127. void compass();
  128. /*
  129. * Event call for up
  130. */
  131. void on_key_up_arrow();
  132. /*
  133. * Event call for down
  134. */
  135. void on_key_down_arrow();
  136. /*
  137. * Event call for left
  138. */
  139. void on_key_left_arrow();
  140. /*
  141. * Event call for right
  142. */
  143. void on_key_right_arrow();
  144. /*
  145. * Event call for space
  146. */
  147. void on_key_space();
  148. /*
  149. * Event call for enter
  150. */
  151. void on_key_enter();
  152. void top_screen();
  153. /*
  154. * Draw user screen
  155. */
  156. void user_screen();
  157. /*
  158. * Draw guest screen
  159. */
  160. void guest_screen();
  161. /*
  162. * On update from network
  163. */
  164. void update(SHAPE &s, MODE &m);
  165. };
  166. } // namespace betacore
  167. #endif