Game Development Community

Custom Player Icons

by Scott Doerrfeld · in Torque Game Engine · 06/22/2006 (12:07 pm) · 2 replies

In my multiplayer game each player sets up a user profile before entering the game (Name, Location, DOB, etc.). While playing, you can view other players' profiles.

I am trying to implement a feature of the profile that allows a player to load their own custom icon from their hard drive (.jpg/.png). This is simple enough to do. However, getting it so the players can see each other's icons is proving to be more difficult. Does anyone have any advice on this? How can I get the image file from client to server so that all clients can see it? Thank you.

#1
06/22/2006 (12:17 pm)
Well, you could transmit the file to them with TCPObject. There's a couple good resources on it, just search for send binary files.
#2
06/22/2006 (12:19 pm)
Depends how you want to accomplish it. It's pretty easy trough both script and C++, but basically; each player has a bitmap that it sends to the server when it connects.

This is what I would do in stock TGE:

1. The client should load the bitmap. This could be done trough fileObject.
2. Make sure the file is within the scope of what the server expects to receive.
3. Send it to the server, I would use TCPObject here rather than using gameConnection.
4. Validate the bitmap on the server.
5. Bind it to the player which sent it.
6. When a player joins the game, iterate trough the clientGroup and grab the icon associated with each player and send it to the connecting client. Also send the connecting clients image to all the clients in the clientGroup.
7. Each client that receives a image either updates it via setModPath() or Fairfaxe's resource. Then use it.

Edit: Formatting.