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

Pages: [1]
1
Network / UDP socket connection over WAN
« on: October 23, 2018, 09:29:12 pm »
Hello,

I’ve been working on an online game for around a month and a half now, and I have made a lot of progress. I have a whole system in place for connecting different machines over LAN, sending packets full of player data to the server and then sending all the data to other players, and all the other basics of online games. I thought it was impossible to connect UDP sockets over WAN without some form of NAT traversal, like UDP hole punching, but I was looking through some tutorials and I found out this might not be the case.

How exactly would this work in SFML, and what would I need to do this? Would I need hole punching after all? Has somebody already done this, and is there any source code for something like this?

2
Network / How do I upgrade a game from LAN to across the internet?
« on: June 04, 2018, 09:59:56 pm »
I made a pong game which works across LAN, and then I realized it might be possible to move it to across the internet, but I didn't know how to. Here are some simple questions I have about it.

Do I need to port forward? If I do need to, how do some games not require you to port forward to be able to play with one of your friends?

Do I need to change any of my actual code? Are there any settings/conditions that aren't enabled by default in each program that need to be met in order to work across the internet?

Thank you.

3
SFML projects / A small puzzle-platformer I've been working on
« on: July 19, 2017, 11:29:53 pm »
I've been working on a small puzzle-platformer for a few weeks, and I think it's the best looking game I've made so far. Here are a few features I've implemented:

- Wall jumping
- The ability to freeze entities
- The ability to possess other people
- An 8-bit auto tiling engine
- Crates!

Here are some of the features in action

http://imgur.com/fbkaui2

And here's a quick shot of the tiling system

http://imgur.com/tsZZpQV

And here's a small album of all the gifs of the game

http://imgur.com/a/JJSgQ

I don't have a name for it yet, but I'm planning to release it soon. I don't want it to become a huge project, just something small. If you thought it looked interesting, I post updates on my twitter.

4
I always thought people just drew every single tile and wrote one long if-else statement to check which sprite to load, but now I realized there are way too many possible block formations to do that. How do people normally approach auto-tiling? Is it possible to have one sprite of the border of a tile, and then instead of loading a million different tiles, just merging the border on top of the original tile texture?

5
Audio / Outputs a warning message upon exit
« on: July 11, 2017, 04:20:09 am »
So I just started working on audio for my latest project and I've done it for one other project that worked perfectly, but for some reason when I exit, it outputs this to the console:

AL lib: (EE) alc_cleanup: 1 device not closed

The sounds still play during the program, but it still outputs this warning. I've googled the code but most of them talked about threads and explained the problem but none had solutions that worked for SFML. I don't have any threads in my project, and all the audio files are within the player. I have 3 SoundBuffer objects and one Sound object. I play them by using the following code:

soundObj.setBuffer(soundBufferObj);
soundObj.play();

Am I able to play sounds within the player class? Is there something I should do to cleanup the sound files upon closing?

6
Network / Why aren't my computers connecting?
« on: January 11, 2017, 11:48:37 pm »
I've tried a lot of things, and yet I still can't figure this out. I saw this question was in the FAQ, I saw examples and I saw other peoples questions. The computers aren't even connecting, so I can't use wireshark. My goal was to create  a simple chatroom before I did something a bit more complex. Here's my code:

#include <iostream>
#include <SFML/Network.hpp>

using namespace std;
using namespace sf;

int main() {
    TcpSocket socket;

    string txt = "Connected to ";

    char message[2000];

    cout << "Enter c for client and s for server: ";
    char type, mode;
    cin >> type;

    if (type == 's') {
        TcpListener listener;
        listener.listen(2000);
        listener.accept(socket);
        txt += "Client!";
        mode = 's';
    } else if (type == 'c') {
        socket.connect(IpAddress::LocalHost, 2000);
        txt += "Server!";
        mode = 'r';
    }

    socket.send(txt.c_str(), txt.size() + 1);
    size_t received;
    socket.receive(message, sizeof(message), received);
    cout << txt << endl;

    Packet packet;
    packet << 5;
    socket.send(packet);
    socket.receive(packet);
   
    bool done = false;
    while (!done) {
        if (mode == 's') {
            getline(cin, txt);
            socket.send(txt.c_str(), txt.length() + 1);
            mode = 'r';
        } else if (mode == 'r') {
            socket.receive(message, sizeof(message), received);
            if (received > 0) {
                cout << message << endl;
                mode = 's';
            }
        }
    }
    return 0;
}
 

What can I do to test this? Is my code just bad?

7
I made a game using C++ and SFML developed on windows, but all of my friends and family members have macs. I have access to one if I really need it, but how do I port it? The game is here:
http://gamejolt.com/games/blast-to-the-spacecraft/214827

8
SFML projects / Blast To The SpaceCraft
« on: December 04, 2016, 07:24:07 pm »
I finished a SFML C++ game, i call it "blast to the space craft". I made it in two weeks, so don't expect too much from it but I think it's worth a couple minutes of your time. It's a top down space shooter, sort of like galaga and space invaders but also not. Nobody's played it yet, but that might be because I just released it yesterday. http://gamejolt.com/games/blast-to-the-spacecraft/214827

9
Graphics / White box glitch when creating multiple objects in a loop
« on: October 10, 2016, 11:12:29 pm »
I know about the white box drawing error when you load things wrong, and I fixed that in previous programs. But I can't figure out how to prevent this from happening when I create multiple objects in a loop and add them to a list. Here is my code:

Platform.h

#ifndef PLATFORM_H
#define PLATFORM_H
#include <SFML/Graphics.hpp>
#include <iostream>

using namespace sf;
using namespace std;

class Platform {
    private:
        string textStr;
        Sprite sprite;
        Texture image;
        Texture t;
    public:
        Platform(string, int, int, int, int);
        Sprite getSprite();
        Texture getTexture();
        string getTextureStr();
};

#endif // PLATFORM_H
 

Platform.cpp

#include "Platform.h"
#include <SFML/Graphics.hpp>

using namespace sf;

//  Default constructor
Platform::Platform(string ima, int x, int y, int w, int h) {
    //  Setting a texture to the path input
    image.loadFromFile(ima);
    //  Setting it so it keeps drawing the texture to the sprite
    image.setRepeated(true);
    //  Setting the private path to the path input
    textStr = ima;
    //  Setting the sprite to the texture, creating the rect and setting the position
    sprite.setTexture(image);
    sprite.setTextureRect(IntRect(x, y, w * 40, h * 40));
    sprite.setPosition(x, y);
}

//  Sprite returning function
Sprite Platform::getSprite() {
    return sprite;
}

//  Texture returning function
Texture Platform::getTexture() {
    return image;
}

string Platform::getTextureStr() {
    return textStr;
}
 

relevant parts of main.cpp

//  Creating a vector that contains all the platforms
vector<Platform> platforms;

//  An array of all the platforms in level 1 - x, y, width and height (in pixels)
int level1[] = {100, 600, 8, 1};

//  Looping through all the ints in the level list, and creating platforms
for (unsigned i = 0; i < (sizeof(level1)/4) - 1; i += 4) {
    platforms.push_back(Platform("brick.png", level1[i], level1[i + 1], level1[i + 2], level1[i + 3]));
}

 

Pages: [1]
anything