Basically before i implemented inheritence into my game, introducing 2 new classes, player and enemy, (not using enemy atm), the level was loaded and drawn (including the player paddle) during the countdown screen (the countdown before the level starts).
Now all of the level is drawn apart from the player paddle when i have implemented inheritence into my game, inheriting from a class called Paddle, where the Player and Enemy classes are derived classes. I have experimented between overriding the draw method in the player class from the base/paddle class and then using the draw method in the base class.
Maybe it's nothing to do with the draw method necessarily but all i know is that the player isnt being drawn during the countdown screen but when the countdown screen finishes, the player is drawn. This may seem like a small problem or change but it's really frustrating, as i cant work out what's causing this.
The relevent code is provided below:
code from the player class
//constructor
public Player(PlayerIndex newID, Texture2D newTexture, Vector2 newPosition, Viewport theViewport, Color newColour)
: base(newTexture, newPosition, theViewport, newColour)
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
spriteBatch.Draw(pTexture, pPosition, pRectangle, pColour);
//base.Draw(gameTime, spriteBatch);
}
code from the paddle class
//constructor
public Paddle(Texture2D newTexture, Vector2 newPosition, Viewport theViewport, Color newColour)
{
pTexture = newTexture;
pPosition = newPosition;
//theres more code here but it's assigning parameter values to properties in this class
}
public virtual void Update(GameTime gameTime)
{
pRectangle = new Rectangle((int)pPosition.X, (int)pPosition.Y, pWidth, pHeight);
}
public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
spriteBatch.Draw(pTexture, pPosition, pRectangle, pColour);
}
code from game1 class
public void DrawPreGameCountdownScreen(GameTime gameTime)
{
DrawPlayingGameScreen(gameTime);
//more code here but it's irrelevent....
}
public void DrawPlayingGameScreen(GameTime gameTime)
{
DrawBlocks(gameTime);
player1.Draw(gameTime, spriteBatch);
//more code here... but irrelevent to this...
}
The player1 is obviously the player and it's of type Player and not Paddle (as i have made the Paddle class abstract... as i don't want to allow for creating a Paddle object directly).
I have put all of the properties in the Paddle class as protected also.
I am also using game states to differentiate between different points in the game, so in the update method for the countdown screen it basically decreases the value of the timer and before that checks that the timer isnt at 0 before doing so, otherwise the state changes.
As i say, this worked perfectly before, so i assume that its something to do with the player class or something ive done wrong.
If you need any more info, please feel free to ask and any ideas/solutions, etc please let me know :).
Thank you v much for the help in advanced.