Hey everyone. I'm writing a small drugwars style game in Visual C#, basically just generating random numbers and adding them and subtracting them from the user's cash. I have a quick question on how to store user variables. I don't know whether to store the variables for the user's stats in the same class that I write the main functions for opening windows and stuff in, or should I build another class just to store user variables. I could also inherit the main functions class into my player stats class and have access to my variables and my functions also. Any help on what more experienced programs would do would be helpful.
Know the answer? Post it. Somebody with the same question will find it here.
Sam HobbsRank #107 · 20.5K reputationPosted Jan 17, 2010, 8:24 AM EST
0
I am sorry, but "opening windows and stuff in" is very general; can you calrify what that is? Is it data that would be different for each user? Also, do you want to support multiple users within a Windows account (user)?
Sorry, I'll try to be a bit more specific. What I meant by opening windows and stuff is that the first class holds functions related to basic game workings. This includes things like generating random numbers, opening new windows and other functions needed to run the game but that don't really require user data. They are essentially just the basic tools for running the game. Also, the user data would be different for each player, but the variables holding the data are the same. For example, each player has a cash variable that has a different value, but the variable is the same for every player. The variables are the same, only the values differ from player to player. Thanks.
0
Sam HobbsRank #107 · 20.5K reputationPosted Jan 17, 2010, 1:01 PM EST
0
Developers usually assume things such as "variables holding the data are the same" and "a cash variable that has a different value, but the variable is the same for every player" and "values differ from player to player". So when I ask if the data is the same or different, I mean what you mean in the sense that the data is defined the same for all users; it is just the instances of the data that varies.
So yes, the data "related to basic game workings" should be separate from the data for each user. Windows defines various folder for such purposes. If the data for the game workings does not change unless it gets updated in the manner that executables get updated, then the data can go in the Program Files subdirectory for your application along with the executables and such. If there is one copy of the data for the computer, but it needs to be updated during execution, then I am sure there is a folder for that but I don't know; I would have t look it up.
Thanks for the reply but I am still a little confused. In the program itself should I declare two classes, one for player data and the other for game functions? Or should I include player data in the game functions class. Thanks.
Sam HobbsRank #107 · 20.5K reputationPosted Jan 17, 2010, 8:24 AM EST
Ron5 reputationPosted Jan 17, 2010, 10:34 AM EST
Sam HobbsRank #107 · 20.5K reputationPosted Jan 17, 2010, 1:01 PM EST
So yes, the data "related to basic game workings" should be separate from the data for each user. Windows defines various folder for such purposes. If the data for the game workings does not change unless it gets updated in the manner that executables get updated, then the data can go in the Program Files subdirectory for your application along with the executables and such. If there is one copy of the data for the computer, but it needs to be updated during execution, then I am sure there is a folder for that but I don't know; I would have t look it up.
Ron5 reputationPosted Jan 18, 2010, 6:42 PM EST