1
General / How to destroy a class object (destroy all data of this object)
« on: November 02, 2018, 12:48:53 pm »
hello everybody im asking if there someone can help me ,im working RPG game and i divise my program to classes as that:
building
actors: inherte from building
houses: inherte from building
platforms: inherte from building
objects: inherte from building
for exemple
class of building:
-----------------------------------------------------------
class of actors
-------------------------------------------
object class :
----------------------------------------------------------------
------------------------------------------------
in the main :
-----------------------------------
building
actors: inherte from building
houses: inherte from building
platforms: inherte from building
objects: inherte from building
for exemple
class of building:
-----------------------------------------------------------
[color=green]class building
{
public:
building(float xpos,float ypos, float size_x, float size_y,string file);
building(void);
~building(void);
void add_texture(string file);
void position_input(float xpos,float ypos);
float position_output(string var);
void scale_input(float width,float height);
void sprite_cadre(int xh,int yh,int xl,int yl);
void charger_texture(void);
void smoothing(void);
Sprite core(void);
protected:
struct position
{
float x;
float y;
}position;
struct size
{
float xsize;
float ysize;
}size;
struct frame
{
int xh;
int yh;
int xl;
int yl;
}frame;
string fichier;
Texture ma_texture;
Sprite ma_sprite;
};[/color]
-----------------------------------------------------------------{
public:
building(float xpos,float ypos, float size_x, float size_y,string file);
building(void);
~building(void);
void add_texture(string file);
void position_input(float xpos,float ypos);
float position_output(string var);
void scale_input(float width,float height);
void sprite_cadre(int xh,int yh,int xl,int yl);
void charger_texture(void);
void smoothing(void);
Sprite core(void);
protected:
struct position
{
float x;
float y;
}position;
struct size
{
float xsize;
float ysize;
}size;
struct frame
{
int xh;
int yh;
int xl;
int yl;
}frame;
string fichier;
Texture ma_texture;
Sprite ma_sprite;
};[/color]
class of actors
-------------------------------------------
[color=red]class objects;
class actors : public building
{
public:
actors(float posx,float posy,float size_xa,float size_ya,string file_a,unsigned int vitesse);
actors(void);
~actors(void);
void animation(unsigned int vitesse,bool autonome=false);
void set_animation(Vector2i anima);
void moving_core(void);
void stoping_core(void);
void colision(objects *the_object,bool contact,int object_type);
void new_position(int at_x,int at_y);
private:
Vector2i animat;
Clock time;
unsigned int Vitesse;
struct last_pos
{
float x_last;
float y_last;
}last_pos;
};[/color]
----------------------------------------------------------------class actors : public building
{
public:
actors(float posx,float posy,float size_xa,float size_ya,string file_a,unsigned int vitesse);
actors(void);
~actors(void);
void animation(unsigned int vitesse,bool autonome=false);
void set_animation(Vector2i anima);
void moving_core(void);
void stoping_core(void);
void colision(objects *the_object,bool contact,int object_type);
void new_position(int at_x,int at_y);
private:
Vector2i animat;
Clock time;
unsigned int Vitesse;
struct last_pos
{
float x_last;
float y_last;
}last_pos;
};[/color]
object class :
----------------------------------------------------------------
class objects :
public building
{
public:
objects(float posix,float posiy,float sizx,float sizy,string filee);
objects(void);
~objects(void);
};
[/color]public building
{
public:
objects(float posix,float posiy,float sizx,float sizy,string filee);
objects(void);
~objects(void);
};
------------------------------------------------
in the main :
-----------------------------------
actors my_actor(20,20,1,1,"myactor.png");
objects obj(40,40,1,1,"myobj.png");
my_actor.collision(obj);// i need a methode to destroy object when collision become true
[/color]
objects obj(40,40,1,1,"myobj.png");
my_actor.collision(obj);// i need a methode to destroy object when collision become true