Advertisement
eliasYFGM

Juego de plataformas en C++/Allegro (Juego.h)

Jul 21st, 2018
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. // Juego.h
  2. // Base para juego de plataformas en C++ y Allegro
  3.  
  4. #ifndef JUEGO_H_INCLUDED
  5. #define JUEGO_H_INCLUDED
  6.  
  7.  
  8. // Allegro
  9. #include <allegro5/allegro.h>
  10.  
  11.  
  12. // Macros de color
  13. #define C_NEGRO   al_map_rgb(0, 0, 0)
  14. #define C_BLANCO  al_map_rgb(255, 255, 255)
  15.  
  16. // Macro para checar colisiones "bounding box"
  17. #define bbox_collision(x1,y1,w1,h1,x2,y2,w2,h2) \
  18.    (!(((x1)>=(x2)+(w2)) || ((x2)>=(x1)+(w1)) || \
  19.       ((y1)>=(y2)+(h2)) || ((y2)>=(y1)+(h1))))
  20.  
  21. // Tamaño del jugador, usado para checar una posición libre y dibujarlo
  22. #define TAMANO_JUGADOR_X   32
  23. #define TAMANO_JUGADOR_Y   32
  24.  
  25. // Tamaño en columnas por defecto de los niveles
  26. #define TAMANO_NIVEL_X     25
  27.  
  28.  
  29. class Juego
  30. {  // Indicar si el juego inició correctamente
  31.    bool iniciado;
  32.  
  33.    // Variables del jugador/player
  34.    float jugador_x, jugador_y;
  35.    float jugador_x_inicio, jugador_y_inicio;
  36.  
  37.    // Ventana (display)
  38.    ALLEGRO_DISPLAY *ventana;
  39.  
  40.    // Timer que controla los FPS
  41.    ALLEGRO_TIMER *timer;
  42.  
  43.    // Lista donde surgen los eventos de Allegro
  44.    ALLEGRO_EVENT_QUEUE *lista_eventos;
  45.  
  46.    // Array para almacenar las pulsaciones del teclado
  47.    int *key;
  48.  
  49.  
  50.    bool Inicializar();
  51.    void Actualizar();
  52.    void Dibujar();
  53.  
  54. public:
  55.    Juego();
  56.  
  57.    void Correr();
  58. };
  59.  
  60.  
  61. #endif // JUEGO_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement