forked from jaildesigner-jailgames/coffee_crisis
54 lines
995 B
C
54 lines
995 B
C
#pragma once
|
|
#include "ifdefs.h"
|
|
|
|
#ifndef UTILS_H
|
|
#define UTILS_H
|
|
|
|
// Estructura para definir un circulo
|
|
struct circle_t
|
|
{
|
|
Uint16 x;
|
|
Uint16 y;
|
|
Uint8 r;
|
|
};
|
|
|
|
// Estructura para definir todas las entradas que aceptará el programa
|
|
struct input_t
|
|
{
|
|
Uint8 up;
|
|
Uint8 down;
|
|
Uint8 left;
|
|
Uint8 right;
|
|
Uint8 escape;
|
|
Uint8 pause;
|
|
Uint8 fire;
|
|
Uint8 fireLeft;
|
|
Uint8 fireRight;
|
|
Uint8 accept;
|
|
Uint8 cancel;
|
|
};
|
|
|
|
// Estructura para mapear el teclado usado en la demo
|
|
struct demoKeys_t
|
|
{
|
|
Uint8 left;
|
|
Uint8 right;
|
|
Uint8 noInput;
|
|
Uint8 fire;
|
|
Uint8 fireLeft;
|
|
Uint8 fireRight;
|
|
};
|
|
|
|
// 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);
|
|
|
|
#endif |