Skip to content

Instantly share code, notes, and snippets.

@Naoray
Created October 5, 2017 11:26
Show Gist options
  • Save Naoray/b4d8122e468b6f9b60dc5a64fd6e80e6 to your computer and use it in GitHub Desktop.
Save Naoray/b4d8122e468b6f9b60dc5a64fd6e80e6 to your computer and use it in GitHub Desktop.
Entity
class Entity
{
protected Texture2D _texture;
public Vector2 Position;
protected Vector2 _velocity;
public Vector2 Velocity { get { return _velocity; } }
public Entity(Texture2D texture)
{
_texture = texture;
}
public virtual void Update(GameTime gameTime)
{
Position += _velocity * (float)gameTime.ElapsedGameTime.TotalSeconds;
}
public virtual void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(_texture, new Rectangle((int)Position.X, (int)Position.Y, _texture.Width, _texture.Height), Color.White);
}
public Rectangle HitBox => new Rectangle((int)Position.X, (int)Position.Y, _texture.Width, _texture.Height);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment