using System; using System.Collections.Generic; using System.Linq; using System.Text; using VBXSE; using Microsoft.Xna.Framework; namespace SnakeRPG { public class Particle { GObject gobject = null; public float speedX = 0; public float speedY = 0; public float duration = 1f; public bool expired = false; public void Update(float milliseconds) { float seconds = milliseconds / 1000f; gobject.SetPosition(gobject.position.X + speedX * seconds, gobject.position.Y + speedY * seconds); duration -= seconds; if (duration < 0) Delete(); } public void Delete() { SpriteEngine.EraseGObject(gobject); this.expired = true; } public static Particle SpawnDamageParticle(int number, Entity source, Color color) { Particle toReturn = new Particle(); GText gText = SpriteEngine.CreateGText(Convert.ToString(number), Convert.ToInt32(source.sprite.position.X), Convert.ToInt32(source.sprite.position.Y)); gText.color = color; gText.depth = -1000; gText.positionLocked = false; toReturn.gobject = gText; toReturn.speedY = -100f; return toReturn; } } }