public static void Burst(GameObject world, PointF point, int amount = 2000, int minMagnitude = 50, int maxMagnitude = 300, float initialSize = 2, float deltaSize = 2, float deltaAlpha = -2) { for (int i = 0; i < amount; i++) { float angle = rnd.Next(0, 360); float magnitude = rnd.Next(minMagnitude, maxMagnitude); float o = (float)Math.Sin(angle) * magnitude; float a = (float)Math.Cos(angle) * magnitude; GameObject explosion = new Explosion(new PointF(a, o), initialSize, deltaSize, deltaAlpha); explosion.Center = point; world.AddChild(explosion); } world.Play(rnd.NextDouble() > 0.5 ? Properties.Resources.explosion1 : Properties.Resources.explosion2); }
public override void Update(float deltaTime) { if (!active) { return; } GameObject world = Parent; Center = world.Center; Left = world.Right; int now = Environment.TickCount; if (now - last > emmisionInterval) { last = now; EnemyShip ship = new EnemyShip(shipIndex, behavior); ship.Center = Center; world.AddChild(ship); } }
private void Form1_Load(object sender, EventArgs e) { Random rnd = new Random(); GameObject world = scene.World; { var noise = new[] { Properties.Resources.space_noise_1, Properties.Resources.space_noise_2, Properties.Resources.space_noise_3 }; world.AddChild(new SpaceNoise(noise[0], 3 * 1.5f, 1.00f, false, false)); world.AddChild(new SpaceNoise(noise[0], 3 * 2.5f, 2.00f, true, true)); world.AddChild(new SpaceNoise(noise[1], 3 * 3.5f, 1.50f, false, true)); world.AddChild(new SpaceNoise(noise[2], 3 * 5.5f, 2.00f, true, false)); } world.AddChild(new StarSpawner()); EnemySpawner[] spawners = new EnemySpawner[] { new EnemySpawner(0, 500, new FuncBehavior(x => Math.Sin(x * 10) * 0.9, 175)), new EnemySpawner(11, 500, new FollowPlayerBehavior(200)), new EnemySpawner(29, 500, new FuncBehavior(x => - 0.9 * (2 / Math.PI) * Math.Asin(Math.Sin(Math.PI * x * 3)), 250)), new EnemySpawner(20, 500, new FlockingBehavior(200)), new EnemySpawner(42, 500, new FuncBehavior(x => (Math.Sin(x * 10) + Math.Sin(x * 5)) * 0.5, 275)), new EnemySpawner(63, 500, new FuncBehavior(x => Math.Atan(x * 10 - 5) * -0.5, 200)), new EnemySpawner(54, 500, new FuncBehavior(x => (Math.Sin((x + 1) * 10 + 15) - Math.Sin((x + 1) * 15)) * 0.2 - 0.4, 300)), }; world.AddChildren(spawners); world.AddChild(new EnemySpawnerDirector(spawners)); PlayerShip player = new PlayerShip(33); player.CenterY = world.CenterY; player.Left = world.Left + 100; world.AddChild(player); }