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

Pages: [1]
1
General / Re: Time in statement
« on: April 05, 2015, 02:18:46 am »
Hmmm... then I don't know what I did wrong. I'm gonna make some more tests and checks, and see what else is wrong.

EDIT: Well, my time loop was made good, but problem was in function in that loop. Thought it can't be wrong, because it worked somewhere else, and this time statement was something new for me, so I was sure the problem is in it. Sorry for problem guys  :-[

2
General / Re: Time in statement
« on: April 04, 2015, 10:58:42 pm »
Where are the events processed ?

eddited in my example code

3
General / Time in statement
« on: April 04, 2015, 10:50:21 pm »
My goal is make a loop, where function 'do_something()' is executed once every 5 seconds. I have code like this:

using namespace sf;
//(...)
Clock clock;
Time time;
//(...)
while (window.isOpen())
{
        Event event;
        while (window.pollEvent(event))
        {
                //some events...
        }

        time = clock.getElapsedTime();
        if (time >= seconds(5.f))
        {
                do_something();
                clock.restart();
        }
}

This code execute my function in minimum possible time interval. I've tried every possible code options, that came into my mind, and all I achieved exept this, is application crash, or there is no reaction (statement never meet). This example looks so easy, that I don't know what can be wrong. Where I'm making mistake?

4
Graphics / Re: Transparent text to the second layer image
« on: March 25, 2015, 05:20:20 pm »
These shaders looks very complicated. I barely understand what is it.

Maybe it is possible to fill text "color" with backgroud texture? And the text will be some kind of sprite then? :P

5
Graphics / Transparent text to the second layer image
« on: March 25, 2015, 12:20:17 pm »
I have 2 images. First is fullscreen, and it's my backgroud as sprite, second is one-color rectangle drawn on backgroud. Next I have text written on those layers. I want my text to be transparent to second layer which is backgroud. How to do this?



window.clear();
window.draw(background);
window.draw(rectangle);
text.setColor(Color(0,0,0,150));
window.draw(text);
window.display();

6
General / Re: Loop in pollEvent
« on: March 22, 2015, 11:32:59 am »
Got it.

7
General / Re: Loop in pollEvent
« on: March 22, 2015, 11:15:56 am »
if (event.type == Event::Closed || event.key.code == Keyboard::Escape)

Quote
And this is wrong, you need to ensure the event is a keyboard event before checking the key.

Thanks! You've found my main bug. Didn't know why the window crash, when cursor was near left side of screen.

And yep, I meant polling events with a for loop. Thought I can make my code little more beautiful w/o making event for all almost the same options.

edit: If it's still incomprehensible, I wanted to do something like this (I know it won't work):
while (window.pollEvent(event))
                {
                        if (event.type == Event::Closed || event.key.code == Keyboard::Escape)
                        {
                                window.close();
                        }
                        for (int i=0; i<6; i++)
                        {
                                else if (option[i].getGlobalBounds().contains(mouse) &&
                                eventtype == Event::MouseButtonPressed && event.key.code == Mouse::Left)
                                        {
                                                //many functions based on matrix used in option[]
                                        }
                        }
                       
                }

8
General / Loop in pollEvent
« on: March 22, 2015, 10:51:53 am »
I've got someting like this:

while (window.pollEvent(event))
                {
                        if (event.type == Event::Closed || event.key.code == Keyboard::Escape)
                        {
                                window.close();
                        }
                        else if (option[1].getGlobalBounds().contains(mouse) &&
                                eventtype == Event::MouseButtonPressed && event.key.code == Mouse::Left)
                        {
                                //many functions based on matrix used in option[]
                        }
                        else if (option[2].getGlobalBounds().contains(mouse) &&
                                event.type == Event::MouseButtonPressed && event.key.code == Mouse::Left)
                        {
                                //many functions based on matrix used in option[]
                        }
                        //else if (option[3]... else if (option[4]... else if (option[5] (...)
                }

Can I use some kind of for loop in window.pollEvent?

9
General / Re: Auto typing character by character
« on: March 18, 2015, 10:23:50 pm »
It works great! Thanks a lot

10
General / Auto typing character by character
« on: March 18, 2015, 01:38:32 am »
Hello. I'm trying to make Fallout 3 terminal application (). I can't figure out how to make text shown character by character. Found some code that works in regular C++ console app:

std::string str = "some text";
for (unsigned i = 0; i < str.length(); i++)
        {
                cout << str[i];

                if ((i + 1) < str.length() && str[i + 1] != '\n')
                        cout << char(219);

                _sleep(6);

                if ((i + 1) < str.length() && str[i + 1] != '\n')
                        cout << char(8);
        }
        cout << ' ' << char(8);

And there goes my questions:
1. How can I use in SFML's Text class something like:

sf::Text str = "some text";
window.draw(str[i]);
?

2. How can I parse char to sf::Text, and then draw it, like in cout's example above?

3. Didn't test, but is the _sleep(n) command is proper for SFML program loop?

PS. Please note I'm novice in C++ and with English language :)

11
Network / Client-serwer communication (TCP) via global IP
« on: January 11, 2015, 10:18:11 pm »
Hello. I wrote the simpliest client and serwer applications that can send a message. It works in local IP, but the same code wont work when I changed local IP to global IP. I have already tried to change internet connection, switch client<-> serwer, diffrent ports, but still nothing. Is my code wrong? Im the beginner with coding and I dont know internet structures well. I've already forward ports on my router and checked it works on program "port checker". Here is the code for client and serwer:

//serwer
#include <SFML\Network.hpp>
#include <iostream>
#include <conio.h>

using namespace sf;
using namespace std;

int main()
{
        UdpSocket socket;
        unsigned short s = 50001;
        unsigned short k = 50002;
        socket.bind(s);
        string tmp = "";
        Packet pakiet; 
        IpAddress ip_k = "89.66.209.51"; //can't work
        //IpAddress ip_k = "192.168.0.12"; //works
        socket.receive(pakiet, ip_k, k);
        pakiet >> tmp;
        cout << tmp;
        getch();
}

//client
#include <SFML\Network.hpp>
#include <iostream>
#include <string>
#include <conio.h>

using namespace sf;
using namespace std;

int main()
{
        UdpSocket socket;
        unsigned short s = 50001;
        unsigned short k = 50002;
        socket.bind(k);
        string tmp = "message";
        Packet pakiet;
        //IpAddress ip_s = "188.146.82.158"; //can't work
        IpAddress ip_s = "192.168.0.12"; //works
        pakiet << tmp;
        socket.send(pakiet, ip_s, s);
        getch();
}

btw. sorry for my english

------------------------------------------------------------------------------------------
edit: Found where is my problem. Im using udp sockets and trying to make a tcp connection  :-[. Code has been repaired and it works now.

Pages: [1]
anything