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

Pages: [1] 2 3 4
1
Network / Re: Problems sending multiple messages
« on: July 04, 2012, 09:42:44 am »
As far as I know the UDP socket do not care if all packages gonna be delivered.
Instead you can try with TCP.

2
Graphics / Re: Graphics and design question - sf::Image
« on: July 03, 2012, 10:12:16 pm »
I am not sure but If you need a GUI you can take a look at SFGUI.

3
Audio / Re: Failed to open Audio Device
« on: July 03, 2012, 05:46:03 pm »
You have to be more clear.
Which version of SFML are you using, well how you load the audio and make sure the path to the audio is correct.

EDIT:
What you mean with that you get the dll online?

4
Graphics / Re: SFML 2 shader
« on: June 29, 2012, 08:59:17 pm »
Can you (or someone else) please write a example code of the design.
EDIT: Because I don't really understand some of the english terms and can't understand the idea correct.

5
Graphics / SFML 2 shader
« on: June 29, 2012, 01:44:23 pm »
Imagine a big sprite for level background. I have to draw the sprite with its own texture applying more than one shaders, for example I want to put 3 light shaders on the texture. How can I achive this?

Currently what I have is:
sf::Shader light;
light.loadFromFile(....);
// Here setting some glsl parameters including light position

sf::RenderStates rs;
rs.shader = &light;

win.draw(bg, rs);
 

Well what design I need to put 3 lights on the bg sprite's texture.

6
General / How works Randomizer in SFML 1.6
« on: June 24, 2011, 11:43:38 am »
Thanks guys! I fixed it.  :)

7
General / How works Randomizer in SFML 1.6
« on: June 24, 2011, 10:18:54 am »
Quote from: "Nexus"
Jsf::Randomizer had the simplest implementation possible.

- rand() % range + min for integers
- rand() * range / RAND_MAX + min for floats


Laurent, this seems is not like sf::Randomizer because if I put for range 10 and min = -10 it's returning values from -10 to 0.

EDIT: I'll check now the source file.

EDIT 2: Yep, i found it and source was a litle bit different (just like my function), so this was not the reason my bolt effect is not like my bolt effect in SFML 1.6 with same source.

I'll try to found wath make it different.
Thanks for helping me. :)

I just wanna ask is there something changed in direction or angles in SFML 2 ?

8
General / How works Randomizer in SFML 1.6
« on: June 24, 2011, 12:49:26 am »
Laurent, can you share how Randomizer work(code) in SFML 1.6 because now with SFML 2 I can't get same effect with my own rand function (it's seems working like randomizer in sfml 1.6 but....)
 :?

Oups... wrong sub-forum maybe. Sorry.

9
Network / TCP - send and recive data
« on: June 20, 2011, 01:58:31 am »
Can someone explain me these things please:

1) Is possible to bind to one TCP socket 4 clients(at one time) and they won't be disconnected if game is not finished.

2) If not, how to make multiplayer game for 4 players using TCP socket?

3) What exactly means that TCP is blocking or not?

4) Is this method good: If client connect to server, he(client) start sending data about hes position on the map, server recive this data and send it back to client, than move client to recived positions(reciving and others players positions). (That's example of my algorith how server and clients to work(communicate), I'll be very happy if someone share better way or give me advice)?

I'm absolute newbie to socket programming.

:oops:

10
Network / TCP - send and recive data
« on: June 19, 2011, 05:03:22 pm »
Yep.

This class are writen from someone shared on sfml forum:

cpp:
Code: [Select]
#ifdef __cplusplus
#include <cstdlib>
#else
#include <stdlib.h>
#endif
#include <SFML/Network.hpp>

#include "network.h"

CNetwork::CNetwork()
{
    port = 5432;
    this->timeout = 5;
    state = ready;
}

CNetwork::CNetwork( int port, float timeout )
{
    this->port = port;
    this->timeout = timeout;
    state = ready;
}

CNetwork::~CNetwork()
{
    Client.Close();
}

bool CNetwork::Connect( sf::IPAddress ClientAddress )
{
    if ( state == connected ) return false;

    this->ClientAddress = ClientAddress;
    if (!this->ClientAddress.IsValid())
        return false;

    Client.SetBlocking(true);
    if ( Client.Connect(5432, this->ClientAddress, timeout) == sf::Socket::Done )
        state = connected;
    else
        state = timed_out;
    Client.SetBlocking(false);

    return (state == connected);
}

bool CNetwork::WaitConnection()
{
    switch(state)
    {
        case connected: return false;
        case ready:
            Server.SetBlocking(false);
            Server.Listen(port);
            state = waiting;
        case waiting:
            if (Server.Accept(Client, &ClientAddress) == sf::Socket::Done)
            {
                state = connected;
                Client.SetBlocking(false);
                Server.Close();
                return true;
            }
        default:
            return false;
    }
}

bool CNetwork::WaitData( sf::Packet* Packet )
{
    if ( state != connected ) return false;

    switch(Client.Receive(*Packet))
    {
        case sf::Socket::Done: return true;
        case sf::Socket::Disconnected:
            state = lost;
        default:
            return false;
    }

    return false;
}

bool CNetwork::SendData( sf::Packet* Packet )
{
    if ( state != connected ) return false;

    switch(Client.Send(*Packet))
    {
        case sf::Socket::Done:
            Packet->Clear();
            return true;
        case sf::Socket::Disconnected:
            state = lost;
        default:
            return false;
    }

    return false;
}


.h:
Code: [Select]
#ifndef NETWORK_H_INCLUDED
#define NETWORK_H_INCLUDED

#include <SFML/Network.hpp>

enum EState
{
    ready = 0,
    waiting,
    connected,
    timed_out,
    lost
};

class CNetwork
{
public:
    CNetwork();
    CNetwork( int port, float timeout );
    ~CNetwork();

    bool WaitConnection();
    bool Connect( sf::IPAddress ClientAddress );
    bool WaitData( sf::Packet* Packet );
    bool SendData( sf::Packet* Packet );

    float timeout;
    int port;
    EState state;
    sf::IPAddress ClientAddress;
    sf::SocketTCP Server;
    sf::SocketTCP Client;
};

template <class T>
class CMessage
{
    uint32_t id;
    uint32_t len;
    T data;
};

template <class T>
sf::Packet& operator <<(sf::Packet& Packet, const CMessage<T>& C)
{
    return Packet << C.id << C.len << C.data;
}

template <class T>
sf::Packet& operator >>(sf::Packet& Packet, CMessage<T>& C)
{
    return Packet >> C.id >> C.len >> C.data;
}

#endif


main function on server:
Code: [Select]

#include "network.h"
#include <iostream>
#include <string>

int main()
{
    CNetwork Network;

    sf::Packet ToSend;
    sf::Packet Recieved;

    bool runn = true;

    while(runn)
    {
        Network.WaitConnection();
        if ( Network.WaitData(&Recieved) )
        {
            std::string data;
            Recieved >> data;
            std::cout<<data<<std::endl;
            Recieved.Clear();
        }
    }

    return 0;
}


main function on client:
Code: [Select]

#include "network.h"
#include <iostream>
#include <string>

std::string doMsg(std::string &var)
{
    var = "";
    std::cout<<"\n[Message]: ";
    std::cin>>var;

    return var;
}

int main()
{
    CNetwork Network;

    sf::Packet ToSend;
    sf::Packet Recieved;

    std::string serverIp;
    unsigned short serverPort;

    std::cout<<"Connect to: ";
    std::cin>>serverIp;
    std::cout<<"Server port: ";
    std::cin>>serverPort;

    Network.port = serverPort;
    Network.Connect(sf::IPAddress(serverIp));
    bool runn = true;

    std::cout<<"\n\nPreparing.... Please be patient.\n\n";

    std::string msg;

    while(doMsg(msg) != "\0")
    {

        if(msg == "!quit")
        {
            runn = false;
        }

        if (msg.length() > 0)
        {
            ToSend.Clear();
            ToSend << msg;
            // fill ToSend packet...
            if (!Network.SendData(&ToSend))
            {
                std::cout<<"Oupss.. Something going wrong!";
            }
        } else std::cout<<"Invalid data (\0 ;))";
    }

    return 0;
}

11
Network / TCP - send and recive data
« on: June 19, 2011, 11:38:15 am »
I have some problems, I'm not familiar with the TCP protocol.

If I send data to server for example:

Msg1: Hello!
- Server recieved: Hello!

Okay.

But if I send:

Msg2: Hello World!
 - Server recieved: Hello
World!

I'm using sf::Package.

That I'm interested is there any way to get data like it is sended(inline)?
 :)

12
General / Build for Linux
« on: June 05, 2011, 02:23:25 am »
Okay, thanks for that info.

13
General / Build for Linux
« on: June 04, 2011, 08:32:16 pm »
I'm interested in how can I build my application for Linux for example, because when I run build it is generating exe.

I'm using Win XP SP3, C::B + MinGW.

I'll be waiting for someone to explain me :oops:  :)

14
Graphics / Get renderer window style
« on: April 16, 2011, 11:16:30 pm »
Yes I can, but I don't like to have lot of variables outside of objects.

15
Graphics / Get renderer window style
« on: April 16, 2011, 10:17:30 pm »
Okay Laurent. I will ask one more thing instend of opening new topic.

Theres no function to get frame limit of renderer window.
Q: Is wrong or dangerous if I write it myself like this:

in Window.hpp I write function:

unsigned int GetFrameLimit() {return myFramerateLimit;}

It's working perfect, but is this correct? I'm using static library if it is important.

Pages: [1] 2 3 4
anything