Tried that...well I'll post all code...can't continue untill this is solved =(
#ifndef SPRITE_H #define SPRITE_H #include "shared.h"// A single frame in the animation struct frame { int delay; // The number of milliseconds to wait before next frame std::string path; // The path to the frame SDL_Surface *img; // The image of the frame }; // A whole animation struct animation { std::string name; // The name of the animation, the name of the folder the frames are in int framenr; // Keeping track of which frame we are currently viewing int frametime; std::vector<frame> frames; // All frames }; // A basic animated sprite class sprite { public: sprite(); ~sprite(); // Self explained just look at the names int getx(); int gety(); int getw(); int geth(); SDL_Rect getrect(); std::string getanimation(); void setx(int x); void sety(int y); void setw(int w); void seth(int h); void setrect(SDL_Rect rect); void setanimation(std::string name); void addx(int add); void addy(int add); // This function loads a sprite from a directory, first it checks how many different animations // the sprite has, then loads the frames of every animation. The width and height of the sprite // is decided by the first frame of the first animation bool load(std::string dir, SDL_Surface *dest); // This function draws the sprite, it animates automatically, if it isn't paused void draw(); // Animation controls void pause(); void resume(); void reset(); void setcolorkey(char r, char g, char b); private: SDL_Rect m_rect; // The rect of the sprite x,y,width and height values int m_animation; // Keeps track of which animation we are on int m_lastframe; // Keeps track of how many milliseconds it has been since the last frame std::vector<animation> m_animations; // Every animation SDL_Surface *m_dest; // The surface to draw to bool m_paused; // Is the animation paused? }; #endif
#ifndef SHARED_H#define SHARED_H#include <iostream>#include <stdarg.h>#include <fstream>#include <string>#include <vector>#include <SDL/SDL.h>#include <SDL/SDL_image.h>#include <SDL/SDL_mixer.h>#include <SDL/SDL_ttf.h>#include <ctime>#include "font.h"#include "framerate.h"#include "img_manager.h"#include "log.h"#include "settings_manager.h"#include "sound_manager.h"#include "sprite.h"#include "game.h"#include "ship.h"#endif
#ifndef SHIP_H#define SHIP_H#include "shared.h"class ship { public: ship(); ~ship(); void shoot(); void die(); bool collide(); private: sprite m_ship; int m_lives;};#endif