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.
Here's what I've got so far:
namespace DrugWarsBeta4 { public partial class mainMenu : Form { public mainMenu() { InitializeComponent(); }
private void mainMenu_Load(object sender, EventArgs e) {
}
public void pDisplayStats() { }
public static int pRandomNumber(int pMin,int pMax) { Random pUserNum = new Random(); return pUserNum.Next(pMin,pMax); }
public void pDisplayBuy() { subMenu pBuyScreen = new subMenu(); pBuyScreen.ShowDialog(); } }
public class pPlayerInfo : mainMenu { pPlayerInfo pCurrentPlayer;
public pPlayerInfo() { pCurrentPlayer = new pPlayerInfo(); } } }
|
Thanks.
RonPosted Jan 18, 2010, 11:42 PM
Sam HobbsPosted Jan 17, 2010, 6:01 PM
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.
RonPosted Jan 17, 2010, 3:34 PM
Sam HobbsPosted Jan 17, 2010, 1:24 PM