public override void Initialize() { base.Initialize(); _tag = "Player"; // Initialise EntityComponeents. stateMachine = AddComponent <StateMachine>() as StateMachine; physicsBody = AddComponent <PhysicsBody>() as PhysicsBody; circleCollider = AddComponent <CircleCollider>() as CircleCollider; // Set our starting position. transform.SetPosition(new Vector2(50f, 400f)); // Set our dimensions. transform.SetDimensions(new Vector2(64, 64)); // Set the dimensions for the circle collider. Width and Height are used to center the collider, // radius is equal to half the width of the character. circleCollider.SetColliderDimensions(transform.dimensions.X, transform.dimensions.Y, 32); playerRun = new Animation(); playerIdle = new Animation(); playerJump = new Animation(); //Image playerRunSpriteSheet = new Image(); //playerRunSpriteSheet.Init("Graphics/playerRun", Vector2.Zero, 1, 1); //playerRun.Init(playerRunSpriteSheet, Vector2.Zero, 40, 35, 6, 100, true); // Initializing the animation files Image playerIdleSpriteSheet = new Image("Graphics/Animations/Charles/Idle_New", Vector2.Zero, 1, 1); playerIdle.Init(playerIdleSpriteSheet, Vector2.Zero, 64, 64, 1, 0.2, true); Image playerRunSpriteSheet = new Image("Graphics/Animations/Charles/WalkR_New", Vector2.Zero, 1, 1); playerRun.Init(playerRunSpriteSheet, Vector2.Zero, 64, 64, 4, 0.2, true); Image playerJumpSpriteSheet = new Image("Graphics/Animations/Charles/Jump_New", Vector2.Zero, 1, 1); playerJump.Init(playerJumpSpriteSheet, Vector2.Zero, 64, 64, 1, 0.2, true); hasJumped = false; playerMoveSpeed = 1.5f; jumpVelocity = -50f; canJump = false; }
PhysicsBody physicsBody; // This patients physicsBody. public override void Initialize() { base.Initialize(); // Initialize variables // Health starts at 100 health = 100f; // Create a list of images, this is how we will indicate how the patient is feeling. images = new List <Image>(); images.Add(new Image("Graphics/Patient-100", transform.position, 1, 1)); images.Add(new Image("Graphics/Patient-80", transform.position, 1, 1)); images.Add(new Image("Graphics/Patient-60", transform.position, 1, 1)); images.Add(new Image("Graphics/Patient-40", transform.position, 1, 1)); images.Add(new Image("Graphics/Patient-20", transform.position, 1, 1)); // Set the initial image to be the first element in the list. currentImage = images[0]; // Initialize EntityComponents. collider = AddComponent <CircleCollider>() as CircleCollider; transform.SetDimensions(new Vector2(40, 64)); collider.SetColliderDimensions(transform.dimensions.X, transform.dimensions.Y, 20); physicsBody = AddComponent <PhysicsBody>() as PhysicsBody; }