#ifndef ELEMENTAL_H
#define ELEMENTAL_H
#include "SDL_init.h"
#include "Sprite.h"
class Elemental: public Game::Sprite{
public:
Elemental( SDL_Surface* img, int x, int y );
//virtual ~Sprite(); // Destructor.
void tick(); // Loop which controls and updates a specific sprite object with the background objects.
SDL_Surface* get_image();
double getSpeed_X(); // Will get the speed ( x ) of the object
double getSpeed_Y(); // Will get the speed ( y ) of the object
void set_speed( double x, double y ); // Will set the speed ( x ) of the object
void move(); // Will be in main class
void show(); // Will be in main class
void install_sprite( std::string filename );
void delete_sprite();
protected:
private:
double speed_x, speed_y, x_pos, y_pos;
SDL_Surface* sprite_image;
SDL_Rect ebox;
};
#endif
/*********************************************************
This is the root class for all gameobjects.
**********************************************************/
#ifndef SPRITE_H
#define SPRITE_H
#include "SDL_init.h"
#include <string>
constint SPRITE_WIDTH = 50;
constint SPRITE_HEIGHT = 56;
namespace Game
{
class Sprite
{
public:
Sprite();
Sprite( std::string filename ); // Constructor.
Sprite::Sprite( SDL_Surface* img );
//virtual ~Sprite(); // Destructor.
virtualvoid tick(); // Loop which controls and updates a specific sprite object with the background objects.
SDL_Surface* get_image();
double getPos_X(); // Will get the x position of the object
double getPos_Y(); // Will get the y position of the object
double getSpeed_X(); // Will get the speed ( x ) of the object
double getSpeed_Y(); // Will get the speed ( y ) of the object
void move_sprite(double x, double y ); // Moves the sprite object to a specific position.
void move();
void show();
void set_pos( double x, double y );// Will set the position ( x ) of the object
void set_speed( double x, double y ); // Will set the speed ( x ) of the object
void install_sprite( /*Sprite* installed,*/ std::string filename );
void delete_sprite( /*Sprite* deleted */);
//Sprite* getInstance(); // Will create a neW sprite object and place it on the screen.
protected:
//Sprite() {};
private:
double speed_x, speed_y, x_pos, y_pos;
SDL_Surface* sprite_image;
SDL_Rect box;
bool jumped;
};
}
#endif
/*********************************************************
This is the root class for all gameobjects.
**********************************************************/
#ifndef SPRITE_H
#define SPRITE_H
#include "SDL_init.h"
#include <string>
constint SPRITE_WIDTH = 50;
constint SPRITE_HEIGHT = 56;
namespace Game
{
class Sprite
{
public:
Sprite();
Sprite( std::string filename ); // Constructor.
Sprite::Sprite( SDL_Surface* img );
//virtual ~Sprite(); // Destructor.
virtualvoid tick(); // Loop which controls and updates a specific sprite object with the background objects.
SDL_Surface* get_image();
void set_image( SDL_Surface* image );
double getPos_X(); // Will get the x position of the object
double getPos_Y(); // Will get the y position of the object
double getSpeed_X(); // Will get the speed ( x ) of the object
double getSpeed_Y(); // Will get the speed ( y ) of the object
void move_sprite(double x, double y ); // Moves the sprite object to a specific position.
virtualvoid move();
void show();
void set_pos( double x, double y );// Will set the position ( x ) of the object
void set_speed( double x, double y ); // Will set the speed ( x ) of the object
void install_sprite( /*Sprite* installed,*/ std::string filename );
void delete_sprite( /*Sprite* deleted */);
//Sprite* getInstance(); // Will create a neW sprite object and place it on the screen.
protected:
//Sprite() {};
private:
double speed_x, speed_y, x_pos, y_pos;
SDL_Surface* sprite_image, optimized_image;
SDL_Rect box;
bool jumped;
};
}
#endif
#ifndef ELEMENTAL_H
#define ELEMENTAL_H
#include "SDL_init.h"
#include "Sprite.h"
class Elemental: public Game::Sprite{
public:
Elemental();
Elemental( SDL_Surface* img, int x, int y );
//virtual ~Sprite(); // Destructor.
void tick(); // Loop which controls and updates a specific sprite object with the background objects.
SDL_Surface* get_image();
double getSpeed_X(); // Will get the speed ( x ) of the object
double getSpeed_Y(); // Will get the speed ( y ) of the object
void set_speed( double x ); // Will set the speed ( x ) of the object
int init( std::string filename, SDL_Surface* dest );
void draw();
void move(); // Will be in main class
void show(); // Will be in main class
void install_sprite( std::string filename );
void delete_sprite();
protected:
private:
double speed_x, x_pos, y_pos;
int isPainted;
SDL_Surface* sprite_image;
SDL_Surface* escreen;
SDL_Rect ebox;
};
#endif
You haven't defined the body of your default constructor for Element. Since you declared a default constructor (Elemental::Elemental( )), you've over-ridden the default constructor provided by the complier. When you override a constructor or destructor, must define its body, no questions asked.
I'm sorry, I should have explained it properly. When a user-defined constructor is declared, you override the default constructor, meaning that the compiler doesn't provide a constructor. Instead, the compiler will use the user-defined constructor, not the default one. This is the same for the destructor.
There's a general rule that you should follow: Always declare a constructor without parameters (equivalent to void) if appropriate.