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

Pages: [1] 2 3
1
Window / How would I find if sf::RenderWindow is focused?
« on: September 15, 2012, 03:40:01 pm »
Like if I want to accept user input only when the window is focused..

How?

2
Network / Re: Problems with packets #2.
« on: July 09, 2012, 02:07:51 pm »
To get the sender's global address would I need to include it to the packet from client-side?

3
Network / Re: Problems with packets #2.
« on: July 09, 2012, 01:59:25 pm »
So senderaddress is the sender's local address already?

4
Network / Problems with packets #2.
« on: July 09, 2012, 01:12:02 pm »
I've switched my game to use udp instead of tcp, because you know :P

So I'm testing it over local network and I've faced some problems..

So if we would have a code

sf::UdpSocket socket;
sf::IpAddress SenderAddress;
sf::Packet ReceivedPacket;
unsigned short Port;
if(socket.receive(ReceivedPacket,SenderAddress,Port)==sf::Socket::Done) {
sf::IpAddress SenderLocalAddress = SenderAddress.getLocalAddress();
}

Now would the SenderLocalAddress be the sender's local address or the local host's local address?
Since when I send directly data from the client to server over local network the server receives the data, however when the server tries to response the client doesn't get the data.

And I was just wondering that does it even send it to the right IP?


5
Network / Re: Problems with packets.
« on: July 06, 2012, 12:39:53 pm »
Sorry, I might have been printing it on the one outer block from that.

6
Network / Re: Problems with packets.
« on: July 06, 2012, 11:56:17 am »
Ok, I got it working.. Sorry for wasting your time :P

It was obvious mistake, the Connected member was never set to true since I modified the constructor a bit :P

7
Network / Re: Problems with packets.
« on: July 05, 2012, 11:15:53 pm »
Yes if I make it print the Players[index].Position.x on that same block it'll print it correctly.

8
Network / Problems with packets.
« on: July 05, 2012, 08:57:39 pm »
This is a part of my code,
void GlobalWorld::SendPlayers(sf::TcpSocket * client) {
        if(this->Players!=NULL){
        sf::Packet SentPacket;
        SentPacket << this->numPlayers;
        for(int index=0;index<this->maxPlayers;index++){
                if(this->Players[index].Connected){
                        //the current player is connected, add the data to the packet
                        SentPacket << Players[index].Position.x << Players[index].Position.y << Players[index].Rotation << Players[index].Health << Players[index].Name;
                }
        }
        int x;
        float z;
        SentPacket >> x >> z;
        std::cout << x << z;
        client->send(SentPacket);
}
}

The x,z part is used for debugging so every time I call that function z will result as undefined float, however if I print the value which z should be (Players[index].Position.x, Position is vector2f) it prints the real result.
But the x matches with the numPlayers member of the GlobalWorld.
What's wrong?

9
Window / Re: How you are supposed to close the window correctly?
« on: June 22, 2012, 03:08:01 pm »
What else than just linking sfml-main.lib would I need to do to hide it completely?

10
Window / Re: How you are supposed to close the window correctly?
« on: June 21, 2012, 03:02:35 pm »
I just want to get user input from the console in some points but I also want that during the user input you can close the console without getting it to not responding status.

11
Window / Re: How you are supposed to close the window correctly?
« on: June 20, 2012, 10:39:42 pm »
How would I get user input without getting the window to not responding state AKA pausing the loop..?

12
Window / Re: How you are supposed to close the window correctly?
« on: June 20, 2012, 09:24:36 pm »
Ok so I want it to be something like this for example,

 #include <SFML/Graphics.hpp>
 #include <iostream>
 
 int main()
 {
     std::string Text;
     Start:
     std::cin >> Text;
     bool Retry(false);
     // Create the main window
     sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
     sf::Text(Text);
     // Start the game loop
     while (window.isOpen())
     {
         // Process events
         sf::Event event;
         while (window.pollEvent(event))
         {
             // Close window : exit
             if (event.type == sf::Event::Closed)
                 window.close();
         }
 
         // Clear screen
         window.clear();
         window.draw(Text);
         // Update the window
         window.display();
         if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape)){
         Retry = true;
         }
         if(Retry){
         window.close();
         goto Start;
         }
     }
     return EXIT_SUCCESS;
 }

But I want it to be possible to close the console at the input after I once pressed Escape

13
Window / Re: How you are supposed to close the window correctly?
« on: June 20, 2012, 08:37:02 pm »
I mean like I want to close the sfml window that I created and keep the console and manually close the console afterwards.
So currently it's like

main
start:
user input
variables and stuff
loop while the window is open
if the event is closed, close the window
other stuff
if the health (defined earlier) is under 0, close the window and jump to start
end the loop
end main

But if my code is something like (without sfml)
(Not so pseudo-code anymore)

int main() {
cin.get()
return 0;
}

And if I would close the console(by hand)before it reaches to return (so before I made the input) it would close normally.
That's the same thing I want to do with my sfml tests

14
Window / Re: How you are supposed to close the window correctly?
« on: June 20, 2012, 01:10:17 pm »
But that also happens when I close the sfml window by window.close() and jump out from the game loop..

15
Window / Re: How you are supposed to close the window correctly?
« on: June 19, 2012, 06:39:34 pm »
I mean that if I close the console manually it just stops responding.

Pages: [1] 2 3