public Enemy(CollidableObject collidableObject, AnimationSet animationSet, float walkSpeed) { CollidableObject = collidableObject; AnimationSet = animationSet; //animations[0].SetToFrame(ref CollidableObject.SourceRectangle, 0); _walkSpeed = walkSpeed; }
public Player(Texture2D texture, Vector2 spawnPosition, List <Animation> animations) { _animationSet = new AnimationSet(animations, AnimationStates.Idle, AnimationDirections.Right); Rectangle initialSourceRectangle = Rectangle.Empty; // Set initialSourceRectangle to the first frame in the first animation animations[0].SetToFrame(ref initialSourceRectangle, 0); CollidableObject = new CollidableObject(texture, spawnPosition, initialSourceRectangle, 0f) { Origin = Vector2.Zero }; _oldPosition = CollidableObject.Position; }
/// <summary> /// Detects a pixel level collision between this and an other CollidableObject. /// </summary> /// <param name="collidable">The CollidableObject to check a collision against</param> /// <returns>True if colliding, false if not.</returns> public bool IsColliding(CollidableObject collidable) { // If rectangle of objects intersects if (BoundingRectangle.Intersects(collidable.BoundingRectangle)) { // And any of the pixels of objects intersect if (IntersectPixels(Transform, SourceRectangle, TextureData, collidable.Transform, collidable.SourceRectangle, collidable.TextureData)) { // Then return true return(true); } } // Else return false return(false); }
public TerrainElement(CollidableObject collidableObject) { CollidableObject = collidableObject; CollidableObject.Origin = Vector2.Zero; }