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

Pages: [1]
1
Graphics / Render window pointer and sprites
« on: August 31, 2012, 12:37:08 pm »
I'm trying to load sprites through the renderwindow that I'm pointing to, it seems to work fine without errors, but when loading a sprite all I get is the white dot. I've tried everything I can think of, and still it refuses to render.

.h
class Invador
{
public:
Invador(sf::RenderWindow& window) :
        m_window(window)
                {}

    float Draw()
    {
                imag.LoadFromFile("sprite.png");
                sprite.SetPosition(10,1);
        m_window.Draw(sprite);
                return 0;
    }

private:
    sf::RenderWindow& m_window;
        sf::Image imag;
        sf::Sprite sprite;
       
};
 

main
int main()
{
sf::RenderWindow window(sf::VideoMode(SC_WIDTH, SC_HEIGHT, 32), "SFML Window");

Invador Draw(window);

while (window.IsOpened())
     {
         sf::Event Event;
         while (window.GetEvent(Event))
         {
             if (Event.Type == sf::Event::Closed)
                 window.Close();
         }
 
                 float elapsedTime = window.GetFrameTime();

                 /*cout << elapsedTime * 100 << endl;*/

         window.Clear();
                 Draw.Draw();

         window.Display();
     }
        return EXIT_SUCCESS;
}
 

2
Graphics / Member function sprite call
« on: August 29, 2012, 02:43:24 pm »
Hi,
I used the example that is on the sfml doc pages that uses member functions as image management. http://www.sfml-dev.org/tutorials/1.4/graphics-sprite.php

And I implemented it fine, no errors. But I'm confused as how to call it? Because you need to apply it to the render window and call the sprite itself, but the render window is defined in my main, and my sprite is defined inside my class.

3
System / Applying clock to movements
« on: August 10, 2012, 03:52:55 pm »
In my game app I have moving sprites, but without them being tied to a clock they just fly across the screen. So I need help fixing my clock code so that my sprites move with the clock timer.

                 Sprite.Move(-1 * elapsedTime ,0);
                 if(elapsedTime>REFRESH_RATE){
                        // get current system time
                        GetSystemTime(&st);
                         if(Sprite.GetPosition().x <= 50)
                                 {
                                        Sprite.Move(0, 10 * elapsedTime);
                                 } else if (Sprite.GetPosition().y == 60)
                                 {
                                         Sprite.Move(1 * elapsedTime,0);
                                 }
                        Clock.Reset();
                }

Pages: [1]