Shorthand to transform component in base entity class

This commit is contained in:
2012-09-24 15:21:49 +02:00
parent 9d46d0ae8a
commit 6ee4611182
4 changed files with 155 additions and 155 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ namespace DepthsBelow
graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferWidth = 1280;
graphics.PreferredBackBufferHeight = 720; graphics.PreferredBackBufferHeight = 720;
graphics.IsFullScreen = true; graphics.IsFullScreen = false;
this.IsMouseVisible = true; this.IsMouseVisible = true;
} }
+4
View File
@@ -8,6 +8,7 @@ namespace DepthsBelow
public class Entity public class Entity
{ {
List<Component> Components; List<Component> Components;
public TransformComponent transform;
public Entity() public Entity()
{ {
@@ -28,6 +29,9 @@ namespace DepthsBelow
public void AddComponent(Component c) public void AddComponent(Component c)
{ {
Components.Add(c); Components.Add(c);
if (c is TransformComponent)
this.transform =(TransformComponent)c;
} }
} }
} }
+1 -5
View File
@@ -15,9 +15,6 @@ namespace DepthsBelow
Core game; Core game;
static Texture2D Texture; static Texture2D Texture;
// Components
TransformComponent transform;
static public void LoadContent(Core game) static public void LoadContent(Core game)
{ {
Texture = game.Content.Load<Texture2D>("images/soldier"); Texture = game.Content.Load<Texture2D>("images/soldier");
@@ -32,8 +29,7 @@ namespace DepthsBelow
rc.Texture = Texture; rc.Texture = Texture;
this.AddComponent(rc); this.AddComponent(rc);
transform = new TransformComponent(this); this.AddComponent(new TransformComponent(this));
this.AddComponent(transform);
} }
public void Update(GameTime gameTime) public void Update(GameTime gameTime)
@@ -6,7 +6,7 @@ using Microsoft.Xna.Framework;
namespace DepthsBelow namespace DepthsBelow
{ {
class TransformComponent : Component public class TransformComponent : Component
{ {
public Vector2 Position; public Vector2 Position;
public float Rotation; public float Rotation;