Created
October 5, 2017 11:26
-
-
Save Naoray/b4d8122e468b6f9b60dc5a64fd6e80e6 to your computer and use it in GitHub Desktop.
Entity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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