store States to heap so that State memory adresses stay same
This commit is contained in:
11
Animal.h
11
Animal.h
@@ -30,6 +30,13 @@ class State {
|
||||
|
||||
vector<SDL_Surface *> imgs;
|
||||
SoundData sound_data;
|
||||
~State() {
|
||||
for (unsigned i = 0; i < imgs.size(); i++) {
|
||||
if (imgs[i]) {
|
||||
SDL_DestroySurface(imgs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class Animal {
|
||||
@@ -40,7 +47,7 @@ class 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 readSkinFill(string skin, State &state);
|
||||
void createShape(int num, int w, int h);
|
||||
void move();
|
||||
void animate(bool reset);
|
||||
@@ -57,7 +64,7 @@ class Animal {
|
||||
|
||||
SDL_Rect disp_pos; // has display width and height and window posiion on it
|
||||
|
||||
vector<State> states;
|
||||
vector<State *> states;
|
||||
vector<State *> special_states;
|
||||
State *cur_state;
|
||||
vector<State *> random_states;
|
||||
|
||||
Reference in New Issue
Block a user