Actualizado el fichero utils.h a una versión posterior

This commit is contained in:
2022-08-08 18:39:51 +02:00
parent 386039336e
commit 55c26df2a5
2 changed files with 147 additions and 33 deletions

View File

@@ -1,35 +1,40 @@
#pragma once
#include "ifdefs.h"
#include "ltexture.h"
#include <string>
#ifndef UTILS_H
#define UTILS_H
#define DIFFICULTY_EASY 0
#define DIFFICULTY_NORMAL 1
#define DIFFICULTY_HARD 2
// Estructura para definir un circulo
struct Circle
struct circle_t
{
Uint16 x;
Uint16 y;
Uint8 r;
int x;
int y;
int r;
};
// Estructura para definir todas las entradas que aceptará el programa
struct Input
// Estructura para definir un color
struct color_t
{
Uint8 up;
Uint8 down;
Uint8 left;
Uint8 right;
Uint8 escape;
Uint8 pause;
Uint8 fire;
Uint8 fireLeft;
Uint8 fireRight;
Uint8 accept;
Uint8 cancel;
Uint8 r;
Uint8 g;
Uint8 b;
};
// Estructura para saber la seccion y subseccion del programa
struct section_t
{
Uint8 name;
Uint8 subsection;
};
// Estructura para mapear el teclado usado en la demo
struct DemoKeys
struct demoKeys_t
{
Uint8 left;
Uint8 right;
@@ -39,16 +44,42 @@ struct DemoKeys
Uint8 fireRight;
};
// Estructura para albergar métodos de control
struct input_t
{
int id; // Identificador en el vector de mandos
std::string name; // Nombre del dispositivo
Uint8 deviceType; // Tipo de dispositivo (teclado o mando)
};
// Estructura con todas las opciones de configuración del programa
struct options_t
{
Uint8 difficulty; // Dificultad del juego
input_t input[2]; // Modo de control (teclado o mando)
Uint8 language; // Idioma usado en el juego
Uint32 fullScreenMode; // Contiene el valor del modo de pantalla completa
Uint8 windowSize; // Contiene el valor del tamaño de la ventana
Uint32 filter; // Filtro usado para el escalado de la imagen
bool vSync; // Indica si se quiere usar vsync o no
};
// Calcula el cuadrado de la distancia entre dos puntos
double distanceSquared(int x1, int y1, int x2, int y2);
// Detector de colisiones entre dos circulos
bool checkCollision(Circle &a, Circle &b);
bool checkCollision(circle_t &a, circle_t &b);
// Detector de colisiones entre un circulo y un rectangulo
bool checkCollision(Circle &a, SDL_Rect &b);
bool checkCollision(circle_t &a, SDL_Rect &b);
// Detector de colisiones entre un dos rectangulos
bool checkCollision(SDL_Rect a, SDL_Rect b);
bool checkCollision(SDL_Rect &a, SDL_Rect &b);
// Carga un archivo de imagen en una textura
bool loadTextureFromFile(LTexture *texture, std::string path, SDL_Renderer *renderer);
// Devuelve un color_t a partir de un string
color_t stringToColor(std::string str);
#endif