No Description

Breakout.h 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // Breakout.h
  3. // ogamalBreakout
  4. //
  5. // Created by Osama Attia on 9/21/14.
  6. // ogamal@iastate.edu
  7. //
  8. #ifndef BREAKOUT_H
  9. #define BREAKOUT_H
  10. #include <vector>
  11. #include <iostream>
  12. #include <stdlib.h>
  13. #include <math.h>
  14. #if defined(__APPLE__) || defined(MACOSX)
  15. #include <GLUT/glut.h>
  16. #else
  17. #include <GL/glut.h>
  18. #endif
  19. // My includes
  20. #include "MyObjects.h" // Game-specific objects
  21. #include "config.h" // Game configurations
  22. class Breakout {
  23. public:
  24. // Class Constructor/Destructor
  25. Breakout();
  26. ~Breakout();
  27. // Public functions (handle GLUT calls)
  28. void display(void);
  29. void init(void);
  30. void reshape(int width, int height);
  31. void mouseClick(int button, int state, int x, int y);
  32. void mouseMove(int x, int y);
  33. void keyStroke(unsigned char key, int x, int y);
  34. void specialKeyPos(int key, int x, int y);
  35. private:
  36. // Game statistics
  37. int score;
  38. int level;
  39. int reward;
  40. int lifesCount;
  41. // Possible ame mode
  42. enum State {INIT, Menus, Gameplay, Scoreboard};
  43. Breakout::State gameState;
  44. // Balls
  45. std::vector <Ball> balls;
  46. // Paddle
  47. Paddle paddle;
  48. // Bricks
  49. std::vector<Brick> bricks;
  50. // Private functions
  51. void drawBackground(void);
  52. void drawGame(void);
  53. void newBall(float x, float y);
  54. void drawBalls(void);
  55. void initPaddle(void);
  56. void drawPaddle(void);
  57. void initBricks(void);
  58. void bricksLevel1(void);
  59. void bricksLevel2(void);
  60. void drawBricks(void);
  61. template <typename Iterator>
  62. int wallCollision(Iterator it);
  63. template <typename Iterator>
  64. bool brickCollision(Iterator it, Iterator br);
  65. template <typename Iterator>
  66. Iterator hitBrick(Iterator brick);
  67. void drawLife(float x, float y);
  68. void drawGameStats(void);
  69. void drawScore(void);
  70. void drawCoordinate(void);
  71. };
  72. #endif // BREAKOUT_H