summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraldrikboy <aldrikboy@gmail.com>2017-12-14 21:13:39 +0100
committeraldrikboy <aldrikboy@gmail.com>2017-12-14 21:13:39 +0100
commit98fb0bdcf3fb02f68f07a72cab211debb827e978 (patch)
tree494455cafaf238c6623186df821559e1f84fdebf
parentff30178f505c69bc70b0770a3220ebd6d4706c74 (diff)
Rotation FIXED!
-rw-r--r--Penguloon/Enemies/RedBalloon.cs2
-rw-r--r--Penguloon/Levels/IceLevel.cs4
-rw-r--r--Penguloon/Levels/Map.cs2
-rw-r--r--Penguloon/Levels/WaveManager.cs2
-rw-r--r--Penguloon/Objects/ObjectBase.cs60
-rw-r--r--Penguloon/Objects/PenguinObject.cs10
6 files changed, 68 insertions, 12 deletions
diff --git a/Penguloon/Enemies/RedBalloon.cs b/Penguloon/Enemies/RedBalloon.cs
index 01a3b41..b0f86f6 100644
--- a/Penguloon/Enemies/RedBalloon.cs
+++ b/Penguloon/Enemies/RedBalloon.cs
@@ -7,7 +7,7 @@ namespace Penguloon.Enemies
public RedBalloon(Map map) : base(map)
{
this.Texture = ContentManager.GetTexture("Enemies/red");
- this.Speed = 15f;
+ this.Speed = 45f;
this.Health = 1;
this.ChildObject = null;
}
diff --git a/Penguloon/Levels/IceLevel.cs b/Penguloon/Levels/IceLevel.cs
index ad34c0b..1778369 100644
--- a/Penguloon/Levels/IceLevel.cs
+++ b/Penguloon/Levels/IceLevel.cs
@@ -64,8 +64,8 @@ namespace Penguloon.Levels
{ OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO },
};
- Map.Objects.Add(new PenguinObject(new Vector2(0, 0), Map));
- Map.Objects.Add(new PenguinObject(new Vector2(Map.TileWidth * 2, 0), Map));
+ //Map.Objects.Add(new PenguinObject(new Vector2(0, 0), Map));
+ Map.Objects.Add(new PenguinObject(new Vector2(Map.TileWidth * 2, Map.TileHeight * 4), Map));
}
}
} \ No newline at end of file
diff --git a/Penguloon/Levels/Map.cs b/Penguloon/Levels/Map.cs
index 2ffcea0..0e3dde6 100644
--- a/Penguloon/Levels/Map.cs
+++ b/Penguloon/Levels/Map.cs
@@ -113,7 +113,7 @@ namespace Penguloon.Levels
{
var b = new RedBalloon(this);
b.Position = pos; b.TargetPosition = target;
- Enemies.Add(b);
+ Enemies.Insert(0, b);
}
}
}
diff --git a/Penguloon/Levels/WaveManager.cs b/Penguloon/Levels/WaveManager.cs
index d3d27d6..1a425a1 100644
--- a/Penguloon/Levels/WaveManager.cs
+++ b/Penguloon/Levels/WaveManager.cs
@@ -26,7 +26,7 @@ namespace Penguloon.Levels
private void CreateWaves()
{
- Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(RedBalloon), 1) }, 500));
+ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(RedBalloon), 5) }, 500));
}
public void StartSpawningEnemies()
diff --git a/Penguloon/Objects/ObjectBase.cs b/Penguloon/Objects/ObjectBase.cs
index 9834b39..a16f70c 100644
--- a/Penguloon/Objects/ObjectBase.cs
+++ b/Penguloon/Objects/ObjectBase.cs
@@ -15,6 +15,7 @@ namespace Penguloon.Objects
public float Range { get; set; }
public Texture2D Texture { get; set; }
+ public Texture2D RangeCircle { get; set; }
public float Rotation { get; set; }
public Vector2 Position { get; set; }
@@ -34,19 +35,31 @@ namespace Penguloon.Objects
{
this.Center = new Vector2(Position.X + ((TileSpanX * Map.TileWidth) / 2), Position.Y + ((TileSpanY * Map.TileHeight) / 2));
- for (int i = 0; i < Map.Enemies.Count; i++)
+ // loop from back of list to front so we always focus the balloons in front
+ for (int i = Map.Enemies.Count - 1; i >= 0; i--)
{
- if (Contains(Map.Enemies[i].Box.Location.ToVector2()))
+ if (Contains(Map.Enemies[i].Box.Center.ToVector2()))
{
Rotation = (float)GetRotation(Map.Enemies[i].Box.Center.ToVector2());
return;
}
}
+
+ if ((DateTime.Now - LastAttack).TotalMilliseconds > AttackSpeedMS)
+ {
+ LastAttack = DateTime.Now;
+ UpdateUnique(deltaTime);
+ }
}
+ public abstract void UpdateUnique(float deltaTime);
+
public void Draw(float deltaTime)
{
- float rotation = ((Rotation));
+ if(RangeCircle == null)
+ RangeCircle = CreateCircle((int)Range * 2);
+
+ float rot = (float)Rotation + (float)MathHelper.PiOver2;
Rectangle rec = new Rectangle(
(int)Position.X + ((int)(Map.TileWidth * TileSpanX)) / 2,
@@ -56,20 +69,53 @@ namespace Penguloon.Objects
Map.ParentScene.Main.SpriteBatch.Draw(Texture,
destinationRectangle: rec,
- rotation: rotation,
+ rotation: (float)rot,
origin: new Vector2(Texture.Width / 2, Texture.Height / 2));
- Map.ParentScene.Main.SpriteBatch.DrawString(ContentManager.GetFont("Fonts/GWENT/24"), Rotation.ToString(), rec.Location.ToVector2(), Color.Red);
+ Map.ParentScene.Main.SpriteBatch.Draw(RangeCircle,
+ destinationRectangle: new Rectangle((int)rec.X - ((int)Range), (int)rec.Y - ((int)Range), (int)Range * 2, (int)Range * 2));
+
+ DrawUnique(deltaTime);
+ }
+
+ public abstract void DrawUnique(float deltaTime);
+
+ private Texture2D CreateCircle(int radius)
+ {
+ Texture2D texture = new Texture2D(Map.ParentScene.Main.GraphicsDevice, radius, radius);
+ Color[] colorData = new Color[radius * radius];
+
+ float diam = radius / 2f;
+ float diamsq = diam * diam;
+
+ for (int x = 0; x < radius; x++)
+ {
+ for (int y = 0; y < radius; y++)
+ {
+ int index = x * radius + y;
+ Vector2 pos = new Vector2(x - diam, y - diam);
+ if (pos.LengthSquared() <= diamsq)
+ {
+ colorData[index] = Color.FromNonPremultiplied(200, 0, 0, 50);
+ }
+ else
+ {
+ colorData[index] = Color.Transparent;
+ }
+ }
+ }
+
+ texture.SetData(colorData);
+ return texture;
}
private double GetRotation(Vector2 enemyPos)
{
double radians = Math.Atan2(enemyPos.Y - Center.Y, enemyPos.X - Center.X);
- return (radians / MathHelper.PiOver2) * MathHelper.Pi;
+ return (radians);
}
- // The concise version...
private bool Contains(Vector2 point)
{
return ((point - Center).Length() <= Range);
diff --git a/Penguloon/Objects/PenguinObject.cs b/Penguloon/Objects/PenguinObject.cs
index e035f70..14ad30a 100644
--- a/Penguloon/Objects/PenguinObject.cs
+++ b/Penguloon/Objects/PenguinObject.cs
@@ -12,5 +12,15 @@ namespace Penguloon.Objects
this.TileSpanY = 1;
this.Range = Map.TileWidth * 2;
}
+
+ public override void DrawUnique(float deltaTime)
+ {
+
+ }
+
+ public override void UpdateUnique(float deltaTime)
+ {
+
+ }
}
} \ No newline at end of file