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

Pages: 1 2 [3]
31
SFML projects / Re: Screenshot Thread
« on: July 28, 2015, 05:49:54 pm »
My simplistic shooter game. Pew pew pew... :P


32
General / Re: SFML Window Quiting when I start program
« on: July 28, 2015, 03:53:52 pm »
This:
while (!IsExisting())
 

Here you are telling the while loop to work until the 'IsExiting()' function returns true, because you put the '!' mark, which negates the logical expression.

Inside the "IsExiting" function:
bool Game::IsExisting()
{
        if (_gameState == Game::Exiting)
                return false;
        else
                return true;
}

You tell the program as long as '_gameState' is not equal to Game::Exiting, the 'isExiting()' will always return true.
Because of the '!' inside the condition parameter for your while loop , it will negate the returning value of the 'isExiting()' function (i.e. true boolean value), making it false for the condition parameter.

The while loop will loop as long as condition is true. But the moment the condition is false, it will break the loop.

This is exactly what happens in your case. ;)

33
General / Re: Printscreen key and SFML
« on: July 26, 2015, 01:47:55 pm »
Quote
Not sure if the code you linked to works but I think its intention is to copy the window into the clipboard. If you're just capturing the window and saving that capture, SFML's window.capture() is perfectly fine, just as you've used it.

Actually, I was only interested in how to use printscreen key, and that topic was the only one I found that explained it to some extent. I was not interested what to do with the image afterwards in that topic. :)

Quote
#ifdef SFML_SYSTEM_WINDOWS
        if (GetAsyncKeyState(VK_SNAPSHOT))
        {
            window.capture().saveToFile("screenshot.png");
        }
#endif // SFML_SYSTEM_WINDOWS
I haven't thought it would be that simple. :D

Quote
This is not an event - it's a realtime query - so it would need to be used outside of the event loop. This would constantly update the screenshot as quickly as it can (capture is pretty slow though) so you might want to delay this test after it's been activated but that might not be necessary.

As you said, it behaves as SFML's "IsKeyPressed()"...
So, a simple boolean value should be enough to stop it from being called each frame.

Quote
Be aware that using this code stops your code being portable and you should consider wrapping it to make sure it's only used on Windows, and also provide an option for other operating systems to use (maybe a different key).

I guess that would also explain why SFML doesn't support it in the first place.
(also, I believe I got some things that already makes my code non-portable, but that is not the main point of this topic)

---------------------------------------------------------------

Already tested it and it works as intended!
Thanks a lot! :D

34
General / Printscreen key and SFML
« on: July 26, 2015, 11:20:27 am »
Hi! :)
I have a few questions about the key in the title.

First of all, I know how to capture current frame from the fullscreen window and save it to file:
if (mEvent.key.code == sf::Keyboard::F12)
{
    sf::Image screenshot = mWindow.capture();
    screenshot.saveToFile("screenshot.png");
}
 

But I got soo used to in using the Printscreen key for making screenshots, since majority of games I played would support it, either by making the image file or by capturing the frame and then pasting it in a image editor program. It is kinda intuitive.  ;D

So, what is the reason that SFML doesn't support the printscreen key?
Also, is there a way to force a program into using the printscreen key the way I want (as code above)?

I was searching a bit and found this topic, but since I extremely lack the OS* inner workings knowledge, I have no idea how implement the code from that topic into my code.  :-\
Which means that the second question basically boils down to "can you write the code for me, pleasee?" ;D
Or just point me at right direction on how to implement it.  ;)

PS: I am a c++ and a programer noob, just so you know...

* OS is Windows 7.

35
SFML projects / Re:creation - a top down action rpg about undeads
« on: July 08, 2015, 08:25:50 pm »
This is awesome!!!  :o
Great work!

36
General / Re: Licensing help (in general)?
« on: June 28, 2015, 05:18:00 am »
The replies were really helpful, thanks! :D

37
General / Re: Licensing help (in general)?
« on: June 27, 2015, 04:01:26 pm »
When you say "licensing the code" does that practically means simply copy-pasting the license text where is necessary ( and obliging yourself to it) or are there other things involved (say, paying royalties to the creator of the license) ?  ???

I am sorry, but I really do not understand how all that licensing thing works, and the more I search, the more I get confused.  :-[

38
General discussions / Re: Funny errors you've made or run into?
« on: June 21, 2015, 11:22:32 pm »
When SFML 2.3 came out, I updated my project to that version, and everything worked well (or was it? :P ).

A week or so has passed after I updated my game and I decided to test the release version of it. The mouse button pressed event didn't work, and I didn't have a clue why.

The very first thing I checked was the include\libraries path in the properties section of my project, following the SFML tutorials for Visual Studio. Everything seemed to be in order. After that I again copied-pasted the 2.3 DLLs, but they were not a problem.

After messing around with std::cout (because breakpoints and assertions does not work in release mode), and on another dummy project updated from 2.2 to 2.3 version (in which I made the same mistake!),  I figured that each time I press a button, a mouse button released event is generated! I then preformed a couple of checks and found out that SFML Debug and Release modes are not compatible.

And in typical C++ noob programmer manner, I convinced myself that I found a bug in SFML!!! ;D I already made the complete and minimal example (in the same project), and was ready to post it on forums.

But then I decided to take one last check on project properties before I do post on forums, and guess what? The Release mod paths still pointed to the 2.2 includes and libraries.:o So you could say that last check saved me from embarrassing myself on the forums. ;D

After fixing that, everything worked as intended. :)

39
Graphics / Re: Where has my 'getGlobalBounds' gone?
« on: June 18, 2015, 01:39:21 pm »
It should work and it would be more intuitive if you write it like this:


// if your "mouse_position" is already a sf::Vector2f, then you don't need to explicitly insert both x and y values
if (minute_page.rectangle.getGlobalBounds().contains(mouse_position)
{
    if (sf::Mouse::isButtonPressed(sf::Mouse:Left)
        click = 2;
}
if (second_page.getGlobalBounds().contains(mouse_position)
{
    if (sf::Mouse::isButtonPressed(sf::Mouse:Left)
        click = 3;
}
 

But I would recommend to check whether the mouse button is pressed inside the pollEvent loop, rather than checking it real time.

Btw, I am a c++ and a programer noob too, so take my suggestion with a grain of salt.  ;D

Pages: 1 2 [3]