calculate spriteCenter more rigorously
This commit is contained in:
parent
36a72b938f
commit
b4e644c2d4
@ -47,10 +47,12 @@ namespace SemiColinGames {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class NPC {
|
public class NPC {
|
||||||
|
// TODO: load sprite sizes from metadata.
|
||||||
private const int spriteWidth = 96;
|
private const int spriteWidth = 96;
|
||||||
private const int spriteHeight = 81;
|
private const int spriteHeight = 82;
|
||||||
private const int spriteCenterYOffset = 10;
|
private const int groundPadding = 7;
|
||||||
private readonly Vector2 eyeOffset = new Vector2(4, -3);
|
private readonly Vector2 spriteCenter;
|
||||||
|
private readonly Vector2 eyeOffset = new Vector2(4, -9);
|
||||||
|
|
||||||
private readonly FSM<NPC> fsm;
|
private readonly FSM<NPC> fsm;
|
||||||
private AABB physicsBox;
|
private AABB physicsBox;
|
||||||
@ -58,6 +60,7 @@ namespace SemiColinGames {
|
|||||||
|
|
||||||
public NPC(Point position, int facing) {
|
public NPC(Point position, int facing) {
|
||||||
Position = position;
|
Position = position;
|
||||||
|
spriteCenter = new Vector2(spriteWidth / 2, spriteHeight - halfSize.Y - groundPadding);
|
||||||
physicsBox = new AABB(position.ToVector2(), halfSize);
|
physicsBox = new AABB(position.ToVector2(), halfSize);
|
||||||
Facing = facing;
|
Facing = facing;
|
||||||
fsm = new FSM<NPC>(new Dictionary<string, IState<NPC>> {
|
fsm = new FSM<NPC>(new Dictionary<string, IState<NPC>> {
|
||||||
@ -103,8 +106,6 @@ namespace SemiColinGames {
|
|||||||
public void Draw(SpriteBatch spriteBatch) {
|
public void Draw(SpriteBatch spriteBatch) {
|
||||||
Rectangle textureSource = Sprites.Executioner.GetTextureSource(
|
Rectangle textureSource = Sprites.Executioner.GetTextureSource(
|
||||||
fsm.StateName, Clock.ModelTime.TotalSeconds);
|
fsm.StateName, Clock.ModelTime.TotalSeconds);
|
||||||
// TODO: move this into Sprite metadata.
|
|
||||||
Vector2 spriteCenter = new Vector2(spriteWidth / 2, spriteHeight / 2 + spriteCenterYOffset);
|
|
||||||
SpriteEffects effect = Facing == 1 ?
|
SpriteEffects effect = Facing == 1 ?
|
||||||
SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
||||||
Color color = Color.White;
|
Color color = Color.White;
|
||||||
|
Loading…
Reference in New Issue
Block a user