using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Otter; namespace OtterApp { class Collectable : Entity { // Create a basic yellow circle. Image image = Image.CreateCircle(10, Color.Yellow); // Create a CircleCollider and tag it with the Collectable tag. CircleCollider collider = new CircleCollider(10, Tags.Collectable); public Collectable(float x, float y) : base(x, y) { // Add the image for rendering. AddGraphic(image); // Center the origin of the image. image.CenterOrigin(); // Add the collider so that it can check for collisions. AddCollider(collider); // Center the origin of the collider so it aligns with the image. collider.CenterOrigin(); } public override void Update() { base.Update(); // Use the collider to check for an overlap with anything tagged as a Player. if (collider.Overlap(X, Y, Tags.Player)) { // Remove itself from the scene when collected. RemoveSelf(); // Increase the player score, yahoo! } } public override void Render() { base.Render(); // Uncomment the following line to see the collider. //collider.Render(); } } }