Shorthand to transform component in base entity class
This commit is contained in:
@@ -28,7 +28,7 @@ namespace DepthsBelow
|
||||
|
||||
graphics.PreferredBackBufferWidth = 1280;
|
||||
graphics.PreferredBackBufferHeight = 720;
|
||||
graphics.IsFullScreen = true;
|
||||
graphics.IsFullScreen = false;
|
||||
|
||||
this.IsMouseVisible = true;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace DepthsBelow
|
||||
public class Entity
|
||||
{
|
||||
List<Component> Components;
|
||||
public TransformComponent transform;
|
||||
|
||||
public Entity()
|
||||
{
|
||||
@@ -28,6 +29,9 @@ namespace DepthsBelow
|
||||
public void AddComponent(Component c)
|
||||
{
|
||||
Components.Add(c);
|
||||
|
||||
if (c is TransformComponent)
|
||||
this.transform =(TransformComponent)c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,6 @@ namespace DepthsBelow
|
||||
Core game;
|
||||
static Texture2D Texture;
|
||||
|
||||
// Components
|
||||
TransformComponent transform;
|
||||
|
||||
static public void LoadContent(Core game)
|
||||
{
|
||||
Texture = game.Content.Load<Texture2D>("images/soldier");
|
||||
@@ -32,8 +29,7 @@ namespace DepthsBelow
|
||||
rc.Texture = Texture;
|
||||
this.AddComponent(rc);
|
||||
|
||||
transform = new TransformComponent(this);
|
||||
this.AddComponent(transform);
|
||||
this.AddComponent(new TransformComponent(this));
|
||||
}
|
||||
|
||||
public void Update(GameTime gameTime)
|
||||
|
||||
@@ -6,7 +6,7 @@ using Microsoft.Xna.Framework;
|
||||
|
||||
namespace DepthsBelow
|
||||
{
|
||||
class TransformComponent : Component
|
||||
public class TransformComponent : Component
|
||||
{
|
||||
public Vector2 Position;
|
||||
public float Rotation;
|
||||
|
||||
Reference in New Issue
Block a user