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

Pages: [1] 2 3 4
1
Feature requests / sf::Rect intersects & contains - unsigned version
« on: July 08, 2016, 03:39:38 pm »
If u don't know much about QuadTree, then please read a bit of it: https://en.wikipedia.org/wiki/Quadtree

The idea is to make separate functions for unsigned version of ::intersects & ::contains, imagine you use QuadTree in your game server to detect collisions or objects around any given point, but since this can be repeated hundreds or even thousands times per frame - checking whether the number is negative or positive several times in one function can take some performance down, so i decided to make "unsigned" version to calculate and compare numbers as fast as possible because i use only number going from 0.f. People like me can benefit from this.

This is purely about Performance, so those functions can be called like: ::intersectsUnsigned && ::containsUnsigned

in my floatRect class i use two sf::Vectors to store position and size.

float floatRect::x() const
{
        return m_position.x;
}

float floatRect::y() const
{
        return m_position.y;
}

float floatRect::w() const
{
        return m_size.x;
}

float floatRect::h() const
{
        return m_size.y;
}

bool floatRect::contains(const float _x, const float _y) const
{
        /*const float minX = std::min(m_position.x, m_position.x + m_size.x);
        const float maxX = std::max(m_position.x, m_position.x + m_size.x);
        const float minY = std::min(m_position.y, m_position.y + m_size.y);
        const float maxY = std::max(m_position.y, m_position.y + m_size.y);

        return (x >= minX) && (x < maxX) && (y >= minY) && (y < maxY);*/


        const bool b1 = x() <= _x;
        const bool b2 = y() <= _y;
        const bool b3 = x() + w() >= _x;
        const bool b4 = y() + h() >= _y;

        return b1 && b2 && b3 && b4;
}

bool floatRect::intersects(const floatRect& _rect) const
{
        /*
        const float r1MinX = std::min(m_position.x, m_position.x + m_size.x);
        const float r1MinY = std::min(m_position.y, m_position.y + m_size.y);
        const float r2MinX = std::min(_rect.m_position.x, _rect.m_position.x + _rect.m_size.x);
        const float r2MinY = std::min(_rect.m_position.y, _rect.m_position.y + _rect.m_size.y);

        const float r1MaxX = std::max(m_position.x, m_position.x + m_size.x);
        const float r1MaxY = std::max(m_position.y, m_position.y + m_size.y);
        const float r2MaxX = std::max(_rect.m_position.x, _rect.m_position.x + _rect.m_size.x);
        const float r2MaxY = std::max(_rect.m_position.y, _rect.m_position.y + _rect.m_size.y);

        const float interLeft   = std::max(r1MinX, r2MinX);
        const float interTop    = std::max(r1MinY, r2MinY);
        const float interRight  = std::min(r1MaxX, r2MaxX);
        const float interBottom = std::min(r1MaxY, r2MaxY);

        if ((interLeft < interRight) && (interTop < interBottom))
                return true;

        return false;*/


        const bool b1 = x() < _rect.x() + _rect.w();
        const bool b2 = y() < _rect.y() + _rect.h();
        const bool b3 = x() + w() > _rect.x();
        const bool b4 = h() + y() > _rect.y();

        return b1 && b2 && b3 && b4;
}

2
SFML game jam / Re: Wanna another? (early 2016 edition)
« on: January 13, 2016, 02:09:36 pm »
Since i've always been "stalking" on these game-jams , this time i'd like to participate too ^^

3
Feature requests / Re: sf::Socket::Status - more flags
« on: December 28, 2015, 03:04:21 pm »
i'm requesting this because it would be useful on my game-server or any network-server generally.

Example in game:You're in a team that you cant normally leave, your connection gets timed-out but server show that you've disconnected, you get punished for violating game rules or so because you were not supposed to leave in any way (play until game timer ends).


EDIT2:
WSAECONNABORTED -> If client connection was aborted by unknown software
WSAECONNRESET  -> This happens if peer application on the remote host is suddenly rebooted or stopped

4
Feature requests / sf::Socket::Status - more flags
« on: December 28, 2015, 02:28:08 pm »
i'd really like to see more flags for sf::Socket::Status since i saw

https://github.com/SFML/SFML/blob/master/src/SFML/Network/Win32/SocketImpl.cpp#L72

Socket::Status SocketImpl::getErrorStatus()
{
    switch (WSAGetLastError())
    {
        case WSAEWOULDBLOCK:  return Socket::NotReady;
        case WSAEALREADY:     return Socket::NotReady;
        case WSAECONNABORTED: return Socket::Disconnected;
        case WSAECONNRESET:   return Socket::Disconnected;
        case WSAETIMEDOUT:    return Socket::Disconnected;
        case WSAENETRESET:    return Socket::Disconnected;
        case WSAENOTCONN:     return Socket::Disconnected;
        case WSAEISCONN:      return Socket::Done; // when connecting a non-blocking socket
        default:              return Socket::Error;
    }
}

it would be nice to know if connection was timed-out, reseted or aborted, and it isn't even so much job to do.

Sometimes you want to know what has happened on the socket.

5
Feature requests / Re: Why not set sf::Window style at runtime?
« on: July 07, 2015, 11:53:36 am »
I vote for this =P

6
i began to use SFML on rpi last year, my project was about recognizing simple shapes/faces on video-stream/camera/photos.

7
Feature requests / Re: new sf::Sprite Method "void centerOrigin()"
« on: February 03, 2015, 05:49:31 am »
I'm for that feature =) it would be nice to see in SFML.

Additionally if your sprite has uneven size, dividing by 2.f might create rasterization issues and as such people would again have to write their own free function or similar.

static_cast<unsigned>(float)

8
Feature requests / Re: [System] getDateTime
« on: February 03, 2015, 05:47:31 am »
Since you can get size of your screen i was thinking about function that returns formatted time.

9
Feature requests / Re: [System] getDateTime
« on: February 02, 2015, 05:56:36 pm »
well, i've already done the code, i just wanted to make this simplier.

EDIT: https://github.com/StDH/SFML/compare/LaurentGomila:master...master

10
Feature requests / [System] getDateTime
« on: February 02, 2015, 05:41:01 pm »
i would like to pull request to add function getDateTime inside system module.

examples of use:
 naming screenshots.
 showing time.
 save time to see when did you last played game.

Clock.hpp
static std::string getDateTime(const char* _format = "%d.%m.%Y - %H:%M:%S");

11
Audio / Re: sf::Music 'call initialize() first'
« on: December 14, 2014, 11:40:31 am »
wow, really ? i thought it do.
Then, sorry for this Laurent.

12
Audio / sf::Music 'call initialize() first'
« on: December 14, 2014, 11:34:10 am »
Visual Studio 2013
SFML, current source from GitHub. (using release build)

Minimal Example:
int main()
{
        sf::Music m_music;

        if (m_music.openFromFile("login.mp3"))
                return -1;

        m_music.play();

        return 0;
}

Failed to open sound file "login.mp3" (File contains data in an unknown format.)
Failed to play audio stream: sound parameters have not been initialized (call initialize() first)


No matter what i do, it appears always.
I've even tried using audacity to export .mp3 file but it shows on any .mp3 i used.

Last time i used this module was about one year ago.

13
General / Re: Game Server Structure
« on: October 23, 2014, 01:47:25 pm »
std::vector::reserve = pain in multiplayer map without limit, this is just for npcs (static amount)
std::deque = can insert/delete in middle, that's what i need for players ofc.

14
General / Re: Game Server Structure
« on: October 23, 2014, 12:13:49 pm »
std::list has big memory usage.
std::vector is reallocating in every insertion.

std::deque is perfect to store players.

15
General / Re: Game Server Structure
« on: October 23, 2014, 05:51:05 am »
That's also the reason I said that a lot depends on what you'll be doing with the data because if you only add/remove from the middle occasionally, then you probably won't gain much from using std::list - but if it's something that is done every game frame and especially on a container that is supposed to be storing large objects, then that's a different story.

Players are allowed to jump thru portal every 5 seconds, so that's the reason of std::deque.
std::list is bit useless because it's doubly-linked to object in front & back, but yeah it's effecient for large objects

Pages: [1] 2 3 4