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

Pages: [1]
1
Here is the log:
http://pastebin.com/raw.php?i=UMB8UhdE

I googled around a bit, and found that you can define a macro that makes the compiler stop giving an error: _CRT_SECURE_NO_WARNINGS, but even after putting this in the preprocessor defines, it still gives the same error.
Similar errors for the audio module as well.

Edit: maybe I should have read the forums with more attention before posting  ;D
For anyone else wondering, I decided to use the nightly builds at http://www.nightlybuilds.ch/

2
General / View frustum culling with a vertex array of tiles?
« on: April 07, 2015, 03:16:52 pm »
I googled around a bit, but I couldn't find anything.

Any idea if this is possible? (Drawing just a part of a vertex array?)

3
Network / selector.isReady(client) returns false every time
« on: November 23, 2014, 03:38:50 pm »
Hi there! I followed the usage example from here: http://sfml-dev.org/documentation/2.0/classsf_1_1SocketSelector.php

Here is the server-side code:
(click to show/hide)

And the client-side code:
(click to show/hide)

I run the server, then run the client, it connects successfully, but when I try to send the packet from the client to the server, it gets sent but not received by the server, which means getting bombarded with "selector no worko", signifying that selector.isReady(client) is always false, even when data is sent to one of the clients.

Any ideas?

PS: Tell me if i forgot to provide anything essential!

4
Audio / sf::Music setPlayingOffset() - big latency?
« on: November 03, 2014, 03:59:55 pm »
Using setPlayingOffset() to seek through a short song (1 min) works with no noticeable latency, however when I try a longer (5.5 min) song it lags for about 2 seconds before resuming playback. Should this be happening? Can it be fixed, should I use sf::Sound, or what?

Not sure if it helps much, but here's the code where I call the function:
...
sf::Time t = sf::seconds(music.getDuration().asSeconds() * barPerc);
music.setPlayingOffset(t);
...
 

Please do tell if you need anything else!

5
Network / Server and client can't both send and receive at the same time?
« on: October 24, 2014, 07:35:55 pm »
The code in its current form works, (with the server that ONLY receives data, and the client only SENDING data) but if you uncomment the currently commented blocks (server receives data and sends it back, and the client the same), it doesn't send or receive anything anymore...

#include <iostream>
#include <SFML/Network.hpp>
#include <SFML/Graphics.hpp>
#include <winsock2.h>

using std::cout;
using std::cin;

class Player
{
public:
    Player();

    int x, y;
    sf::RectangleShape shape;
};

Player::Player()
{
    x = y = 0;
    shape.setFillColor(sf::Color::White);
    shape.setSize(sf::Vector2f(50, 100));
}

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
    window.setVerticalSyncEnabled(true);
    bool isServer = false;
    cout << "Server/Client ? 1/0\n";
    cin >> isServer;

    if (!isServer)
    {
        sf::Int32 datax;
        sf::Int32 datay;
        Player player1, player2;
        player2.shape.setFillColor(sf::Color::Red);

        sf::TcpSocket socket;
        sf::Socket::Status status = socket.connect("localhost", 53000);
        if (status != sf::Socket::Done)
        {
            // error...
        }

        while (window.isOpen())
        {
            sf::Event event;
            while (window.pollEvent(event))
            {
                // Close window : exit
                if (event.type == sf::Event::Closed)
                    window.close();
                if (event.type == sf::Event::KeyPressed)
                {
                    if (event.key.code == sf::Keyboard::W)
                    {
                        player1.y--;
                    }
                    if (event.key.code == sf::Keyboard::S)
                    {
                        player1.y++;
                    }
                    if (event.key.code == sf::Keyboard::A)
                    {
                        player1.x--;
                    }
                    if (event.key.code == sf::Keyboard::D)
                    {
                        player1.x++;
                    }
                }
            }

            sf::Packet packet2;
//            if (socket.receive(packet2) != sf::Socket::Done)
//            {
//                cout << "Couldn't recieve data from server.\n";
//            }
//            else
//            {
//                cout << "Recieved data from server.\n";
//            }

            sf::Int32 enemydatax, enemydatay;
            packet2 >> enemydatax, enemydatay;
            player2.x = enemydatax;
            player2.y = enemydatay;
            player2.shape.setPosition(player2.x, player2.y);
            player1.shape.setPosition(player1.x, player1.y);
            window.clear(sf::Color::Black);

            window.draw(player2.shape);
            window.draw(player1.shape);
            window.display();

            //Send our clients position to the server
            sf::Packet packet1;
            datax = player1.x;
            datay = player1.y;
            packet1 << datax << datay;

            // TCP socket:
            if (socket.send(packet1) != sf::Socket::Done)
            {
                cout << "Couldn't send data to server.\n";
            }
            else
            {
                cout << "Sent data to server.\n";
            }
        }
    }
    else
    {
        sf::TcpListener listener;
        sf::Int32 datax;
        sf::Int32 datay;
        Player player1, player2;
        player2.shape.setFillColor(sf::Color::Red);

        // bind the listener to a port
        if (listener.listen(53000) != sf::Socket::Done)
        {
            cout << "Error: No connections.\n";
        }

        // accept a new connection
        sf::TcpSocket client;
        if (listener.accept(client) != sf::Socket::Done)
        {
            cout << "error client\n";
        }


        while (window.isOpen())
        {
            sf::Event event;
            while (window.pollEvent(event))
            {
                // Close window : exit
                if (event.type == sf::Event::Closed)
                    window.close();
                if (event.type == sf::Event::KeyPressed)
                {
                    if (event.key.code == sf::Keyboard::W)
                    {
                        player1.y--;
                    }
                    if (event.key.code == sf::Keyboard::S)
                    {
                        player1.y++;
                    }
                    if (event.key.code == sf::Keyboard::A)
                    {
                        player1.x--;
                    }
                    if (event.key.code == sf::Keyboard::D)
                    {
                        player1.x++;
                    }
                }
            }
            sf::Packet packet2;
            if (client.receive(packet2) != sf::Socket::Done)
            {
                cout << "Couldn't recieve data from client.\n";
            }
            else
            {
                cout << "Recieved data from client.\n";
            }

            sf::Int32 enemydatax, enemydatay;
            packet2 >> enemydatax;
            packet2 >> enemydatay;
            cout << "enemy x: " << enemydatax << std::endl;
            cout << "enemy y: " << enemydatay << std::endl;
            player2.x = enemydatax;
            player2.y = enemydatay;
            player2.shape.setPosition(player2.x, player2.y);
            player1.shape.setPosition(player1.x, player1.y);
            window.clear(sf::Color::Black);

            window.draw(player2.shape);
            window.draw(player1.shape);
            window.display();

            //Send our clients position to the server
            sf::Packet packet1;
            datax = player1.x;
            datay = player1.y;
            packet1 << datax << datay;


//            if (client.send(packet1) != sf::Socket::Done)
//            {
//                cout << "Couldn't send data to client.\n";
//            }
//            else
//            {
//                cout << "Data sent to client.\n";
//            }

        }
        // use "client" to communicate with the connected client,
        // and continue to accept new connections with the listener
    }
}

6
General / Generating cmake config files from a codeblocks project?
« on: September 22, 2014, 03:55:22 pm »
This may be a stupid question, but is something like this possible?

7
Graphics / Dynamic Tile Map
« on: June 30, 2014, 09:31:14 am »
The tile map in the tutorial is static, right? I was wondering, for a dynamic map, what changes would you need to make to the load() function to further optimize it? So far i've put the function that loads the tileset into a constructor, so it doesn't get loaded every cycle, but the performance is still pretty poor (around 40-50 fps on a 10x10 map, but also 40-50fps on a 100x100 map).

Is there anything else you'd recommend?

Also, is this a bad approach? What's the best way to render a map of dynamic NPCs?
is there a way to only redraw the tiles that have been modified in the vertex array? and leave everything else static?

8
Graphics / Joystick (?) functions slowing down program
« on: June 28, 2014, 06:47:02 pm »
My tile-based game was abnormally slow, so I decided to profile it a bit to see where the slowness comes from. I commented out everything in the render loop (only clear() and display() left), so just the event processing is in use... It only gets about 150 fps.
Here is the profiler information. Any idea what's up with the joystick functions?
http://pastebin.com/Hp5QJfBk

edit:
I've commented out the event processing as well and it's still 150 fps. What gives?

edit 2:
alright mates i tested it on a more powerful computer and the performance is way better (5100 fps) so it looks like my laptop is just very bad.

9
Graphics / Vertex Array using individual textures?
« on: June 02, 2014, 07:47:42 pm »
I implemented a small top-down tilebased game using individual textures and sprites to draw the map, and now I'm experiencing poor performance due to the large amount of draw calls (I'm guessing that's what it is.)
Looking at the vertex array tutorial (http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php) I can see that it uses a tileset. If I were to implement a tileset, I think i would need to rewrite a lot of code, so what I'm asking is: is it possible to just add(convert) the sprites that have textures and positions already assigned to them to the vertex array and then just draw that?
I know this is not the most optimized way, but I'm thinking the sprite creation and handling is negligible performance-wise (correct me if I'm wrong). Would this grant me a noticeable performance boost?
How do I do it?

If you need me to post some code, don't hesitate to ask, please!

10
Graphics / sf::Text wrap?
« on: April 18, 2014, 08:03:34 pm »
After some digging around, I couldn't find much. Any idea how to insert a newline if the text goes off screen? Also: if i display a sf::Text like "testing \n newline" it will just display it on the same line, no newline.

11
Audio / Sound stops playing once sf::Sound object goes out of scope?
« on: February 21, 2014, 02:08:21 pm »
#ifndef PLAY_HPP_INCLUDED
#define PLAY_HPP_INCLUDED

void Game::play(std::string soundName)
{
    std::cout << "Loading sounds...\n";
    if (!buffer.loadFromFile(soundName))
        std::cout << "Error: Could not find sound file named " << soundName << " !\n";

    sf::Sound sound;
    sound.setBuffer(buffer);
    sound.play();
    std::cout << "Playing \"" << soundName << "\"\n";
}

#endif // PLAY_HPP_INCLUDED
 

'buffer' is declared outside, and is still in scope when play() is called, but the sound doesn't play. any ideas?

Pages: [1]
anything