No Description

frog.h 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #ifndef FROG_H
  2. #define FROG_H
  3. #include <QWidget>
  4. #include <QPainter>
  5. #include <QtGui>
  6. #include <QtCore>
  7. #include <QTimer>
  8. #include <QLabel>
  9. /// Class that represent the frog and leaves.
  10. ///
  11. /// Frog is a subclass of QWidget.
  12. class frog : public QWidget
  13. {
  14. Q_OBJECT
  15. public:
  16. /// \fn frog::frog(QWidget *parent)
  17. /// \~English
  18. /// \brief Default constructor.
  19. /// * Ysapo: Y coordinate of the frog, set at 190 so it sits on top of the leaf
  20. /// * Xsapo: X coordinate of the frog, a random number from 0 to -30
  21. /// * xnenu, xnenu2, xnenu3: X coordinates of the leafs
  22. /// * textBool: Boolean for the labels on the leafs
  23. /// * temp, temp2: X coordinate of the background
  24. /// \~Spanish
  25. /// \ brief Constructor por defecto.
  26. /// * Ysapo: Coordenada Y del sapo, inicializado a 190 para que aparesca encima del nenufar
  27. /// * Xsapo: Coordenada X del sapo, un numero aleatorio de 0 a -30
  28. /// * xnenu, xnenu2, xnenu3: coordenadas x de las hojas
  29. /// * textBool: Booleana para las etiquetas de los nenufares
  30. /// * temp, temp2: Coordenada X del fondo
  31. ///
  32. explicit frog(QWidget *parent = 0);
  33. /// \fn frog::QuadraticPlus(int a, int b, int c)
  34. /// \~English
  35. /// \brief Function that returns the result of the positive quadratic formula.
  36. /// \param a: value used to complete the quadratic formula ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
  37. /// \param b: value used to complete the quadratic formula ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
  38. /// \param c: value used to complete the quadratic formula ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
  39. /// \~Spanish
  40. /// \brief Funcion que devuelve el resultado de la formula cuadratica positiva.
  41. /// \param a: valor utilizado para completar la formula quadratica ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
  42. /// \param b: valor utilizado para completar la formula quadratica ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
  43. /// \param c: valor utilizado para completar la formula quadratica ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
  44. ///
  45. double QuadraticPlus(int a, int b, int c);
  46. /// \fn frog::QuadraticMinus(int a, int b, int c)
  47. /// \~English
  48. /// \brief Function that returns the result of the negative quadratic formula.
  49. /// \param a: value used to complete the quadratic formula ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
  50. /// \param b: value used to complete the quadratic formula ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
  51. /// \param c: value used to complete the quadratic formula ((-b) + sqrt((pow(b,2)) - 4*a*c))/(2*a)
  52. /// \~Spanish
  53. /// \brief Funcion que devuelve el resultado de la formula cuadratica negativa.
  54. /// \param a: valor utilizado para completar la formula quadratica ((-b) - sqrt((pow(b,2)) - 4*a*c))/(2*a)
  55. /// \param b: valor utilizado para completar la formula quadratica ((-b) - sqrt((pow(b,2)) - 4*a*c))/(2*a)
  56. /// \param c: valor utilizado para completar la formula quadratica ((-b) - sqrt((pow(b,2)) - 4*a*c))/(2*a)
  57. ///
  58. double QuadraticMinus(int a, int b, int c);
  59. /// \fun frog::~frog()
  60. /// \~English
  61. /// \brief Default destructor.
  62. /// \~Spanish
  63. /// \brief Destructor por defecto.
  64. ///
  65. ~frog();
  66. float Ysapo; /**< Y coordinate of the frog*/
  67. float Xsapo; /**< X coordinate of the frog*/
  68. float initialX; /**< Initial position of the frog*/
  69. bool flag, xFlag, backFlag, moved, textBool;
  70. int A, B, C, buttonCounter,temp,temp2,xnenu,xnenu2,xnenu3;
  71. signals:
  72. public slots:
  73. /// \fun void frog::mySlot()
  74. /// \~English
  75. /// \brief Function connected to a timer, used to simulate the
  76. /// frog's jump.
  77. /// \~Spanish
  78. /// \brief Funcion conectada a un reloj, utilizada para simular
  79. /// el brinco del sapo
  80. ///
  81. void mySlot();
  82. /// \fn void frog::run(int , int , int )
  83. /// \~English
  84. /// \brief Function that is invoked when the jump button is
  85. /// pressed, makes the frog jump to the coordinates calculated
  86. /// with the a, b, c values provided by the user.
  87. /// \param aa value provided by user to complete the quadratic equation ax^2 + bx + c
  88. /// \param bb value provided by user to complete the quadratic equation ax^2 + bx + c
  89. /// \param cc value provided by user to complete the quadratic equation ax^2 + bx + c
  90. /// \~Spanish
  91. /// \brief Funcion que es invocada cuando el boton de brincar es
  92. /// presionado, hace que el sapo salte a las coordenadas calculadas
  93. /// con los valores de a, b, c proporcionados por el usuario.
  94. /// \param aa valor proporcionado por el usuario utilizado para completar la ecuacion
  95. /// cuadratica ax^2 + bx + c
  96. /// \param bb valor proporcionado por el usuario utilizado para completar la ecuacion
  97. /// cuadratica ax^2 + bx + c
  98. /// \param cc valor proporcionado por el usuario utilizado para completar la ecuacion
  99. /// cuadratica ax^2 + bx + c
  100. void run(int, int, int);
  101. /// \fn void frog::reset()
  102. /// \~English
  103. /// \brief Function that is invoked when the retry button is clicked, resets
  104. /// the frog and the leafs to a random starting position.
  105. /// \~Spanish
  106. /// \brief Funcion que es invocada cuando el boton de "retry" es presionado,
  107. /// restablece el sapo y los nenufares a una posicion de partida aleatoria.
  108. ///
  109. void reset();
  110. /// \fn void frog::updatenenu()
  111. /// \~English
  112. /// \brief Function that updates the position of the frog and the leafs
  113. /// when the frog reaches the end of the screen when it's sliding back.
  114. /// \~Spanish
  115. /// \brief Funcion que actualiza la posicion del sapo y los nenufares
  116. /// cuando el sapo llega al final de la pantalla cuando se desliza hacia atras.
  117. ///
  118. void updatenenu();
  119. protected:
  120. /// \fn void frog::paintEvent(QPaintEvent *event)
  121. /// \~English
  122. /// \brief Function that is invoked each time the widget or
  123. /// its parent receives a repaint signal.
  124. /// \~Spanish
  125. /// \brief Funcion que es invocada automaticamente cada vez que el widget
  126. /// o su padre recive una senal de repintar.
  127. ///
  128. void paintEvent(QPaintEvent *event);
  129. QTimer *myTimer;
  130. };
  131. #endif // FROG_H