move Draw() into Player & Shot
This commit is contained in:
parent
b5853828bd
commit
d8f3d940ef
@ -45,17 +45,11 @@ namespace SemiColinGames {
|
|||||||
SamplerState.PointClamp, DepthStencilState.Default,
|
SamplerState.PointClamp, DepthStencilState.Default,
|
||||||
RasterizerState.CullNone);
|
RasterizerState.CullNone);
|
||||||
|
|
||||||
// Draw player.
|
// Draw player, then shots.
|
||||||
Texture2D playerTexture = world.Player.Texture.Get;
|
world.Player.Draw(spriteBatch);
|
||||||
Vector2 spriteCenter = new Vector2(playerTexture.Width / 2, playerTexture.Height / 2);
|
|
||||||
Vector2 drawPos = Vector2.Floor(Vector2.Subtract(world.Player.Position, spriteCenter));
|
|
||||||
spriteBatch.Draw(playerTexture, drawPos, Color.White);
|
|
||||||
|
|
||||||
// Draw shots.
|
|
||||||
foreach (ShmupWorld.Shot s in world.Shots) {
|
foreach (ShmupWorld.Shot s in world.Shots) {
|
||||||
Texture2D texture = s.Texture.Get;
|
s.Draw(spriteBatch);
|
||||||
Vector2 center = new Vector2(texture.Width / 2, texture.Height / 2);
|
|
||||||
spriteBatch.Draw(texture, Vector2.Floor(Vector2.Subtract(s.Position, center)), Color.White);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finish drawing sprites.
|
// Finish drawing sprites.
|
||||||
|
@ -9,6 +9,7 @@ namespace SemiColinGames {
|
|||||||
public TextureRef Texture = Textures.Yellow2;
|
public TextureRef Texture = Textures.Yellow2;
|
||||||
// Center of player sprite.
|
// Center of player sprite.
|
||||||
public Vector2 Position = new Vector2(48, 1080 / 8);
|
public Vector2 Position = new Vector2(48, 1080 / 8);
|
||||||
|
// TODO: use a bounds rect instead of HalfSize.
|
||||||
public Vector2 HalfSize = new Vector2(16, 10);
|
public Vector2 HalfSize = new Vector2(16, 10);
|
||||||
|
|
||||||
private float speed = 150f;
|
private float speed = 150f;
|
||||||
@ -36,6 +37,13 @@ namespace SemiColinGames {
|
|||||||
}
|
}
|
||||||
return shots;
|
return shots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
spriteBatch.Draw(texture, drawPos, Color.White);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Shot {
|
public class Shot {
|
||||||
@ -68,6 +76,12 @@ namespace SemiColinGames {
|
|||||||
(int) HalfSize.X * 2,
|
(int) HalfSize.X * 2,
|
||||||
(int) HalfSize.Y * 2);
|
(int) HalfSize.Y * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly Rectangle Bounds;
|
public readonly Rectangle Bounds;
|
||||||
|
Loading…
Reference in New Issue
Block a user