almostJump
This commit is contained in:
parent
6e4eaf7915
commit
5c4e67ddb4
1 changed files with 35 additions and 2 deletions
|
@ -14,18 +14,26 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
{
|
||||
bool isAlive = true;
|
||||
public int health;
|
||||
public bool isGoRight;
|
||||
public Vector2 playerVelocity;
|
||||
public int rightBorder;
|
||||
|
||||
public Player(Vector2 position) : base(position)
|
||||
{
|
||||
Width = 32;
|
||||
Height = 64;
|
||||
AppManager.Instance.InputManager.MovEventJump += Jump;
|
||||
AppManager.Instance.InputManager.ShootEvent += Shoot;
|
||||
|
||||
playerVelocity = new Vector2(100, 0);
|
||||
rightBorder = (int)position.X + 20;
|
||||
}
|
||||
public bool IsAlive { get { return isAlive; } }
|
||||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack", "DeathFromZombie" }, "ZombieMoveLeft");//TODO: Change to player
|
||||
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
Move(gameTime);
|
||||
}
|
||||
public void Kill()
|
||||
{
|
||||
|
||||
|
@ -58,5 +66,30 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
{
|
||||
|
||||
}
|
||||
public void Move(GameTime gameTime)
|
||||
{
|
||||
float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if (isGoRight)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("ZombieMoveRight");
|
||||
}
|
||||
velocity = playerVelocity * delta;
|
||||
}
|
||||
else if (!isGoRight)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveLeft")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("ZombieMoveLeft");
|
||||
}
|
||||
velocity = -playerVelocity * delta;
|
||||
}
|
||||
if (Pos.X >= rightBorder)
|
||||
{
|
||||
Pos.X = rightBorder
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue