Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Getting graphics from a server  (Read 3087 times)

0 Members and 1 Guest are viewing this topic.

Eevee204

  • Newbie
  • *
  • Posts: 9
    • View Profile
Getting graphics from a server
« 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?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Getting graphics from a server
« Reply #1 on: July 09, 2014, 11:19:01 pm »
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).

Eevee204

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Getting graphics from a server
« Reply #2 on: July 09, 2014, 11:31:09 pm »
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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Getting graphics from a server
« Reply #3 on: July 10, 2014, 08:13:17 am »
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.
Laurent Gomila - SFML developer

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Getting graphics from a server
« Reply #4 on: July 10, 2014, 06:03:34 pm »
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 would work for you (I personally find it very convenient).

Eevee204

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Getting graphics from a server
« Reply #5 on: July 10, 2014, 11:22:37 pm »
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.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Getting graphics from a server
« Reply #6 on: July 10, 2014, 11:28:39 pm »
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 (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).

Eevee204

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Getting graphics from a server
« Reply #7 on: July 10, 2014, 11:57:07 pm »
That makes perfect sense, thanks for the tips!