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

Pages: [1]
1
Graphics / Clicking app titlebar makes objects skip
« on: March 18, 2011, 09:14:05 pm »
Oh, I can't believe I didn't think of that, thanks.

2
Graphics / Clicking app titlebar makes objects skip
« on: March 18, 2011, 03:38:01 pm »
I a simple program that just make a 32x32 ball bounce around the screen and when I click and hold the the application's titlebar the ball appears to be still, but when I release the ball seems to go past the set boundaries.

Code: [Select]

#include <SFML/Graphics.hpp>

int vx = 500;
int vy = 150;
const int windowWidth = 800;
const int windowHeight = 600;
const int ballSize = 32;


int main()
{
    sf::RenderWindow App(sf::VideoMode(800,600,32), "Physics Simulation");

    App.SetFramerateLimit(60);
    const sf::Input& Input = App.GetInput();

    sf::Image ballImg;

    if(!ballImg.LoadFromFile("Ball.png"))
        return EXIT_FAILURE;

    sf::Sprite Ball(ballImg);
    Ball.SetPosition(400,600-32);

    ///***
    while(App.IsOpened())
    {
      if(Ball.GetPosition().y > windowHeight-ballSize)
         vy *= -1;
if(Ball.GetPosition().y < 0)
vy *= -1;
if(Ball.GetPosition().x > windowWidth-ballSize)
vx *= -1;
if(Ball.GetPosition().x < 0)
vx *= -1;

Ball.Move(vx*App.GetFrameTime(), vy*App.GetFrameTime());

        sf::Event Event;
        while(App.GetEvent(Event))
        {
            if(Event.Type == sf::Event::Closed)
                App.Close();
        }

        App.Clear(sf::Color(100, 149, 237));
        App.Draw(Ball);
        App.Display();

    }
    return EXIT_SUCCESS;
}
[/code]

Pages: [1]