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

Pages: [1] 2
Graphics / Re: Subtle positioning behavior
« on: May 02, 2015, 08:51:57 pm »

Graphics / Re: Subtle positioning behavior
« on: May 02, 2015, 03:46:21 pm »
Should be in general discussion because it is not a help request.
It's a conversation about bugs that may arise when using sfml-graphics, and not a general design discussion about SFML.

But it's not a help request either.

Graphics / How to use bounding boxes and points?
« on: May 01, 2015, 11:54:19 pm »
I don't understand the syntax, please correct me. I want to check if a sprite contains a point. and YeS I have read the forums and looked on the wiki.

sf::RectangleShape sprite1box = sprite1.getGlobalBounds();
sf::Vector2f point = (-50, -20);
if (sprite1box.contains(point))


Graphics / Re: Subtle positioning behavior
« on: May 01, 2015, 08:58:54 pm »
First, this is not a SFML bug, yet behavior that one would probably not expect as a user. I stumbled upon it yesterday, after debugging almost an hour and searching in the wrong places :P

There is a bug in the following code, leading to a rendering that doesn't appear smooth when the sprites move.
// Two sprites. Assume they're initialized with texture and everything.
// Origin is (0, 0) and rotation is 0 at all times.
sf::Sprite sprite;
sf::Sprite sprite2;

// Align sprite to integral coordinates (pixel-perfect rendering)
sprite.setPosition(std::round(...), std::round(...));

// Second sprite starts at the center of first.
// Also round sprite2 for pixel-perfect rendering
sf::FloatRect bounds = sprite.getGlobalBounds();
sf::Vector2f center(
        bounds.left + std::round(bounds.width / 2.f),
        bounds.top + std::round(bounds.height / 2.f));

Does anybody spot it? ;)
Should be in general discussion because it is not a help request. And no I don't see a problem.

Graphics / Re: How to 'get distance' between two entities?
« on: May 01, 2015, 08:56:51 pm »
Indeed it is a very random attempt. I'm a university mathmatician graduate with 5 years experience in coding.

Graphics / How to 'get distance' between two entities?
« on: May 01, 2015, 05:50:19 pm »
Hello, can anyone give me some advice or point me in the right direction on how to get the distance between two sprites? What I want is to get the difference between two sprite's global position. I looked through the documentation and forums, but had no luck. I tried to do this but honestly have little idea:
sf::RectangleShape spritebox = sprite.getGlobalbounds();
sf::RectangleShape sprite2box = sprite2.getGlobalBounds();

if (spritebox < sprite2box)


Window / Re: Detect if number has been pressed?
« on: April 24, 2015, 06:17:44 pm »
is it possible to detect if two numbers have been pressed in one line of code?

Window / Detect if number has been pressed?
« on: April 24, 2015, 05:19:12 pm »
How do I check if a letter is pressed down? I try to do it with if
but it says it expected an identifier. How can I do this?

Window / Re: sf::Keyboard question
« on: April 23, 2015, 10:21:31 pm »
Thanks for quick response :) I think I got it now

Window / sf::Keyboard question
« on: April 23, 2015, 10:13:09 pm »
I am making an app that need keyboard input, and I need it so when you press a key it 'permantley' makes a sprite appear, not just while the key is pressed. Not sure how to do this. And yes I have read the tutorials and looked for other questions like this, but it says sf::keyboard has only one function which isKeyPressed. Here is the bit of code
if (sf::Keyboard:IsKeyPressed(sf::Keyboard::S))
//need the sprite to draw here if the key has been pressed once

Graphics / Re: Sprite movement help
« on: April 17, 2015, 05:09:08 pm »
You could of just written it in text, not with the slightly overdone derision.

Audio / Re: sf::sound won't play .ogg file
« on: April 17, 2015, 04:50:09 pm »
...............Now put a breakpoint on the call to sound.play() and tell me when it is called. Also you must learn about program flow control and basic C++ before you can even attempt to use SFML. So get yourself a good C++ book and learn that for 2 months and then come back to SFML.

(please no one else state the obvious)
The tutorial was more helpful than you. For your information, I know several languages of code and have been doing C++ for much longer than 2 months. Case closed.

Audio / Re: sf::sound won't play .ogg file
« on: April 17, 2015, 04:30:07 pm »
I moved the sound.play(); outside of the loop, but still not hearing anything  :-\ I also tried with sf::music, and with different files.

Show your updated code. Alternatively try the included examples that come with SFML.

Okay thanks, here is my code
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

int main()
        // create the window
        sf::RenderWindow window(sf::VideoMode(800, 600), "My window");

        sf::SoundBuffer buffer;
        sf::Sound sound;
        while (window.isOpen())
                sf::Event event;
                while (window.pollEvent(event))
                        // check the type of the event...
                        switch (event.type)
                                // window closed
                        case sf::Event::Closed:



Graphics / Sprite movement help
« on: April 17, 2015, 03:53:44 pm »
I'm currently making a classic ping pong game, but I don't know what the code/syntax is for if a sprite contacts another sprite, if you know what I mean. I thought I could make an if statement that checks if the ball is touching the rectangle or something like that, and then make it go towards somewhere.  Can anyone help me with this, or what other way could I do it?  :D

Audio / Re: sf::sound won't play .ogg file
« on: April 17, 2015, 03:23:38 pm »
yes  ;) They play fine

Pages: [1] 2