WE SHMOOVIN BIGTIME

master
BraydonKains 5 years ago
parent 830891a71e
commit 4be05cff2d

@ -24,19 +24,19 @@
"id": 1,
"x": 64,
"y": 32,
"timer": 3
"timer": 8
},
{
"id": 2,
"x": 32,
"y": 32,
"timer": 3
"timer": 8
},
{
"id": 3,
"x": 0,
"y": 32,
"timer": 3
"timer": 8
}
]
},
@ -48,13 +48,13 @@
"id": 1,
"x": 32,
"y": 64,
"timer": 3
"timer": 8
},
{
"id": 2,
"x": 64,
"y": 64,
"timer": 3
"timer": 8
}
]

@ -11,6 +11,8 @@ namespace SeeNoEvil.Character {
private Animation CurrentAnimation;
public Frame CurrentFrame =>
CurrentAnimation.GetFrame();
public bool IsDefault =>
CurrentAnimation.Id == 1;
public AnimationController(AnimationSetModel model) {
Name = model.Name;

@ -1,14 +1,7 @@
using Microsoft.Xna.Framework;
namespace SeeNoEvil.Character {
public enum Direction {
Up,
Down,
Left,
Right
}
public class Cat : Character {
private Direction Facing;
public Cat(Vector2 position, Direction facing) : base(position) {
AnimationController = new AnimationController(AnimationParser.ReadAnimationJson("SeeNoEvil/Animation/cat.json"));
Width = AnimationController.Width;
@ -16,24 +9,24 @@ namespace SeeNoEvil.Character {
Facing = facing;
}
public void Move(Direction direction) {
int x = 0, y = 0;
switch(direction) {
case Direction.Up:
y = -1;
break;
case Direction.Down:
y = 1;
break;
case Direction.Left:
x = -1;
break;
case Direction.Right:
x = 1;
break;
public override void Move(Direction direction) {
if(!Moving) {
switch(direction) {
case Direction.Up:
AnimationController.ChangeAnimation(3);
break;
case Direction.Down:
AnimationController.ChangeAnimation(3);
break;
case Direction.Left:
AnimationController.ChangeAnimation(2);
break;
case Direction.Right:
AnimationController.ChangeAnimation(2);
break;
}
base.Move(direction);
}
Destination = Vector2.Add(Position, new Vector2(Width*x, Height*y));
Velocity = new Vector2(x, y);
}
}
}

@ -4,18 +4,20 @@ using Microsoft.Xna.Framework.Graphics;
namespace SeeNoEvil.Character {
public class Character {
protected Vector2 Destination {get; set;}
protected Vector2 Velocity {get; set;}
protected Vector2 Position {get; private set;}
protected bool Transform =>
!Destination.Equals(Vector2.Zero) &&
!Velocity.Equals(Vector2.Zero) &&
!Position.Equals(Destination);
private Vector2 Destination {get; set;}
private Vector2 Velocity {get; set;}
private Vector2 Position {get; set;}
private Texture2D SpriteSheet;
protected AnimationController AnimationController;
protected Texture2D SpriteSheet;
protected int Width;
protected int Height;
protected Direction Facing;
protected bool Moving =>
!Destination.Equals(Vector2.Zero) &&
!Velocity.Equals(Vector2.Zero) &&
!Position.Equals(Destination);
public Character(Vector2 position) {
Position = position;
@ -29,8 +31,10 @@ namespace SeeNoEvil.Character {
// TODO Do I want to move every frame?
public void Update() {
if(Transform)
if(Moving)
Position = Vector2.Add(Position, Velocity);
else if(!AnimationController.IsDefault)
AnimationController.ChangeAnimation(1);
}
public void Draw(SpriteBatch spriteBatch) {
@ -42,5 +46,33 @@ namespace SeeNoEvil.Character {
spriteBatch.Draw(SpriteSheet, Position, srcRectangle, Color.White);
// spriteBatch.Draw(SpriteSheet, Position, Color.White);
}
public virtual void Move(Direction direction) {
if(!Moving) {
int x = 0, y = 0;
switch(direction) {
case Direction.Up:
y = -1;
break;
case Direction.Down:
y = 1;
break;
case Direction.Left:
x = -1;
break;
case Direction.Right:
x = 1;
break;
}
Destination = Vector2.Add(Position, new Vector2(Width*x, Height*y));
Velocity = new Vector2(x, y);
}
}
}
public enum Direction {
Up,
Down,
Left,
Right
}
}
Loading…
Cancel
Save