Files
volcano_2016/source/volcano.h

209 lines
5.4 KiB
C++

#pragma once
#ifndef VOLCANO_H
#define VOLCANO_H
#include "ifdefs.h"
#include "jail_audio.h"
#include "const.h"
#include "ltexture.h"
struct Tanimation
{
bool loops; // Salta a true cuando se reinicia la animación
Uint16 timer; // Temporizador de la animación
Uint8 frame[50]; // Vector con ....
Uint8 index; // Frame actual
Uint8 num_frames; // Cantidad de frames de la animación
Uint8 speed; // Velocidad de la animación
};
struct Tprogram
{
bool debug;
bool filter;
bool music_enabled; //
LTexture *sprite;
SDL_Rect dst_rect;
SDL_Rect src_rect;
Uint8 section;
};
struct Tgame
{
bool enabled;
JA_Sound sound_drop_enemy;
JA_Sound sound_drop_splat;
JA_Music music;
Uint8 zone; // Zona en la que estamos
};
struct Tmenu
{
bool enabled;
int frame;
int timer;
LTexture *sprite_animation;
LTexture *sprite;
JA_Sound sound_logo;
JA_Sound sound_start;
JA_Music music;
SDL_Rect dst_rect_animation;
SDL_Rect dst_rect_fondo;
SDL_Rect dst_rect_logo_zoom;
SDL_Rect dst_rect_logo;
SDL_Rect dst_rect_text;
SDL_Rect dst_rect_text2;
SDL_Rect src_rect_animation;
SDL_Rect src_rect_fondo;
SDL_Rect src_rect_logo;
SDL_Rect src_rect_text;
SDL_Rect src_rect_text2;
Tanimation animation[2];
Uint8 section;
};
struct Tplayer
{
bool can_jump; // Si puede saltar
bool enabled; // Si está habilitado
bool jump_pressed_before; // Si se ha pulsado el botón de salto previamente
bool jump_pressed_now; // Si se acaba de pulsar el salto
bool key[6]; // Indica las llaves que posee el jugador
bool standing; // Si esta de pie (o quieto?)
bool was_on_background; // Si viene de una zona atravesable
int coins; // Cantidad de monedas
int cooldown; // Tiempo de inhabilitación
int jumpforce; // Cantidad de pixels a desplazarse y velocidad que pilla al saltar
int respawn_x; // Coordenadas para revivir
int respawn_y; // Coordenades para revivir
int speed_x; // Cantidad de pixeles a desplazarse
int speed_y; // Cantidad de pixels a desplazarse
LTexture *sprite; // Textura con los graficos del jugador
JA_Sound sound_coin; // Sonido al coger monedas
JA_Sound sound_death; // Sonido al morir
JA_Sound sound_jump; // Sonido al saltar
SDL_Rect dst_rect; // Rectangulo donde dibujar el sprite del jugador. Es la posición del jugador
SDL_Rect src_rect; // Rectangulo con el dibujo del jugador a pintar
Tanimation animation[8]; // Vector con las animaciones del jugador
Uint8 active_animation; // Animación activa
Uint8 direction; // Sentido del desplazamiento
Uint8 lifes; // Cantidad de vidas
Uint8 respawn_direction; // Dirección para revivir
};
struct Tactor
{
bool enabled;
Uint8 frame;
int speed_x;
int speed_y; // Velocidad = cantidad de pixeles a desplazarse
int timer;
SDL_Rect dst_rect;
SDL_Rect src_rect;
Uint8 direction; // Sentido del desplazamiento
Uint8 id;
Uint8 kind; // Tipo de actor: enemigo, moneda, llave, plataforma ...
Uint8 parent; // Indice al padre del actor
};
struct Tanimated_tile
{
bool enabled;
Uint8 index;
int x;
int y;
Uint8 frame;
};
struct Thud
{
LTexture *sprite;
SDL_Rect src_rect;
SDL_Rect dst_rect;
SDL_Rect num_src_rect;
SDL_Rect num_dst_rect;
SDL_Rect bignum_src_rect;
SDL_Rect bignum_dst_rect;
};
struct Tmap
{
LTexture *sprite_tile;
LTexture *sprite_actor;
LTexture *background;
SDL_Rect src_rect;
SDL_Rect dst_rect;
Uint8 *tile;
Uint8 *actor;
Uint8 w;
Uint8 h;
Uint8 room;
};
bool fullscreen;
bool quit;
const Uint8 *keys;
SDL_Event *event;
SDL_Renderer *renderer;
SDL_Window *window;
std::string executablePath;
Tactor actor[MAX_ACTORS];
Tanimated_tile animated_tile[MAX_ANIMATED_TILES];
Tgame game;
Thud hud;
Tmap map;
Tmenu menu;
Tplayer player;
Tprogram prog;
Uint32 delta_time;
bool CheckZoneChange(int room);
bool loadTextureFromFile(LTexture *texture, std::string path, SDL_Renderer *renderer);
bool OnFloor();
Uint8 GetActor(Uint8 x, Uint8 y);
Uint8 GetTile(Uint8 x, Uint8 y);
Uint8 ReadMapTile(Uint8 x, Uint8 y);
void allocatePointers();
void Animate(Tanimation &a, SDL_Rect &s);
void AnimateIntroMenu(Tanimation &a, SDL_Rect &s);
void ApplyGravity();
void CheckPlayerCollisionWithActors();
void CheckPlayerCollisionWithActors();
void CheckPlayerCollisionWithMap();
void CloseMusic(JA_Music music);
void ClosePicture(LTexture *picture);
void CloseSound(JA_Sound sound);
void CreateActor(Tactor &a, Uint8 kind, Uint8 id, Sint16 dstx, Sint16 dsty, Sint16 dstw, Sint16 dsth, Sint16 srcx, Sint16 srcy, Sint16 sx, Sint16 sy, Sint16 timer, Sint16 frame, Uint8 direction, Uint8 parent);
void DrawHud();
void DrawMap();
void DrawSprite(LTexture *sprite, SDL_Rect src_rect, SDL_Rect dst_rect);
void EndGame();
void EndHud();
void EndMap();
void EndMenu();
void EndPlayer();
void EndProgram();
void IniActors();
void IniAnimatedTiles();
void IniGame(Uint8 zone);
void IniHud();
void IniMap();
void IniMenu();
void IniPlayer();
void IniProgram();
void KillPlayer();
void LoadMap();
void LoadRoom(int num);
void MoveActors();
void MovePlayer(int direction);
void SetActor(Uint8 x, Uint8 y, Uint8 valor);
void setExecutablePath(std::string path);
void SetMapGFX(Uint8 zone);
void SetMapMusic(Uint8 zone);
void SetPlayerAnimation(Uint8 anim);
void SetPlayerDirection(int direction);
void SetProgSection(Uint8 section);
void SetZone(int room);
#endif