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

Pages: 1 2 3 [4] 5
46
SFML projects / MyGui - Yet another GUI-System!
« on: May 31, 2012, 02:03:37 am »
Okay, creating a thread in this section. premiere for me, hooray!  ;D

This is an older project and was the first real thing I did with SFML (other than playing around). And also right after reading half a book about C++ (existing programming experience, like ... writing a calculator that does the 4 basic operations in C and stuff).

Anyway, I've spent the last evenings reviewing and updating everything to work with the current RC, did some debugging and, thank god, everything works flawlessly.





Everything is as slim and flexible as possible, so no title bars or buttons for the windows right from the start or stuff like that. You can basically make it look and work however you want (as long as the existing controls allow it, of course).

Well, hope you like my first real project and all. Thanks to Laurent for all his work and an amazing library.

47
Graphics / Re: sf::Text bounds not updated
« on: May 31, 2012, 01:51:14 am »
Ah, I didn't see that. It behaves strangely indeed, but this thing I couldn't find a workaround for.

Anyway, thank you for pointing me there.

48
Graphics / sf::Text bounds not updated
« on: May 31, 2012, 12:35:35 am »
Okay, I have a little problem with sf::Text that I need some help with, or some clarification.

Basically this happens:
sf::Text text;
std::cout << text.getGlobalBounds().width << std::endl; // 0
text.setString("");
std::cout << text.getGlobalBounds().width << std::endl; // 0
text.setString("a");
std::cout << text.getGlobalBounds().width << std::endl; // 16
text.setString("");
std::cout << text.getGlobalBounds().width << std::endl; //16

In words: Once sf::Text had some sort of string and is set to an empty string it still keeps the bounds of the previous one.

Now I'd like to know if this is intended, if I'm doing something wrong or if this shouldn't be that way. Is there maybe a better way to clear the string?

[edit]
Oh yes, I'm using 2.0 RC.

49
Graphics / Re: Passing sf::RenderWindow to multiple .cpp files
« on: May 29, 2012, 06:14:12 pm »
Either I'm not getting what you're talking about or you should read through a chapter about using multiple header/source files in the C++ book of your choice. We're talking about really basic stuff here that you should try to understand first.

50
General / Re: setFramerateLimit doesn't work
« on: May 28, 2012, 07:58:48 pm »
I just tried this and it seems to happen to me as well. While vSynch works as intended, I get similar values as TheEnigmist in his last post.

Downloaded 2.0 RC something like 2-3 days ago and use all the libs as they are in the archive.

#include <SFML/Graphics.hpp>
#include <sstream>

int main()
{
    sf::RenderWindow window(sf::VideoMode(300, 200), "fps");
    window.setFramerateLimit(500);
    sf::Text fps;
    sf::Clock clock;

    std::stringstream fpsstream;

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        fpsstream.str("");
        fpsstream << 1.f/clock.getElapsedTime().asSeconds();
        fps.setString(fpsstream.str());
        clock.restart();

        window.clear();
        window.draw(fps);
        window.display();
    }

    return 0;
}

51
General / Re: Mouse Drag Box tutorial with SFML?
« on: May 26, 2012, 05:50:26 pm »
Ooh, I see. How about this? When you get a click-event and the cursor is in the area where the dragging is possible you save the starting coords (you can use them as a flag, for instance if you're not dragging the coords are set to 0/0 or -1/-1 or something, you get the idea) and redraw it from the starting point to the current cursor position whenever the mouse is moved. When the key is released again you do the calculation what's inside the box and continue with whatever you wanna do.

I've never done something like this before though, it's just an idea.

52
General / Re: Mouse Drag Box tutorial with SFML?
« on: May 26, 2012, 05:40:21 pm »
Well, all you need to do is (very) basically this.

Have an object with the sprite you want to drag and a flag-variable.
When the mouse is clicked and the cursor is on the sprite set the flag to true.
When the flag is true the sprite is set to the position of the cursor whenever it's moved, before the sprite is drawn or whenever you choose to do so.
When the mouse is released you set the flag to false again.

At least that's how I would do it. You can of course add more stuff that defines the behaviour, like interaction with other objects or the borders of the window.

53
System / Re: [SFML 2.0 RC] Mouse and moving sprite
« on: May 21, 2012, 09:35:05 pm »
Just realized using Event::KeyPressed would probably result in a one-time movement anyway. Just another guess though. I should really start working with it again before continuing replying to threads here.  ;D

54
System / Re: [SFML 2.0 RC] Mouse and moving sprite
« on: May 21, 2012, 09:19:53 pm »
I haven't directly worked with SFML in quite a while, so I'm merely guessing.

sf::Keyboard works outside of whether an event occured or not, but you're processing it inside the event loop.

So basically this is what happens:
You Press left key and the program enters the event-loop. The sprite is moved.
When you move the mouse additionally that counts as different event, so the the loop is being run through another time. Since isKeyPressed will return true this time as well (since it's not linked to events) the sprite will be moved more often.

Long story short. Use sf::Event::KeyPressed or what it's called (check the doc).

Hope this helps.

[edit]
Also there's cpp tags in the forum, you should use them instead.

55
SFML projects / Re: Pioneers
« on: May 20, 2012, 10:36:22 pm »
Dang!
Quote
I'd suggest moving it either till you see the forest your you're standing in front of it.
Should ofc be:
Quote
I'd suggest moving it either till you see the forest or you're standing in front of it.

56
SFML projects / Re: Pioneers
« on: May 20, 2012, 03:25:40 pm »
Wow, that looks indeed pretty cool. Will download and try it later.

[edit]
Tested it for some minutes. Two things that don't look too good.
- Your character already knows if he can pass something or not while the area is still unexplored. If there is a forest (on a black area) it just won't move. I'd suggest moving it either till you see the forest your you're standing in front of it.
- You can move without using your available steps or energy by simply building a small camp directly onto your character, entering it, and leaving it again putting your character right next to it. Building the camps doesn't seem to cost anything (not even energy). Doing so you can basically explore everything on the day you arrived on the island, just prepare for building lots of those darn camps.  ;D

I don't need to say that all I did was moving around, so if there's anything else to do in this stage, I didn't see it. Hope this helps.

57
Feature requests / Re: Animation
« on: May 12, 2012, 08:32:22 pm »
I suppose because everyone has different needs and SFML is there to provide the basic tools?
All you need for a simple animation is sf::Sprite::setTextureRect() and sf::Clock anyway.

58
General discussions / Re: sf::Keyboard::isKeyPressed()
« on: May 05, 2012, 02:23:07 am »
You should really use events, just like Groogy said.

(Anyway, your method can be fixed by a simple flag that prevents calling your method a second time unless the key has been released in the meantime. No seriously, don't do it that way.  ;D)

59
General discussions / Re: sf::Keyboard::isKeyPressed()
« on: May 05, 2012, 01:08:07 am »
My wild guess would be that isKeyPressed returns true as long as the key is pressed, and therefore SetMoveFwd is called numerous times till you release the key again (let's assume this happens in a (game) loop). That would result in a kinda random state of whatever SetMoveFwd changes (constantly switching from true to false and so on), unless you're not showing everything.

It's just a guess though.

60
General discussions / Re: C++/Game Programming Tutoring Classes
« on: May 03, 2012, 06:28:25 pm »
Don't you think one topic is enough?

Pages: 1 2 3 [4] 5