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

Pages: 1 2 3 [4]
46
Ah, ok. Is there a way to call the receive function without giving it an address and port?

Not without editing the SFML source. If you don't need that information, just create two local-scope variables like you've done and let them go out of scope :)

47
Problem resolved when I replaced

socket.receive(packet, address, port);

with

sf::IpAddress copyAddress = address;
unsigned short copyPort = port;
socket.receive(packet, copyAddress, copyPort);

Is socket.receive() supposed to modify the address and port arguments?

Yes, that way you know the IP address / port of the sender.

48
General / Re: Frame-speed on animation
« on: June 28, 2017, 02:05:06 am »
You will want the animation to update based on time. For example; every 0.25 seconds that have passed you increment the current frame by 1. That magical "0.25" seconds I mentioned would be your frame speed. You can achieve this by having a counter variable that stores the elapsed time since the last frame update, once that counter reaches the "frame speed", we increment the frame & set the counter back to 0.

49
Network / Re: UDP Failed to bind socket to port 45666
« on: June 23, 2017, 12:54:37 am »
Now I think that it arises from the fact that one and the same port is used both for sending and receiving messages, but this assumption causes me the following questions:
Why then does the error not appear on the first device, if the program works exactly the same?
Maybe my mistake is that UDP requires closing like TCP, but it's very strange and I'm in a confusion.

Is it possible for you to produce complete and minimal code that replicates your problem? I might be able to help you out further. Your second question after your assumption regarding UDP requiring the closure of the TCP connection is wrong, they're both independent of each other. But it definitely sounds like there is something wrong in your logic and not the devices.

50
Network / Re: UDP Failed to bind socket to port 45666
« on: June 22, 2017, 04:19:11 am »
Are you running both applications on the same computer?
Sorry if you answered this in your original post, I couldn't really get that from "I have 2 devices, both in my application work as a receiver and as a sender."

51
DotNet / Re: SFML.NET 2.4 Update
« on: June 21, 2017, 12:31:57 am »
Testing! Try it out, use it, and respond with any feedback you have!

Hi, I lurk these forums frequently & I don't have much to contribute in terms of feedback. However; I have been using SFML 2.4 .NET in one of my current projects & haven't had any issues with it yet. Thanks.

52
General / Drawing to render window freezes
« on: February 20, 2015, 09:50:22 am »
Hello, I have two classes:
Object
ObjectManager

I store all of my objects inside the ObjectManager class with a vector. I update all objects in one function which works perfectly. But when it comes to drawing them all in another function the game freezes. I even tried getting the object to just draw a RectangleShape & it still freezes. But when I comment out the draw function inside the object itself it is fine. So I think it might have to do with drawing to the window?

Here is my draw code for the object manager:

mWindow:
sf::RenderWindow                *mWindow;

void ObjectManager::draw()
{
        // Draw all of our drawable objects
        for (std::vector<Object*>::iterator it = objectList.begin(); it != objectList.end(); ++it)
        {
                (*it)->draw(mWindow);

        }
}
 

Here is the function above it that updates the objects (and it works):

void ObjectManager::draw()
{
void ObjectManager::update(sf::Time &delta)
{
        // Update all of our objects on the list
        for (std::vector<Object*>::iterator it = objectList.begin(); it != objectList.end(); ++it)
        {
                (*it)->update(delta);
                std::cout << "draw" << std::endl;
        }

        // Set there draw priority by depth
        std::sort(objectList.begin(), objectList.end(), sortByDepth);
}
 

53
General / Re: Custom draw order (depth)
« on: November 01, 2014, 06:41:05 pm »
I just moved it over to a vector with std::sort and it is working like a charm! it even fixed a lot of issues I was having. Thanks a lot for your input! :)

54
General / Re: Custom draw order (depth)
« on: November 01, 2014, 06:13:21 pm »
Simply sort the entities according to their Z value. std::multimap is one possibility, but if you're not using the Z order as an index, I'd probably work with std::vector and std::sort() instead.

By the way, check out the following C++ features, they will simplify your code a lot:
  • std::make_pair
  • auto
  • Range-based for loop
And are you sure you want to copy the Entity objects all the time?

Thank you for your answer, I will have a look at std::vector & std::sort(). I will also have a look at those features.
Currently one of the problems I'm having with this class is the copying of the Entity object all the time, it's giving me trouble when I'm trying to update it's velocity.

55
General / Custom draw order (depth)
« on: November 01, 2014, 05:54:23 pm »
Hello, I am quite new to C++ and SFML. I have made a few small games from SFML so far and am really enjoying it. Right now I am trying to create an RPG game, then I realised that unlike my other simpler games I've made previously, this game requires a draw order. I was a little bit stumped on how to do this at first, I tried searching on the forums but couldn't quite get a good understanding.

I have been trying to figure out the best & easiest way to draw sprites in a specific order related to their depth. At the moment the class I have made seems to work so far (see code below) , even though I still need to add a few more features. Am I on the right track for this? Sorry if this is in the wrong section of the forums. Thanks in advance.

Here is what I have come up with so far:


void SceneGraph::addToList(Entity entity, int depth)
{
    //drawList.emplace(depth, entity);
    drawList.insert ( std::pair<int,Entity>(depth,entity) );
}

void SceneGraph::updateList(sf::Time &deltaTime)
{
    // Put our current draw list into a new container
    tempDrawList.insert(drawList.begin(), drawList.end());
    //tempDrawList = drawList;
    // Clear our current draw list
    drawList.clear();
    //
    for(std::multimap<int, Entity>::iterator it=tempDrawList.begin(); it!=tempDrawList.end(); it++)
    {
        // Add our new updated depth to the list
        addToList((*it).second, (*it).second.getDepth());
    }
    // Clear the temp list now we're done with it
    tempDrawList.clear();

}


void SceneGraph::draw(sf::RenderWindow& target)
{
    for(std::multimap<int, Entity>::iterator it=drawList.begin(); it!=drawList.end(); it++)
    {
        (*it).second.draw(target);
    }

}

 

Pages: 1 2 3 [4]
anything