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

Pages: [1] 2
1
General / Re: Valgrind with SFML
« on: April 16, 2013, 05:08:05 pm »
Thank you very much binary1248!!! Updated graphics drivers and it solved my problem!! ;)

2
General / Re: Valgrind with SFML
« on: April 16, 2013, 07:34:14 am »
I am having the exact same problem. I have also switched to 2.0 to see if that would help. The number of errors is still ridiculously high. I have to crash out, but I think tomorrow I will just try to reinstall Valgrind or something. If anyone has any ideas, please feel free to chime in, I am at a lose! :(


Just checked again, Valgrind still works as long as nothing SFML touches it heh. ALL day because I wanted to see if I had any memory leaks lol ;)

3
General / Re: Valgrind with SFML
« on: April 16, 2013, 02:36:56 am »
lol, i'm still using 1.6.. I know.. I know heheh ;)

I DL'd with the repository

I am pretty sure I am linked the correct libraries. I do not think it would compile if not. When I compile it to run valgrind on it, I use this.

g++  main.cpp /usr/lib/libsfml-window.so.1.6 /usr/lib/libsfml-graphics.so.1.6 -o test

to run:

valgrind --leak-check=full  ./test

main.cpp includes <SFML/Graphics.hpp> and has an int main(){return 0;}

As far as the errors, there are 2.6million so I assume they don't mean much as it is something else I am doing wrong heh.

4
General / Valgrind with SFML
« on: April 16, 2013, 01:54:45 am »
I have been working on getting Valgrind to work all day. Valgrind works well when I do not include any SFML headers, but the second I include <SFML/Graphics.hpp>, I get something like 2.6million errors. Obviously there is no way that this is being caused by SFML lol, but I am not sure what to do about it. Does anyone know why this might be happening? Any advice or help would be greatly appreciated! ;)

5
General / Problem with game loop
« on: January 09, 2013, 06:14:42 am »
I am relatively new to OOP. I have been working on this problem for awhile and cannot find a good way to do it.

In my class I have:

Code: [Select]
int GetNextCard(int &ReturnCard)                               //Idea is to set ReturnCard to the last element, then delete the element
    {                                                                                     
        ReturnCard = cards.back();
        cards.pop_back();
        return ReturnCard;
    }

void SetNextCard(std::vector<int> &NextCard, int  &ReturnCard)     //Idea is to add to a new vector what the value of returncard
{                                                                                                                       //This is done so I can use something like sprite[NextCard]
  NextCard.push_back(ReturnCard);                                                       //instead of sprite[0] or sprite[1]
}                                                                                                                       //I want to use this method because for htis and splits
                                                                                                                        //the sprite[0] method seems difficult to use as there is no
void dealcardone(sf::RenderTarget& App, int x, int y)                         //way to determine how many cards have gone out from
{                                                                                                                      //player to play.
    if (fStop == true)
    {
        GetNextCard(ReturnCard);                                      //This is my draw function, uses bool to ensure it only runs once
        SetNextCard(NextCard, ReturnCard);
        fStop = false;
    }
        SpriteCard[ReturnCard].SetPosition(x,y);
        App.Draw(SpriteCard[NextCard[0]]);
}

void dealcardtwo(sf::RenderTarget& App, int x, int y)
{
    if (fStop2 == true)
    {
        GetNextCard(ReturnCard);
        SetNextCard(NextCard, ReturnCard);
        fStop2 = false;
    }
        SpriteCard[ReturnCard].SetPosition(x,y);
        App.Draw(SpriteCard[NextCard[1]]);
}


The problem is that the second time the main game loop runs, the first card gets changed to the second same card. I know why it is happening. It is happening because the second time through when it redraws the value of NextCard has grown, so it changes. I do not see a good way around this well keeping the cards in the main game loop. The cards must stay in the main game loop though, as I will have to change the position of a card if the player splits. Can anyone point me in the right direction as to what I need to do here? Any help would be greatly appreciated.

6
General / Re: Sprite Management question
« on: January 07, 2013, 10:00:02 pm »
Wow.... nvm I figured it out.. sorry for all the confusion.

7
General / Re: Sprite Management question
« on: January 07, 2013, 09:43:05 pm »
ya, I pretty much failed on the clearing up of the question. I make sure to use proper code tags for future posts.

Anyway, I have tried to overload the virtual function but I get an error that says that the function cannot be overloaded. I think I am looking at this the wrong way and I need to implement a different strategy. What brought this all on was that I wanted my sf::Image and sf::Sprite to be private. After asking on these boards, someone mentioned inheriting from sf::Drawable, and writing a virtual function to display the sprite. I have accomplished this through the code i have posted in the forum; however, I am implementing a second  sf::Image and sf::Sprite in private. I am attempting to follow the same method; however,
 
Code: [Select]
void Graphics::Render(sf::RenderTarget& App) const
{
    App.Draw(spriteBJtable);
}

will only display spriteBJtable.

So, I was trying to figure out a way to, App.Draw(chosensprite), instead of a fixed one; however, I have not found a way to do so.

Hopefully this helps clear things up a bit.

8
General / Re: Sprite Management question
« on: January 07, 2013, 09:01:04 pm »
Alright, let me try to clear up my question a bit ;)

Code: [Select]

class Graphics : public sf::Drawable
{
    public:
        Graphics(){};
        ~Graphics(){};

virtual void Render(sf::RenderTarget& App) const;
void loadBJtable();
void sprite_loadBJtable();

void loadBCard();
void sprite_loadBCard();



    private:

sf::Image BJtable;
sf::Sprite spriteBJtable;

sf::Image BCard;
sf::Sprite spriteBCard;

};




Currently, to display the BJtable, I am using
Code: [Select]
virtual void Render(sf::RenderTarget& App) const;
[code]

[code]
void Graphics::Render(sf::RenderTarget& App) const
{
    App.Draw(spriteBJtable);
}

in main
Code: [Select]
Graphic.Render(App);

I would like to be able to use the virtual function to also display spriteBCard, not just spriteBJtable. ;)

9
General / Re: Sprite Management question
« on: January 07, 2013, 08:31:43 pm »
The class is inherting from drawable. Every time i try to overload the function, I get a compiler error that says the class is a pure virtual class. The error brings me to the Render(sf::RenderTarget& App) const function in drawable.hpp.

The purpose of the string was to allow a string to pass in so I could set it to a different sprite. something like:

Code: [Select]
void load(std::string file)
{
imgBGone.LoadFromFile(file);
}

so that I can set the name of the sprite to load.

10
General / Sprite Management question
« on: January 07, 2013, 08:16:47 pm »
I am working on an image manager. To do so, I have used a virtual function in my class to do my drawing.

Code: [Select]
virtual void Render(sf::RenderTarget& App) const;

Code: [Select]
void Graphics::Render(sf::RenderTarget& App) const
{
    App.Draw(spriteBJtable);
}

The issue is that I would like to use this same function to draw other sprites, but it seems that I cannot overload the function to include a string for the sprite.

Is there anyway to allow the sprite being drawn to be sent into the function so that I can use this draw function to draw multiple sprites in my manager? Any help would be greatly appreciated.

11
General / Re: Image Class Question
« on: January 07, 2013, 08:44:29 am »
Solved!!! Ty everyone for your help..  here is the solution for anyone else running into this problem ;)

class Graphics : public sf::Drawable
{

    public:

        Graphics(){};

        ~Graphics(){};


        sf::Sprite &GetSprite(){return spriteBJtable;}
        sf::Image GetImage(){return BJtable;}


virtual void Render(sf::RenderTarget& App) const
{


    App.Draw(spriteBJtable);
}

                void loadBJtable()
                {
                        BJtable.LoadFromFile("realbj.jpg");
                }

                void sprite_loadBJtable()
                {
                        spriteBJtable.SetImage(BJtable);
                        spriteBJtable.Resize(800,600);
                }



    private:

        sf::Image BJtable;
        sf::Sprite spriteBJtable;

};

 

12
General / Re: Image Class Question
« on: January 07, 2013, 08:37:18 am »
I'm continuing to read and plug away at this.

 Currently:
class Graphics : public sf::Drawable // this should set up the inhert

//and

virtual void Render(sf::RenderTarget& App) const
{

    sf::Image bjtable;
    bjtable.LoadFromFile("realbj.jpg");

    sf::Sprite spriteBtab;
    spriteBtab.SetImage(bjtable);
    spriteBtab.Resize(800,600);

    App.Draw(spriteBJtable);
}

//is what I have for my draw function
 

I noticed that if I tried to use any other parameters for the virtual function the compiler complained about it being a pure virtual function. I am assuming it is pure because it is taking
virtual void Render(sf::RenderTarget& Target) const
 

from drawable.hpp...

The issue is that my current draw function is not drawing anything. I am getting a default black screen.


Also

virtual void Render(sf::RenderTarget& App) const
{

    BJtable.LoadFromFile("realbj.jpg");

    spriteBJtable.SetImage(BJtable);
    spriteBJtable.Resize(800,600);

    App.Draw(spriteBJtable);
}

 

I tried this to see if the sprite and image were being passed in, and I am receiving some errors.

what am I missing here?

13
General / Re: Image Class Question
« on: January 07, 2013, 07:06:43 am »
class Graphics : public sf::Drawable
{

    public:

        Graphics(){};

        ~Graphics(){};


        sf::Sprite &GetSprite(){return spriteBJtable;}
        sf::Image GetImage(){return BJtable;}



    virtual void Draw(RenderWindow& App)
     {
        App.Draw(spriteBJtable);
     }




                void loadBJtable(std::string file)
                {
                        BJtable.LoadFromFile(file);
                }

                void sprite_loadBJtable(sf::Image& pic)
                {
                        spriteBJtable.SetImage(pic);
                        spriteBJtable.Resize(800,600);
                }


    private:


        sf::Image BJtable;
        sf::Sprite spriteBJtable;

};


 

Can anyone let me know if I am on the right track here or am I completely off base?

14
General / Re: Image Class Question
« on: January 07, 2013, 06:18:47 am »
I completely agree. That is the main reason why I am focusing on making sf::image and sf::sprite private variables. It is easy to take the easy way out, but I want to learn good programming practice as it will be of great benefit in the end; however, that can be difficult considering I am not even sure where to start haha. I am just doing some reading to try to figure out how to inherit from sf::drawable and virtual functions. Thank you all for your responses.

15
General / Re: Image Class Question
« on: January 07, 2013, 05:49:55 am »
"If you want to draw the sprite that is contained in the class then have it inherit from sf::Drawable and draw your sprite in the virtual draw function."

  I think I see what you are saying. I am getting the same error because I have not inherited from sf::drawable or attempted to draw the sprite in a virtual draw function. I think this was easier when I was okay with the sprite being a public member lol. Alright, inherit and virtual functions, two things I have not worked with. Going to do some reading and testing! Thank you for your help! If you wish to add anything feel free. ;)


Pages: [1] 2
anything