I am still kinda new to developing games in XNA and using classes with C#, but I want to start a semi-decent game project where I can learn without throwaway projects.
I want to devide my game up into classes. For example a main game class, a player class (i want two players, and they battle against each other), a level class (for drawing the world) and maybe later on things like a power up class and a networking class so I can make everything multiplayer.
But I don't know the best way to start using classes like this in an XNA game. Do I make a class like this:
namespace MyGame
{
class Player : MyGame
{
// whatever
}
}
or like this:
namespace MyGame
{
class Player : Microsoft.Xna.Framework.Game
{
// whatever
}
}
I want each class to have something along the lines of Initialize()
, Update()
and Draw()
methods, and I will use the spriteBatch and GraphicsDeviceManager from my main game class passed to these classes... but I also don't know the best way to pass them in, or even if I should be passing them in over making new ones in the classes themselves.
Any help is greatly appreciated. Thanks.
I want to start a semi-decent game project where I can learn without throwaway projects
- I'd just like to point out what a terrible plan this is. By all means create a complete project from end-to-end. But make it incredibly simple. Tic-Tac-Toe is probably a good starting point - you shouldn't even need to create any classes beyondMyGame
. After that make (for example) Pong - where you can have a Paddle class and an instance for each paddle (you might want to read stackoverflow.com/questions/3879204 this question). Save "semi-decent" until after you can make "crap". – Andrew Russell