public void Update() { lifeTime--; Position += Velocity; rotation += (float)Math.PI / 15; Position = LinkGame.LoopAroundCheck(Position); if (LinkGame.random.Next(2) == 0) { new Particle(Position, LinkGame.PolarVector(1, (float)LinkGame.random.NextDouble() * (float)Math.PI * 2), 2f); } for (int i = 0; i < LinkGame.gameRings.Count; i++) { if ((LinkGame.gameRings[i].Position - this.Position).Length() < LinkGame.gameRings[i].radius) { for (int p = 0; p < LinkGame.gameRings[i].radius; p++) { new Particle(LinkGame.gameRings[i].Position, LinkGame.PolarVector((float)LinkGame.random.NextDouble() * 4 + 1, (float)LinkGame.random.NextDouble() * 2 * (float)Math.PI), 2f + (float)LinkGame.random.NextDouble() * 3); } LinkGame.gameRings[i].linkedTo = null; LinkGame.gameRings[i] = null; LinkGame.gameRings.RemoveAt(i); LinkGame.gameProjectiles.Remove(this); LinkGame.sounds[2].Play(.5f, 1f, 1f); } } if (lifeTime <= 0) { LinkGame.gameProjectiles.Remove(this); for (int p = 0; p < 5; p++) { new Particle(Position, LinkGame.PolarVector(3, (float)LinkGame.random.NextDouble() * (float)Math.PI * 2), 2f); } } }
public void Update() { this.energy++; if (this.energy > this.maxEnergy) { this.energy = this.maxEnergy; } this.time++; if (this.LinkedToPlayer != -1) { this.Position = LinkGame.gamePlayers[this.LinkedToPlayer].Position; LinkGame.gamePlayers[this.LinkedToPlayer].energy += this.energy; this.energy = 0; } if (this.linkedTo != null && !LinkGame.gameRings.Contains(this.linkedTo)) { this.linkedTo = null; } foreach (Ring otherRing in LinkGame.gameRings) { if (this.LinkedToPlayer == -1 && this != otherRing) { while ((this.Position - LinkGame.screenLoopAdjust(Position, otherRing.Position)).Length() < this.radius + otherRing.radius) { float direction = LinkGame.ToRotation(this.Position - LinkGame.screenLoopAdjust(Position, otherRing.Position)); this.Position += LinkGame.PolarVector(1, direction); if (otherRing.LinkedToPlayer == -1) { otherRing.Position -= LinkGame.PolarVector(1, direction); } } if (this.linkedTo == null && (this.Position - LinkGame.screenLoopAdjust(this.Position, otherRing.Position)).Length() < 100 + this.radius + otherRing.radius && otherRing.linkedTo != this) { this.linkedTo = otherRing; LinkGame.playeLinkSound = true; } } } if (this.linkedTo != null) { this.linkedTo.energy += this.energy; this.energy = 0; if ((this.Position - LinkGame.screenLoopAdjust(this.Position, this.linkedTo.Position)).Length() > 100 + this.radius + this.linkedTo.radius) { float direction = LinkGame.ToRotation(LinkGame.screenLoopAdjust(this.Position, this.linkedTo.Position) - this.Position); this.Position += LinkGame.PolarVector(3, direction); } } this.Position = LinkGame.LoopAroundCheck(this.Position); }
static void Main() { using (var game = new LinkGame()) game.Run(); }
protected override void LoadContent() // runs once when the game starts { instance = this; font = TtfFontBaker.Bake(File.ReadAllBytes(@"C:\\Windows\\Fonts\arial.ttf"), 25, 1024, 1024, new[] { CharacterRange.BasicLatin, CharacterRange.Latin1Supplement, CharacterRange.LatinExtendedA, CharacterRange.Cyrillic }).CreateSpriteFont(GraphicsDevice); //Idk how this works but it make fonts a lot easier spriteBatch = new SpriteBatch(GraphicsDevice); //Music and Sound effects by Eric Matyas //www.soundimage.org song = Content.Load <Song>("Retro-Frantic_V001_Looping"); MediaPlayer.Volume = .3f; MediaPlayer.IsRepeating = true; MediaPlayer.Play(song); sounds[0] = Content.Load <SoundEffect>("UI_Quirky26"); //linking sound sounds[1] = Content.Load <SoundEffect>("Laser-Ricochet2"); //shooting sounds[2] = Content.Load <SoundEffect>("Explosion1"); // ring eliminated //define all our textures playerArrow = drawTriangle(12, 1.4f); shot = drawSquare(10); for (int c = 1; c < CircleSizes.Length; c++) { CircleSizes[c] = drawRing(c); } linkTriangle = drawTriangle(12, 1f); pixel = new Texture2D(instance.GraphicsDevice, 1, 1); Color[] dataColors = { Color.White }; pixel.SetData(0, null, dataColors, 0, 1); int Xsize = 20; X = new Texture2D(instance.GraphicsDevice, Xsize, Xsize); dataColors = new Color[Xsize * Xsize]; for (int x = 0; x < Xsize; x++) { for (int y = 0; y < Xsize; y++) { if (x == y || x == Xsize - y) { dataColors[x + y * Xsize] = Color.White; } } } X.SetData(0, null, dataColors, 0, Xsize * Xsize); // L i n k int width = 880; Vector2 startTextAt = new Vector2(screenSize.X / 2 - width / 2, 200); new Ring(startTextAt); new Ring(startTextAt + new Vector2(0, 100)); new Ring(startTextAt + new Vector2(0, 200)); new Ring(startTextAt + new Vector2(120, 200)); new Ring(startTextAt + new Vector2(280, 200)); new Ring(startTextAt + new Vector2(280, 100)); new Ring(startTextAt + new Vector2(280, 0)); new Ring(startTextAt + new Vector2(440, 100)); new Ring(startTextAt + new Vector2(440, 200)); new Ring(startTextAt + new Vector2(440, 0)); new Ring(startTextAt + new Vector2(520, 0)); new Ring(startTextAt + new Vector2(600, 100)); new Ring(startTextAt + new Vector2(600, 200)); Ring r = new Ring(startTextAt + new Vector2(880, 200)); Ring r2 = new Ring(startTextAt + new Vector2(880, 0)); Ring r3 = new Ring(startTextAt + new Vector2(760, 0)); Ring r4 = new Ring(startTextAt + new Vector2(760, 200)); r.linkedTo = r2.linkedTo = r3.linkedTo = r4.linkedTo = new Ring(startTextAt + new Vector2(760, 100)); }