SFML community forums
Help => Network => Topic started by: Eevee204 on July 09, 2014, 11:02:04 pm
-
Hello, I just have a question about how to use graphics for an online game. I was looking at either:
1. Storing the images on an FTP server and have the client access these files like that
OR
2. Store the images on the server and have the server send the files to the client as a package.
Which one is the recommended for this?
-
I don't think it matters either way.
Ftp server brings its own complexity in setting it up, maintaining it etc and your client needs to be able to speak ftp.
Custom transfer protocol from your game server needs to be coded, tester etc. Also brings complexity.
Which is the bigger pain is probably a judgement call. Personally I'd probably pick option 2.
Another option would be to simply include the images in the client (if they are not expected to change).
-
Yeah, having them stored on the client would be a lot easier, however I wouldn't want anyone to be able to customize the images to edit the game graphics for that client alone. So yeah option two seemed good for me also, don't suppose you or anyone else has any tips on how to send classes like texture, sprites as a package?
-
What does "as a package" mean? You can just upload them on your server and access them with their URL.
But you don't want people to be able to edit them, which means that they will be downloaded everytime the game is ran? No local cache at all? That sounds very inefficient, especially for people with slow internet connections. You'd better embed them into your executable; this way only people who know how to generate the sources from the resources, and how to recompile your game, can modify them. Unless running the game with modified content can have critical impacts on your whole community of players, this sounds like a reasonable option. Much simpler and efficient.
-
As Laurent already said, you don't have to distribute your images as plain files with your client. You can embed them directly inside the final executable or a .DLL/.so if you want.
If you don't want to embed them directly, then maybe using something like PhysFS (http://icculus.org/physfs/) would work for you (I personally find it very convenient).
-
Oh right, that sounds like a better approach, I never knew you could store graphics as a DLL, I will need to have a look into this. Thanks for the information.
-
Of course you can, it's all just zeroes and ones, where you store them is irrelevant as long as you have access to them later and can read them. ;)
Just look at something like the XBM (http://en.wikipedia.org/wiki/X_BitMap) (X BitMap) format. It's explicitly defined in a form that makes it easily includable into C program sources. But there's nothing special about XBM, you could do the same with any data file - convert it to a textual C array representation and include it as part of your source and compile. There are easier/better ways, but you get the point (I hope).
-
That makes perfect sense, thanks for the tips!