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

Pages: 1 2 [3] 4 5 ... 10
31
Window / Re: [SFML 2.0]Problem with repeating buttons and events.
« on: August 30, 2014, 01:58:46 am »
I've spent more than 20 mins writing the last reply, have you read it yet? Why do you keep using bool = signed integer?

32
Window / Re: [SFML 2.0]Problem with repeating buttons and events.
« on: August 30, 2014, 12:43:39 am »
Quote
So, okno.pollEvent(event) is checking all event events in okno, right?
How am I able to manage multiple events in one window? Or should I use this one for everything?
As there's while in main loop, won't it cause lags/something like that?
As you can see here SFML builds a LIFO ( I think) queue with every event happened in the last frame, pollEvent gives you the last even that has been registered. A loop is the only way to handle the events. What you do in the loop depends on what you need, but i recommend using the Thor library as soon as you've understood the flaws in your code (cleaner and sexier code :P).
Quote
It's working (even for letters), but I've got a question - why wasn't it working earlier? (or working partially?)
You were polling for the last event of the queue. The order is decided either by the OS or by how SFML was implemented (no time to check the source  ::)). The last IF statement was working on the same first event so it could only work if by chance the last event in the queue was keypressed.
Quote
And now, what with okno.setKeyRepeatEnabled(false); ? This code starts and stops my game in loop as long, as I'm holding P. How to disable this? (without any variables - I think that making "lock" variable for every key is a bad idea)
This is happening because you create a sf::event out of the scope and you don't poll the queue correctly.
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Window/Mouse.hpp>
#include <SFML/Window/Keyboard.hpp>
using namespace std;

int main()
{
        sf::RenderWindow okno(sf::VideoMode(800, 600), "title");
        while (okno.isOpen())
        {
                sf::Event event;
                while (okno.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                        {
                                okno.close();
                        }
                        else
                                if (event.type == sf::Event::KeyPressed)
                                {
                                        if (event.key.code == sf::Keyboard::P)
                                        {
                                                cout << "Gra Wstrzymana" << endl;
                                        }
                                }
                        else
                                if (event.type == sf::Event::KeyReleased) // pause until p is pressed
                                {
                                        if (event.key.code == sf::Keyboard::P)
                                        {
                                                cout << "Gra Wznowiona" << endl;
                                        }
                                }
                }
                okno.clear(sf::Color::Black);
                //okno.draw();
                okno.display();
        }
        return 0;
}
 
Quote
I want to write "skills"- functions, which would be called with keys (like Q, W, E, R). And when (wasd) moving it's simple (checking key state), in this case it's a little more complicated, as I need to check if a key was pressed-released (once)
I you can either do something like
while (okno.pollEvent(event))
{
        switch (event.type)
        {
        case sf::Event::KeyPressed:
                switch (event.key.code)
                {
                case sf::Keyboard::Q:
                        attackwithFireballs();
                        break;
                }
                break;
        default:
                break;
        }
}
 
if/else statements work too, however I'll always recommend Thor or a custom implementation for handling actions.
Quote
If I have:
bool abc;, does abc = 0; is equal to abc = false;?
The fact that the bool CLASS may be able to implicitly convert an integer number to bool shouldn't concern you. You MUST use either true or false because those are the keywords that were meant to work with bools.

TL;DR: you must read more tutorials and the SFML documentation.

33
Window / Re: [SFML 2.0]Problem with repeating buttons and events.
« on: August 29, 2014, 11:30:57 pm »
 
while (okno.pollEvent(event))
{
     if (event.type == sf::Event::Closed) {okno.close(); }
}
if (event.type == sf::Event::KeyPressed)      
{
     cout << event.key.code << endl;
}
Are you sure this is your code? Shouldn't it be like this instead?
while (okno.pollEvent(event))
{
     if (event.type == sf::Event::Closed)
         okno.close();
     else if (event.type == sf::Event::KeyPressed)      
              cout << event.key.code << endl;
}
 

34
Window / Re: [SFML 2.0]Problem with repeating buttons and events.
« on: August 29, 2014, 03:41:10 am »
I can't answer the first question because I have not understood it, I'll link this in case you haven't seen it yet. Regarding question 2 and 3 I'm quite sure this still holds true. Have you considered switching to sfml 2.1 or the latest version? I see more good than harm in doing that. By the way, I'm pretty sure most of the people posting in this forum are not native speakers :) (C1 here 8)).

35
Graphics / Re: Int to string
« on: August 28, 2014, 02:00:51 am »
If I recall correctly you don't have std::to_string() on mingw you need to find a workaround

36
General / Re: why am I getting an error on Void...?
« on: August 27, 2014, 08:57:09 am »
First of all pass the RenderWindow(noncopyable) as reference.

37
General / Re: installation by yum
« on: August 27, 2014, 01:21:51 am »
SFML 2.0 is quite outdated anyway (6th of april 2013). You might want to use SFML 2.1 or compile the latest version yourself.

38
C / Re: Problems with class files with SFML
« on: August 24, 2014, 12:54:50 pm »
his sf::Texture is obviously getting destroyed in the constructor, so this is probably the white square problem again.
He's declaring another pTexture and a different playerImage in the constructor while Player::pTexture and Player::playerImage are left untouched.

39
C / Re: Problems with class files with SFML
« on: August 24, 2014, 12:38:34 pm »
Probably this is the cause

41
What's the value that triggers the error?

42
Window / Re: pollEvent crash after window re-create (osx)
« on: August 23, 2014, 09:22:38 pm »
You're completely right, I should learn not to lurk the forums while I am only half awake. I apologize for sounding like a smartass and not helping you a single bit  :'(.
Let me try again (I know nothing about OSX but no one seems to reply and I have a lot of time to waste):

43
Window / Re: pollEvent crash after window re-create (osx)
« on: August 23, 2014, 07:58:58 am »
It keeps recreating the window as soon as you press F once.
Toggle must be declared in the is open loop and yes, the window create is (probably?) better off of the poll event loop

45
SFML projects / Re: Re: Word puzzle game of sorts
« on: August 10, 2014, 04:27:48 pm »
That's strange. I have the window, system, and graphics .dll's packaged with it. I downloaded the release just to double check. I wonder if it has anything to do with GCC compiled dll's (judging by the error msg)?
MOst likely the answer

Pages: 1 2 [3] 4 5 ... 10