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.


Topics - Chivos

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

2
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.

3
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.

4
General / Image Class Question
« on: January 07, 2013, 04:30:42 am »
class Graphics
{

    public:

        Graphics();

        ~Graphics();


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


                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;

};


 

I have been trying to work out a class that will handle my graphics. The issue that the image and sprite are staying private despite my return. After search around, I have run into similar code and tried some other methods; however, I have been met with a wall here. I apologize if this is a dumb question, but I have just started learning classes, and the book does not show any other methods other than get and set. Any help would be greatly appreciated.   

5
Graphics / Turn Based Game
« on: January 03, 2013, 08:05:27 am »
I am relatively new to c++ and SFML. For the purpose of practice, I figured I would try to complete a blackjack program. The approach I have taken is simply (deal, check-for-blackjacks-player one turn- player two turn, etc..) I have a basic game working; however, when attempting to add an option to split, I have come across a problem. I cannot change the position of the original dealt cards because I do not run the App.Draw for it until the game-loop resets.

Is there a way to delete a single sprite without redrawing? Or a way to hide it behind the background? Or something to get rid of it without needing to make the game one giant loop? any help would be... helpful ;) 

Pages: [1]