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.


Topics - StDH

Pages: [1]
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
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.

3
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");

4
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.

5
General / Game Server Structure
« on: October 18, 2014, 11:04:06 am »
Hello, after long time  ;D .

I want help because i've got problem with my game-server code structure (c++) VS2013.

#I'm getting quite pissed off when:
 - i want to let ent/npc get some data from map,
 - exchanging data between two maps

@ because the structure looks like this:

Main - calls funtion Server::run() to prepare an initialize enviroment.
   |
Server - everything what this does is controling FPS and calls MapMgr::update()
   |
MapMgr - there is std::map<enum, std::unique_ptr<Map>> to store maps & updates them.
   |
Map - std::deque<std::unique_ptr<EntActor>> storing npcs & in update() calling ptr -> update();
   |
EntActor - whole interface, move, goto, health, shield, speed .....

EntActor::update()
moves/rotates entity to specified location, or try attack any near player by data from Map.

and this whole system is one-way, should i make some sort of a global-message-bus ?
Please tell me if you have better idea :) .

# Problem begins when i want to port/move EntActor from map1 to map2.

6
Feature requests / System specs
« on: June 16, 2014, 05:58:43 am »
wouldn't it will be nice to have some commands
to get system specifications like amount of ram ? :)
in windows it is thru GetSysytemMetrics() [ i hope i am right :) ]

# it could look like this:
sf::System::Cpu::Amount();
sf::System::Cpu::Speed(); [in Hz]

sf::System::Ram::Size(); [in KB]
sf::System::Ram::Usage(); return Vector2u(used, left);

sf::System::Gpu::Size(); [in KB] // i'm not so sure about writing this on my own
 

point: check if game can run of that system, or other :D
You can also use the specs for auto-configuration of the program's settings.

if this will be accepted, then i can write code for windows.

7
Graphics / onCreate() text glitch
« on: May 11, 2014, 12:27:13 pm »
language: c++
visual studio ultimate 2013
sfml 2.1 static [20.02.2014]

minimal code:
namespace game
{
        class Window : public sf::RenderWindow
        {
                public:
                        void onCreate();
        };
};

void game::Window::onCreate()
{
        // load files
}

first time it appears when i tried loading files inside onCreate(),
so i removed line that load files in onCreate() but it was still
appearing .... then i removed whole function onCreate() and
glitch disappeared.
I tried this more time to be sure it isn't my fault

8
General / QuadTree is adding objects to only one children
« on: May 10, 2014, 12:15:40 pm »
Initialize it with max_level 1 to have only 4 childrens.
its adding objects to only one children : SouthEast.
I have no idea why.

9
Graphics / sf::Text crash the program
« on: April 18, 2014, 06:40:37 pm »
Visual Studio 2013
sfml 2.1 [myself compiled]

sf::Text fps;

void gameWindow::setTextProperties(sf::Text &text, std::string string, unsigned char_size, sf::Color color, sf::Font font, sf::Vector2f position, float angle, sf::Uint32 style)
{
        text.setString(string);

        text.setCharacterSize(char_size);
        text.setColor(color);
        text.setFont(font);
        text.setPosition(position);
        text.setRotation(angle);
        text.setStyle(style);

        text.setOrigin(gameMath::setOrigin(text.getGlobalBounds()));
}

setTextProperties(fps, "", 12, sf::Color::Magenta, *gameFilesMgr::instance().getFont("font-orbitron-medium"), sf::Vector2f(2,2), 0, sf::Text::Regular);

fps.setString("string");

window.draw(fps);

 

it crashes when i call setTextProperties.
i had this problem even in sfml 2.0 .

font-orbitron-medium -> not the problem because same line is used in my npc's names

I have no idea where is the problem.

10
General / [HELP] laser movement
« on: April 18, 2014, 10:23:08 am »
Well as topic already say i need to help with laser movement like on this video:
https://www.youtube.com/watch?v=haBWQQ8D-Gw

as you cant see player and npc are moving with some angle and laser must move with them at some angle and speed, or otherwise it will be rocket.

and that: (me[angle] + npc[angle]) / 2 = laser[angle] -> i dont know if it is right, tell me if am i doing it wrong
i need to calculate angle + speed of laser [using sf::Sprite]

11
General / [HELP] Enemy Around
« on: April 16, 2014, 09:31:02 pm »
Hello all,

2D game,
i need to find if there is any enemy around another enemy but, using lenght and collision detection with 200 npcs it's equivalent to winVista as server on WiFi.
Is there any other way to find any enemy near another enemy ?

And sys look like this:

entity:
struct gameEntity_NPC

entity manager:
map<string, unique_ptr<gameEntity_NPC>>

12
System / sf::Thread Constructor Problem
« on: April 01, 2014, 05:32:05 am »
Hello all, i am new to this forum, but i am working with sfml 1 year or more.

The problem is this:

sf::Thread kb(&gameInputMgr::keyboard, this);
sf::Thread ms(&gameInputMgr::mouse, this);
kb.launch();
ms.launch();

this above is inside :
void gameWindow::run()

Libs are compiled in VC++12 [STATIC]

I have even tried this:
gameInputMgr gInputMgr;

sf::Thread kb(&gInputMgr.keyboard, this);
sf::Thread ms(&gInputMgr.mouse, this);
&
sf::Thread kb(&gInputMgr.keyboard);
sf::Thread ms(&gInputMgr.mouse);

I have no idea whats wrong, there is my output log:

  gameWindow.cpp
D:\Dark Orbit X\_shared\SFML-2.1\SFML/System/Thread.inl(48): error C2064: term does not evaluate to a function taking 1 arguments
          D:\Dark Orbit X\_shared\SFML-2.1\SFML/System/Thread.inl(48) : while compiling class template member function 'void sf::priv::ThreadFunctorWithArg<F,A>::run(void)'
          with
          [
              F=void (__thiscall gameInputMgr::* )(void)
  ,            A=gameWindow *
          ]
          D:\Dark Orbit X\_shared\SFML-2.1\SFML/System/Thread.inl(79) : see reference to class template instantiation 'sf::priv::ThreadFunctorWithArg<F,A>' being compiled
          with
          [
              F=void (__thiscall gameInputMgr::* )(void)
  ,            A=gameWindow *
          ]
          gameWindow.cpp(29) : see reference to function template instantiation 'sf::Thread::Thread<void(__thiscall gameInputMgr::* )(void),gameWindow*>(F,A)' being compiled
          with
          [
              F=void (__thiscall gameInputMgr::* )(void)
  ,            A=gameWindow *
          ]

N3v3r h48 4ny pr0bl3ms w11h 11.

Pages: [1]
anything