add Vectors class and use Vectors.Round() & Vectors.Floor().
This commit is contained in:
parent
f05142066d
commit
92ace31d90
@ -122,7 +122,7 @@ namespace SemiColinGames {
|
||||
SpriteEffects effect = Facing == 1 ?
|
||||
SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
||||
Color color = Color.White;
|
||||
spriteBatch.Draw(Textures.Executioner.Get, Vector2.Round(Position), textureSource, color, 0f,
|
||||
spriteBatch.Draw(Textures.Executioner.Get, Vectors.Round(Position), textureSource, color, 0f,
|
||||
spriteCenter, Vector2.One, effect, 0f);
|
||||
}
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ namespace SemiColinGames {
|
||||
if (invincibilityTime > 0 && invincibilityTime % 0.2f > 0.1f) {
|
||||
color = new Color(0.5f, 0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
spriteBatch.Draw(Textures.Ninja.Get, Vector2.Floor(position), textureSource, color, 0f,
|
||||
spriteBatch.Draw(Textures.Ninja.Get, Vectors.Floor(position), textureSource, color, 0f,
|
||||
spriteCenter, Vector2.One, effect, 0f);
|
||||
}
|
||||
}
|
||||
|
@ -42,5 +42,6 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Timer.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)TreeScene.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)TreeWorld.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Vectors.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -38,7 +38,7 @@ namespace SemiColinGames {
|
||||
public void Draw(SpriteBatch spriteBatch) {
|
||||
Texture2D texture = Texture.Get;
|
||||
Vector2 spriteCenter = new Vector2(texture.Width / 2, texture.Height / 2);
|
||||
Vector2 drawPos = Vector2.Floor(Vector2.Subtract(Position, spriteCenter));
|
||||
Vector2 drawPos = Vectors.Floor(Vector2.Subtract(Position, spriteCenter));
|
||||
spriteBatch.Draw(texture, drawPos, Color.White);
|
||||
}
|
||||
}
|
||||
@ -78,7 +78,7 @@ namespace SemiColinGames {
|
||||
public void Draw(SpriteBatch spriteBatch) {
|
||||
Texture2D texture = Texture.Get;
|
||||
Vector2 center = new Vector2(texture.Width / 2, texture.Height / 2);
|
||||
spriteBatch.Draw(texture, Vector2.Floor(Vector2.Subtract(Position, center)), Color.White);
|
||||
spriteBatch.Draw(texture, Vectors.Floor(Vector2.Subtract(Position, center)), Color.White);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ namespace SemiColinGames {
|
||||
public void Draw(SpriteBatch spriteBatch) {
|
||||
Texture2D texture = Texture.Get;
|
||||
Vector2 spriteCenter = new Vector2(texture.Width / 2, texture.Height / 2);
|
||||
Vector2 drawPos = Vector2.Floor(Vector2.Subtract(Position, spriteCenter));
|
||||
Vector2 drawPos = Vectors.Floor(Vector2.Subtract(Position, spriteCenter));
|
||||
spriteBatch.Draw(texture, drawPos, null, Color.White, 0f,
|
||||
spriteCenter, Vector2.One, SpriteEffects.FlipHorizontally, 0f);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace SemiColinGames {
|
||||
public void Draw(SpriteBatch spriteBatch) {
|
||||
Texture2D texture = Texture.Get;
|
||||
Vector2 spriteCenter = new Vector2(texture.Width / 2, texture.Height / 2);
|
||||
Vector2 drawPos = Vector2.Floor(Vector2.Subtract(Position, spriteCenter));
|
||||
Vector2 drawPos = Vectors.Floor(Vector2.Subtract(Position, spriteCenter));
|
||||
spriteBatch.Draw(texture, drawPos, Color.White);
|
||||
}
|
||||
}
|
||||
@ -52,7 +52,7 @@ namespace SemiColinGames {
|
||||
public void Draw(SpriteBatch spriteBatch) {
|
||||
Texture2D texture = Texture.Get;
|
||||
Vector2 spriteCenter = new Vector2(texture.Width / 2, texture.Height / 2);
|
||||
Vector2 drawPos = Vector2.Floor(Vector2.Subtract(Position, spriteCenter));
|
||||
Vector2 drawPos = Vectors.Floor(Vector2.Subtract(Position, spriteCenter));
|
||||
spriteBatch.Draw(texture, drawPos, Color.White);
|
||||
}
|
||||
}
|
||||
|
15
Shared/Vectors.cs
Normal file
15
Shared/Vectors.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
|
||||
namespace SemiColinGames {
|
||||
public static class Vectors {
|
||||
public static Vector2 Floor(Vector2 v) {
|
||||
return new Vector2((float) Math.Floor(v.X), (float) Math.Floor(v.Y));
|
||||
}
|
||||
|
||||
public static Vector2 Round(Vector2 v) {
|
||||
return new Vector2((float) Math.Round(v.X), (float) Math.Round(v.Y));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user