/// <summary> /// Jumps the player. /// </summary> private void DoJump(Room room) { velocity.Y = -JUMP_SPEED; if (curAnimation.IsCalled(SLIDE)) velocity.X = ((facing == RIGHT && velocity.X > 0) ? -WALL_JUMP_PUSH : WALL_JUMP_PUSH); maxSpeed = new Vector2(MAX_JUMP_SPEED_X, MAX_JUMP_SPEED_Y); ChangeAnimation(JUMP); canJump = false; if (!(Color == Color.Black)) room.Splat(Center, Vector2.One * JUMP_SPLATTER_SIZE*2.5f, color, velocity); }
public void Die(Room room) { room.Splat(Center, size * 8, color, Vector2.One); dying = true; ChangeAnimation(DIE); }
internal override void Move(Room room, Vector2 direction) { if (direction.X == 0 && curAnimation.IsCalled(WALK)) ChangeAnimation(IDLE); if (direction.X < 0) { if (curAnimation.IsCalled(SLIDE)) { velocity.X = -2; ChangeAnimation(JUMP); Position = new Vector2(Position.X - size.X / 8, Position.Y); } facing = LEFT; } else if (direction.X > 0) { if (curAnimation.IsCalled(SLIDE)) { velocity.X = 2; ChangeAnimation(JUMP); Position = new Vector2(Position.X + size.X / 8, Position.Y); } facing = RIGHT; } if (TookStep && !(Color == Color.Black)) room.Splat(facing == RIGHT ? new Vector2(box.Left, box.Bottom) : new Vector2(box.Right, box.Bottom), STEP_SPLATTER_SIZE * Vector2.One, color, room.Gravity * Vector2.One * 0.0001f); base.Move(room, direction); }
public override void CollideWithWall(Room room) { base.CollideWithWall(room); if (Math.Abs(velocity.Y) > 0 && !onGround && !hasCollidedWithCeiling) { ChangeAnimation(SLIDE); } if (velocity.Y > 0 && !onGround) { velocity = velocity.PushBack(new Vector2(0, velocity.Y/WALL_SLIDE_FACTOR)); canJump = true; float splatX = velocity.X > 0 ? Position.X + size.X : Position.X; float splatY = Position.Y + size.Y / 4; if (!hasCollidedWithCeiling && !(Color == Color.Black)) room.Splat(facing == LEFT ? new Vector2(splatX + 10, splatY) : new Vector2(splatX - 23, splatY), Vector2.One * 80f, color, velocity); } // splat if the impact is too big to ignore. if (velocity.LengthSquared() > Math.Pow(SPLATTER_IGNORE, 2)) { Vector2 splatPosition = Position.ShoveToSide(size, velocity); if (facing == LEFT) splatPosition.Y += 30f; if (canSplat) { if (!hasCollidedWithCeiling && !(Color == Color.Black)) room.Splat(splatPosition, size * STEP_SPLATTER_SIZE, color, new Vector2(Math.Abs(velocity.X) > NEGLIGIBLE_SPLATTER_VELOCITY ? velocity.X : 0, Math.Abs(velocity.Y) > NEGLIGIBLE_SPLATTER_VELOCITY ? velocity.Y : 0)); canSplat = false; splatTimer.Start(); } } }