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

Pages: [1]
1
Network / Re: Wrong data in packets.
« on: November 05, 2018, 05:25:03 pm »
Problem solve :) I cant send packet in packet like i did ;p

2
Network / Wrong data in packets.
« on: November 05, 2018, 08:18:18 am »
Im sending player ID in packet to client for him players table. Im checking my ID and sending it in Uint16 to client but he dont receive this... or receive a random data ;/ Code:
Server side when client join:

                        if (type == DOLACZENIE) // client send this when join
                        {
                                ++IDS;
                                it->second = IDS;
                                gracze[IDS].gra = true; // player with ID = IDS is now playing
                                Packet paccc;
                                Uint16 cos = IDS;
                                if (paccc << cos)
                                {
                                        WyslijPakiet(POLACZONO, paccc); // sending my paccc to client
                                        cout << "CONNECT: " << cos << endl;
                                }
                        }
Client receive:
                        if (type == POLACZONO) // get ID from serwer
                        {
                                Uint16 cos;
                                if (pac >> cos)
                                {
                                        cout << "ID in connect: " << cos << endl;
                                        packet >> cos;
                                }
                                else
                                {
                                        cout << "error in pac" << endl;
                                }
                        }
Output info in console:

CONNECT: 0
error in pac

3
Network / Get receive data in real time
« on: September 25, 2018, 08:08:18 pm »
I have problem with receive data in client side. I send to server info that player is connect and server make a new player in his vector and send another information to client with id player and coordinates. But i dont know how to receive that data. I tried a while loop but client is stop on this function with loop, i tried thread but thread dont work all the time ;/ Like if i send form server data then if just then thread working i get my data but otherwise i dont get info. How i have to receive data from serwer irrelevant what actualy function get focus from main?

4
Graphics / Re: Delete sprite from vector
« on: September 14, 2018, 02:06:39 pm »
Okay, these code do not work:
void Weapon::Draw(RenderWindow &window, Map &m)
{
        iterator = 0;
        for (i=begin(pociski);i!=end(pociski);)
        {
                pocisk = *i;
                pocisk.move(Velocity[iterator]);
                pociski[iterator] = pocisk;
                for (vector<Sprite>::iterator j = m.walls.begin(); j < m.walls.end(); j++)
                {
                        Sprite sciana = *j;
                        if (areColliding(pocisk, sciana, 2))
                        {
                                i = pociski.erase(i);
                        }
                }
                window.draw(*i);
                iterator++;
        }
}

        for (;i!=pociski.end();)
        {
                pocisk = *i;
                pocisk.move(Velocity[iterator]);
                pociski[iterator] = pocisk;
                for (vector<Sprite>::iterator j = m.walls.begin(); j < m.walls.end(); j++)
                {
                        Sprite sciana = *j;
                        if (areColliding(pocisk, sciana, 2))
                        {
                                i = pociski.erase(i);
                        }
                        else
                        {
                                ++i;
                        }
                }
                window.draw(*i);
                iterator++;
        }

        for (i=pociski.begin();i!=pociski.end();)
        {
                pocisk = *i;
                pocisk.move(Velocity[iterator]);
                pociski[iterator] = pocisk;
                for (vector<Sprite>::iterator j = m.walls.begin(); j < m.walls.end(); j++)
                {
                        Sprite sciana = *j;
                        if (areColliding(pocisk, sciana, 2))
                        {
                                vector<Sprite>::iterator curr = i++;
                                pociski.erase(curr);
                        }
                        else
                        {
                                ++i;
                        }
                }
                window.draw(*i);
                iterator++;
        }

        for (auto i = pociski.begin(); i != pociski.end();)
        {
                pocisk = *i;
                pocisk.move(Velocity[iterator]);
                pociski[iterator] = pocisk;
                for (vector<Sprite>::iterator j = m.walls.begin(); j < m.walls.end(); j++)
                {
                        Sprite sciana = *j;
                        if (areColliding(pocisk, sciana, 2))
                        {
                                i = pociski.erase(i);
                        }
                        else
                        {
                                i++;
                        }
                }
                window.draw(*i);
                iterator++;
        }

It's answers by googe when type "c++ erase vector iterator in loop" Any dont work. Any other sugestions? ;/

5
Graphics / Re: Delete sprite from vector
« on: September 13, 2018, 09:55:21 pm »
Thanks for answer but i tested all in google answers and any dont work ;/ Can you made a vector of sprites and erase some of object? Or redo my code? Maybe im doing some wrong but i dont thing so.

6
Graphics / Re: Delete sprite from vector
« on: September 13, 2018, 02:12:54 pm »
Look now

7
Graphics / Delete sprite from vector
« on: September 12, 2018, 10:55:31 pm »
I want to delete sprite form my vector but all function dont work xd... and return this error:

I saw all topics with similar like my but any dont work for me ;/
Code:
void Weapon::Draw(RenderWindow &window, Map &m)
{
        iterator = 0;
        for (i = pociski.begin(); i < pociski.end(); i++)
        {
                pocisk = *i;
                pocisk.move(Velocity[iterator]);
                pociski[iterator] = pocisk;
                for (m.i = m.walls.begin(); m.i < m.walls.end(); m.i++)
                {
                        if (areColliding(pocisk, *m.i, 2))
                        {
                                // bullet touch wall
                                 pociski.erase(i);
                        }
                }
                window.draw(*i);
                iterator++;
        }
}
 

8
Graphics / Re: Making SAT for rotation shape
« on: September 12, 2018, 10:05:40 pm »
Why i dont saw your code ;// Thanks you!

9
Graphics / Making SAT for rotation shape
« on: September 10, 2018, 11:13:34 pm »
Yo. Im writting a game in which player is shotting with computer bots. I have done movement player and collisions with "right" set wall rotation(0,90,180,270,360). But if change rotation of wall then algorithm for SAT doesnt work good like this on ss:
Work good:

And dont work good:


So if you saw, if i changed rotation then sat doesnt works good ;/ This algorithm isnt main. I get this form this film:
and code looks like this:
bool Player::Sat(const Sprite &sp1, const Sprite &sp2, Vector2f *out_mtv)
{               const FloatRect &rectSp1 = sp1.getGlobalBounds();
                const FloatRect &rectSp2 = sp2.getGlobalBounds();
                float proj_x, proj_y, overlap_x, overlap_y;

                // test overlap in x axis
                proj_x = max(rectSp1.left + rectSp1.width, rectSp2.left + rectSp2.width) - min(rectSp1.left, rectSp2.left);
                if (proj_x < rectSp1.width + rectSp2.width) {
                        if (out_mtv) {
                                // calculate mtv in x
                                overlap_x = rectSp1.width + rectSp2.width - proj_x;
                        }
                        // test overlap in y axis
                        proj_y = max(rectSp1.top + rectSp1.height, rectSp2.top + rectSp2.height) - min(rectSp1.top, rectSp2.top);
                        if (proj_y < rectSp1.height + rectSp2.height)
                        {
                                if (out_mtv)
                                {
                                        // calculate mtv in y
                                        overlap_y = rectSp1.height + rectSp2.height - proj_y;
                                        out_mtv->x = out_mtv->y = 0;

                                        // choose minimun overlap
                                        if (overlap_x < overlap_y) {
                                                out_mtv->x = overlap_x * (rectSp1.left < rectSp2.left ? -1 : 1);
                                        }
                                        else {
                                                out_mtv->y = overlap_y * (rectSp1.top < rectSp2.top ? -1 : 1);
                                        }
                                }
                                return true;
                        }
                }
                return false;
}
 
Im writing in sfml like 5 days and sat algorithm is too difficult ;/ Can you give me hint how i have change this code to get the perfect sat algorithm? I know i have to use .getTransform but its a bit difficult for me ;d

Pages: [1]
anything