forked from jaildesigner-jailgames/jaildoctors_dilemma
85 lines
2.0 KiB
C++
85 lines
2.0 KiB
C++
#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_t
|
|
{
|
|
int x;
|
|
int y;
|
|
int r;
|
|
};
|
|
|
|
// Estructura para definir un color
|
|
struct color_t
|
|
{
|
|
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_t
|
|
{
|
|
Uint8 left;
|
|
Uint8 right;
|
|
Uint8 noInput;
|
|
Uint8 fire;
|
|
Uint8 fireLeft;
|
|
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_t &a, circle_t &b);
|
|
|
|
// Detector de colisiones entre un circulo y un rectangulo
|
|
bool checkCollision(circle_t &a, SDL_Rect &b);
|
|
|
|
// Detector de colisiones entre un dos rectangulos
|
|
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 |