Skip to content

Instantly share code, notes, and snippets.

@hamoungh
Created March 20, 2015 19:04
Show Gist options
  • Save hamoungh/d20b6708e8b8bce4f38c to your computer and use it in GitHub Desktop.
Save hamoungh/d20b6708e8b8bce4f38c to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.GamerServices;
using SpriteClasses;
namespace Week07_Animation
{
public class Human : PlayerAnimationManager
{
public Human(ContentManager Content)
: base(Content.Load<Texture2D>("walkCycle1"),
new Vector2(100, 450), new Vector2(10, 0),
true, 0, 2, SpriteEffects.None)
{
Animation animation = new Animation();
//player animations
//stop
animation.AddCell(Content.Load<Texture2D>("walkCycle1")); //0
AddAnimation("idle", animation);
animation = new Animation();
//walk right
animation.AddCell(Content.Load<Texture2D>("walkCycle2")); //0
animation.AddCell(Content.Load<Texture2D>("walkCycle3")); //1
animation.AddCell(Content.Load<Texture2D>("walkCycle4")); //2
animation.AddCell(Content.Load<Texture2D>("walkCycle5")); //3
AddAnimation("walk", animation);
animation = new Animation();
//kick
animation.AddCell(Content.Load<Texture2D>("kick1")); //0
animation.AddCell(Content.Load<Texture2D>("kick2")); //1
animation.AddCell(Content.Load<Texture2D>("kick3")); //2
AddAnimation("kick", animation);
//what should he be doing when program starts?
Idle();
}
public override void Right()
{
base.Right();
//make him face right
CurrentAnimation = "walk";
animationDictionary["walk"].LoopAll(.5f);
}
public override void Left()
{
base.Left();
//make him face left
SetMoveLeft();
CurrentAnimation = "walk";
animationDictionary["walk"].LoopAll(.5f);
}
public override void Idle()
{
base.Idle();
//don't change spriteeffect so he stays pointing the same direction as he was
CurrentAnimation = "idle";
//animation is only one cell so we don't have to tell it to play or loop
}
public void Kick()
{
CurrentAnimation = "kick";
//don't change spriteeffect so he stays pointing the same direction as he was
animationDictionary["kick"].PlayAll(1f);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment