public void CreateParticle(CustomSprite texture, Vector2 position, Color tint, float duration, Vector2 scale, T state, float theta = 0) { Particle particle; if (particleList.Count == particleList.Capacity) { // if the list is full, overwrite the oldest particle, and rotate the circular list particle = particleList[0]; particleList.Start++; } else { particle = particleList[particleList.Count]; particleList.Count++; } // Create the particle particle.Texture = texture; particle.Position = position; particle.Tint = tint; particle.Duration = duration; particle.PercentLife = 1f; particle.Scale = scale; particle.Orientation = theta; particle.State = state; }
static void DrawInternal(CustomSprite sprite, Vector4 destinationRectangle, Color color, float rotation, Vector2 origin, float depth) { Dictionary <Texture2D, Batch> batches; if (!layerBatches.TryGetValue(depth, out batches)) { batches = new Dictionary <Texture2D, Batch>(); layerBatches[depth] = batches; } Batch batch; var texture = sprite.Texture; if (!batches.TryGetValue(texture, out batch)) { batch = new Batch(); batch.Texture = texture; batches[texture] = batch; } if (totalVertex + 6 >= maxVertices) { throw new System.InvalidOperationException("Ran out of vertices"); } totalVertex += 6; if (batch.VertexCount + 6 >= batch.Vertices.Length) { Array.Resize(ref batch.Vertices, batch.Vertices.Length * 2); } if (rotation == 0f) { Set(batch.Vertices, ref batch.VertexCount, destinationRectangle.X - origin.X, destinationRectangle.Y - origin.Y, destinationRectangle.Z, destinationRectangle.W, color, sprite.TexCoordTL, sprite.TexCoordBR, depth); } else { Set(batch.Vertices, ref batch.VertexCount, destinationRectangle.X, destinationRectangle.Y, -origin.X, -origin.Y, destinationRectangle.Z, destinationRectangle.W, (float)Math.Sin(rotation), (float)Math.Cos(rotation), color, sprite.TexCoordTL, sprite.TexCoordBR, depth); } }
public Enemy(CustomSprite image, Vector2 position) { this.image = image; Position = position; Radius = image.Width / 2f; color = Color.Transparent; PointValue = 1; }
public static void Draw(CustomSprite texture, Vector2 position, Color color, float rotation, Vector2 origin, float scale, float layerDepth) { var w = texture.Width * scale; var h = texture.Height * scale; DrawInternal(texture, new Vector4(position.X, position.Y, w, h), color, rotation, origin * scale, layerDepth); }
public static void Draw(CustomSprite texture, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, float layerDepth) { var w = texture.Width * scale.X; var h = texture.Height * scale.Y; DrawInternal(texture, new Vector4(position.X, position.Y, w, h), color, rotation, origin * scale, layerDepth); }
} // a single white pixel public static void Load() { var cache = AtomicNET.GetSubsystem <ResourceCache>(); SpriteSheet2D sheet = cache.GetResource <SpriteSheet2D>("Sprites/AtomicBlasterSprites.xml"); Player = new CustomSprite(sheet.GetSprite("Player")); Seeker = new CustomSprite(sheet.GetSprite("Seeker")); Wanderer = new CustomSprite(sheet.GetSprite("Wanderer")); Bullet = new CustomSprite(sheet.GetSprite("Bullet")); Pointer = new CustomSprite(sheet.GetSprite("Pointer")); BlackHole = new CustomSprite(sheet.GetSprite("BlackHole")); LineParticle = new CustomSprite(sheet.GetSprite("Laser")); Glow = new CustomSprite(sheet.GetSprite("Glow")); Pixel = new CustomSprite(sheet.GetSprite("Pixel")); }
public void CreateParticle(CustomSprite texture, Vector2 position, Color tint, float duration, float scale, T state, float theta = 0) { CreateParticle(texture, position, tint, duration, new Vector2(scale, scale), state, theta); }
public static void Load() { var cache = AtomicNET.Cache; SpriteSheet2D sheet = cache.GetResource<SpriteSheet2D>("Sprites/AtomicBlasterSprites.xml"); Player = new CustomSprite(sheet.GetSprite("Player")); Seeker = new CustomSprite(sheet.GetSprite("Seeker")); Wanderer = new CustomSprite(sheet.GetSprite("Wanderer")); Bullet = new CustomSprite(sheet.GetSprite("Bullet")); Pointer = new CustomSprite(sheet.GetSprite("Pointer")); BlackHole = new CustomSprite(sheet.GetSprite("BlackHole")); LineParticle = new CustomSprite(sheet.GetSprite("Laser")); Glow = new CustomSprite(sheet.GetSprite("Glow")); Pixel = new CustomSprite(sheet.GetSprite("Pixel")); }
static void DrawInternal(CustomSprite sprite, Vector4 destinationRectangle, Color color, float rotation, Vector2 origin, float depth) { Dictionary<Texture2D, Batch> batches; if (!layerBatches.TryGetValue(depth, out batches)) { batches = new Dictionary<Texture2D, Batch>(); layerBatches[depth] = batches; } Batch batch; var texture = sprite.Texture; if (!batches.TryGetValue(texture, out batch)) { batch = new Batch(); batch.Texture = texture; batches[texture] = batch; } if (totalVertex + 6 >= maxVertices) { throw new System.InvalidOperationException("Ran out of vertices"); } totalVertex += 6; if (batch.VertexCount + 6 >= batch.Vertices.Length) { Array.Resize(ref batch.Vertices, batch.Vertices.Length * 2); } if (rotation == 0f) { Set(batch.Vertices, ref batch.VertexCount, destinationRectangle.X - origin.X, destinationRectangle.Y - origin.Y, destinationRectangle.Z, destinationRectangle.W, color, sprite.TexCoordTL, sprite.TexCoordBR, depth); } else { Set(batch.Vertices, ref batch.VertexCount, destinationRectangle.X, destinationRectangle.Y, -origin.X, -origin.Y, destinationRectangle.Z, destinationRectangle.W, (float)Math.Sin(rotation), (float)Math.Cos(rotation), color, sprite.TexCoordTL, sprite.TexCoordBR, depth); } }