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

Pages: [1]
1
Thanks mate, that example helped quite a lot. No more escaping paddles.

I'm still confused about Rect's though, like how can I actually use it after using getGlobalBounds(). I've tried stuff like if paddle1.x or paddle1.top (at least 'top' was an attribute on a Rect) has a value that puts them out of the screen, it will be adjusted so the paddle can't exit the screen. This hasn't been working at all, as I get compile error:
error: 'class sf::RectangleShape' has no member named 'top'
Obviously it's still using Shape, so how am I able to use Rect instead?

(Apologies for bad text, I felt nauseous after reading it too.)

2
aIck here!
I finally felt ballsy enough to try and program something, and that something would be yet another Pong clone (start small they all say). I was pleasantly surprised that I was able to draw those sweet white rectangles on the screen and making them moveable with keyboard was rather easy, but now I'm struggling on collisions and such. I need to stop those paddles from escaping the screen, and later make the ball bounce off the paddles and walls.

Here's the code for a paddle:
    sf::RectangleShape paddle1;
    paddle1.setSize(sf::Vector2f(20, 100));
    paddle1.setFillColor(Color::White);
    paddle1.setPosition(20, 150);
    paddle1.getGlobalBounds();

I figured getGlobalBounds() could be the way to go, but I don't quite know how to advance from here. Any help? Suggestions? Corrections?

I'm using SFML2 if that matters.

Pages: [1]