initial commit
This commit is contained in:
75
Animal.h
Normal file
75
Animal.h
Normal file
@@ -0,0 +1,75 @@
|
||||
#ifndef ANIMAL_H
|
||||
#define ANIMAL_H
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3_image/SDL_image.h>
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "SoundData.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// These States have something special logic in code (other than just randomly picked)
|
||||
enum SpecialState { NOTHING, stay, drop, jump, jump_end, flop, hang, fast_right, fast_left, SPECIAL_STATE_LAST };
|
||||
|
||||
|
||||
class State {
|
||||
public:
|
||||
string name;
|
||||
string img_name;
|
||||
int count;
|
||||
int interval;
|
||||
int x;
|
||||
int y;
|
||||
string sound;
|
||||
SpecialState special;
|
||||
bool interruptable;
|
||||
|
||||
vector<SDL_Surface *> imgs;
|
||||
SoundData sound_data;
|
||||
};
|
||||
|
||||
class Animal {
|
||||
public:
|
||||
|
||||
Animal(string skin);
|
||||
~Animal();
|
||||
SDL_Surface *readImg(string skin, string state_name, int num);
|
||||
void readSkin(string file);
|
||||
void readSkinStep(string skin, char chr, string &buf, string &key, State &state, char &prev_chr);
|
||||
void readSkinFill(string skin, State state);
|
||||
void createShape(int num, int w, int h);
|
||||
void move();
|
||||
void animate(bool reset);
|
||||
void shuffle();
|
||||
void setState(State *s);
|
||||
void setSpecialState(SpecialState s);
|
||||
void resetTimes(Uint64 t);
|
||||
Uint64 step(Uint64 cur, bool press);
|
||||
SDL_Surface *getImage();
|
||||
SoundData *getSound();
|
||||
bool hasStateChanged();
|
||||
void shouldRunAway(char dir);
|
||||
SDL_Surface *getPreviewSurface();
|
||||
|
||||
SDL_Rect disp_pos; // has display width and height and window posiion on it
|
||||
|
||||
vector<State> states;
|
||||
vector<State *> special_states;
|
||||
State *cur_state;
|
||||
vector<State *> random_states;
|
||||
|
||||
int animation_i;
|
||||
|
||||
Uint64 move_time;
|
||||
Uint64 animate_time;
|
||||
Uint64 random_time;
|
||||
Uint64 cur;
|
||||
bool viime_event;
|
||||
bool state_changed;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user