Skip to content

Commit

Permalink
added new assets made it so enemy rotates aswell
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Perdue committed Mar 13, 2022
1 parent 805ef79 commit b48aa01
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 6 deletions.
Binary file added Assets/LancasterGuy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/LancasterGuy_Fists_Attacked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/LancasterGuy_Fists_Resting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/UclanGuy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/UclanGuy_Fists_Attacked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/UclanGuy_Fists_Resting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/YorkGuy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/YorkGuy_Fists_Attacked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/YorkGuy_Fists_Resting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Zombie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Zombie_Fists_Attacked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Zombie_Fists_Resting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 16 additions & 1 deletion Characters/Enemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void newStartDistance(int distanceFromStart, List<Node> path)

public Enemy(string directionName, float distance, Vector2 location)
{
playerModelPath = "Assets/dave.png";
playerModelPath = "FinalAssets/Zombie.png";
isEnemy = true;
if (directionName == "up" || directionName == "left")
direction = -1;
Expand Down Expand Up @@ -375,6 +375,21 @@ public override void Update(GameTime delta)
{
player = (Player)Scene.GameObjects.Where(x => x is Player).FirstOrDefault();
}
if(player!=null)
{
Vector2 deltaPos = new Vector2((player.Position.X - Position.X), -(player.Position.Y - Position.Y));
float angleA = sprite.Rotation;
if (deltaPos.Y >= 0)
{
angleA = (float)Math.Atan(deltaPos.X / deltaPos.Y);
}
else
{
angleA = (float)(Math.Atan(deltaPos.X / deltaPos.Y) + Math.PI);
}

sprite.Rotation = angleA;
}
if (!pushStats.isPushed() && attacking)
{
attacking = false;
Expand Down
2 changes: 1 addition & 1 deletion Characters/EnemySprint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class EnemySprint : Enemy
{
public EnemySprint(string directionName, float distance, Vector2 location) : base(directionName, distance, location)
{
playerModelPath = "Assets/daveSprint.png";
playerModelPath = "FinalAssets/UclanGuy.png";
sprite.Texture = AssetManager.AttemptLoad<Texture2D>(playerModelPath);
speed = 150;
damage = 7;
Expand Down
2 changes: 1 addition & 1 deletion Characters/EnemyTank.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class EnemyTank : Enemy
{
public EnemyTank(string directionName, float distance, Vector2 location) : base(directionName, distance, location)
{
playerModelPath = "Assets/daveTank.png";
playerModelPath = "FinalAssets/YorkGuy.png";
sprite.Texture = AssetManager.AttemptLoad<Texture2D>(playerModelPath);
speed = 50;
damage = 20;
Expand Down
2 changes: 1 addition & 1 deletion Characters/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Player : Character
//public Timer cooldown;
public Player()
{
playerModelPath = "Assets/TestModel.png";
playerModelPath = "FinalAssets/LancasterGuy.png";
sprite = new SpriteComponent()
{
Texture = AssetManager.AttemptLoad<Texture2D>(playerModelPath),
Expand Down
4 changes: 2 additions & 2 deletions Entities/Weapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public bool checkAttack(Vector2 newPos,bool player)
currentEnemy.onDamage(damage*character.damage, character.attackDirection, (int)(knockback * 1.5));
hit = true;
}
else if (Math.Abs(enemyPos.X - currentPos.X) < 40 && Math.Abs(enemyPos.Y - currentPos.Y) < 40)
else if (Math.Abs(enemyPos.X - currentPos.X) < 35 && Math.Abs(enemyPos.Y - currentPos.Y) < 35)
{
currentEnemy.onDamage(damage, character.attackDirection, (int)(knockback * 1.5));
hit = true;
Expand Down Expand Up @@ -181,7 +181,7 @@ public virtual bool Attack(bool lungeAttack,bool player)
Point enemyTile = Scene.GridToTileLocation(enemy.Position);
if (lungeAttack)
{
if (Math.Abs(enemy.Position.X - character.Position.X) < 40 && Math.Abs(enemy.Position.Y - character.Position.Y) < 40)
if (Math.Abs(enemy.Position.X - character.Position.X) < 35 && Math.Abs(enemy.Position.Y - character.Position.Y) < 35)
{
enemy.onDamage(damage * character.damage, character.attackDirection, (int)(knockback * 1.5));
isAttacking = false;
Expand Down
Binary file modified campus-crawl.teproj
Binary file not shown.

0 comments on commit b48aa01

Please sign in to comment.