Game Development Community

Player Editing Questions

by Richard Van Stone · in Torque Game Engine · 01/08/2005 (11:43 am) · 1 replies

I want to create a system where players can choose from five different dts models as their character in game. The model they pick will be saved in their preferences and stored on the mysql database. I'm thinking I'm going to have to edit the player.cs file so that it loads the appropriate model based off of information I'm going to store in a global variable. This is my thought process as to how it'll work. I know it's not in torque syntax yet, please let me know if I'm on the right track

Have a global variable such as playerchoice

playerchoice.model = bear
playerchoice.texture = bear01.tga
playerchoice.scale = 0.5

And then in the player.cs it'll set the playermodel, texture and scale.

Is this the best way to do it?

Richard

#1
01/08/2005 (1:38 pm)
A global variable? If you can get away with just one global variable, then it must be a single player game. If this is a single player game, then I think you should avoid using MySQL. If you used MySQL, then you would have to do one of two things: have each player install and run a copy of MySQL or have each player connect to your MySQL server to store their preferences. Both are more complicated than a single player game needs to be. If the only point of MySQL is to store a few preferences for a single player game, consider using a preferences.txt file instead.

If this is a multiplayer, server-based game, you need one for each player. Then instead of a global variable you would make the playerchoice variable a part of the player class. Also, sending the strings "bear" and "bear01.tga" over the network is inefficient. Here's an alternative. You said there are only five choices, right? So player choice should be a number between 1 and 5 (simpler to keep track of in database, simpler to send over network). You could create functions that converted these numbers into models or textures. playertexture(3) -> "bear01.tga" for example

Aside from that one small objection, I think you're on the right track. Good luck.