Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - wardi2331

Pages: [1]
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:
-----------------------------------------------------------
[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]
-----------------------------------------------------------------

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]
----------------------------------------------------------------

object class :
----------------------------------------------------------------
class objects :
        public building
{
public:
        objects(float posix,float posiy,float sizx,float sizy,string filee);
        objects(void);
        ~objects(void);



};
 
[/color]
------------------------------------------------
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]

Pages: [1]