public override bool Draw(Color Color) { Color cl = RetroApplication.Blend(Color.Black, Color, p); RetroApplication.Raster[x - 2, y] = cl; RetroApplication.Raster[x - 1, y] = cl; RetroApplication.Raster[x, y] = cl; RetroApplication.Raster[x + 1, y] = cl; RetroApplication.Raster[x + 2, y] = cl; RetroApplication.Raster[x + 3, y] = cl; RetroApplication.Raster[x, y - 1] = cl; RetroApplication.Raster[x + 1, y - 1] = cl; RetroApplication.Raster[x, y - 2] = cl; RetroApplication.Raster[x + 1, y - 2] = cl; RetroApplication.Raster[x, y + 1] = cl; RetroApplication.Raster[x + 1, y + 1] = cl; RetroApplication.Raster[x, y + 2] = cl; RetroApplication.Raster[x + 1, y + 2] = cl; RetroApplication.Raster[x + 2, y + 1] = cl; RetroApplication.Raster[x + 3, y + 1] = cl; RetroApplication.Raster[x - 1, y + 1] = cl; RetroApplication.Raster[x - 2, y + 1] = cl; RetroApplication.Raster[x, y + 3] = cl; RetroApplication.Raster[x + 1, y + 3] = cl; return(true); }
public override void AfterMove() { Color DestPixel = RetroApplication.Raster[this.x, this.y]; if (DestPixel.ToArgb() != Color.Black.ToArgb()) { if (DestPixel.R == 255 && DestPixel.B == 0) { RetroApplication.FillFlood(this.x, this.y, Color.Black); if (this.playerNr == 1) { BinaryOutput Output = new BinaryOutput(); int Gift = RetroApplication.Random(0, 31); Output.WriteByte(7); Output.WriteInt(Gift); this.GetGift(1, Gift, Output, null); if (Program.NrPlayers > 1) { Program.MPE.SendUdpToAll(Output.GetPacket(), 3); } } } else if (!this.immortal) { this.Die(); return; } } if (!this.invisible || this.playerNr == 2) { RetroApplication.Raster[this.x, this.y] = this.headColor; } if (this.immortal) { int SecondsLeft = 10 - (int)(DateTime.Now - this.immortalStart).TotalSeconds; if (SecondsLeft != this.immortalSecondsLeft) { if (SecondsLeft < 0) { this.immortal = false; Program.PlayerMsg(this.playerNr, string.Empty); } else { this.immortalSecondsLeft = SecondsLeft; Program.PlayerMsg(this.playerNr, "Immortal " + SecondsLeft.ToString()); } } } }
public override bool Draw(Color Color) { if (this.recalc) { this.CalcPoints(); } RetroApplication.DrawPolygon(this.Points, Color); return(true); }
public Present(int X1, int Y1, int X2, int Y2) : base(1, 1) { this.x1 = X1; this.y1 = Y1; this.x2 = X2; this.y2 = Y2; this.p = 0; RetroApplication.FillRectangle(this.x1, this.y1, this.x2, this.y2, color1); }
public override bool Draw(Color Color) { Color cl = RetroApplication.Blend(Color.Black, Color, p); int xd = (int)(this.X + 0.5); int yd = (int)(this.Y + 0.5); RetroApplication.Raster[xd, yd] = cl; RetroApplication.Raster[xd + 1, yd] = cl; RetroApplication.Raster[xd + 2, yd] = cl; RetroApplication.Raster[xd + 3, yd] = cl; RetroApplication.Raster[xd + 4, yd] = cl; RetroApplication.Raster[xd + 5, yd] = cl; RetroApplication.Raster[xd + 6, yd] = cl; RetroApplication.Raster[xd + 7, yd] = cl; RetroApplication.Raster[xd + 8, yd] = cl; RetroApplication.Raster[xd + 9, yd] = cl; RetroApplication.Raster[xd + 10, yd] = cl; RetroApplication.Raster[xd + 11, yd] = cl; RetroApplication.Raster[xd + 12, yd] = cl; RetroApplication.Raster[xd + 13, yd] = cl; RetroApplication.Raster[xd + 14, yd] = cl; RetroApplication.Raster[xd + 15, yd] = cl; RetroApplication.Raster[xd + 16, yd] = cl; RetroApplication.Raster[xd + 17, yd] = cl; RetroApplication.Raster[xd + 18, yd] = cl; RetroApplication.Raster[xd + 19, yd] = cl; RetroApplication.Raster[xd + 20, yd] = cl; RetroApplication.Raster[xd, yd - 1] = cl; RetroApplication.Raster[xd + 1, yd - 1] = cl; RetroApplication.Raster[xd + 2, yd - 1] = cl; RetroApplication.Raster[xd + 3, yd - 1] = cl; RetroApplication.Raster[xd + 4, yd - 1] = cl; RetroApplication.Raster[xd + 5, yd - 1] = cl; RetroApplication.Raster[xd + 6, yd - 1] = cl; RetroApplication.Raster[xd + 7, yd - 1] = cl; RetroApplication.Raster[xd + 8, yd - 1] = cl; RetroApplication.Raster[xd + 9, yd - 1] = cl; RetroApplication.Raster[xd + 10, yd - 1] = cl; RetroApplication.Raster[xd + 11, yd - 1] = cl; RetroApplication.Raster[xd + 12, yd - 1] = cl; RetroApplication.Raster[xd + 13, yd - 1] = cl; RetroApplication.Raster[xd + 14, yd - 1] = cl; RetroApplication.Raster[xd + 15, yd - 1] = cl; RetroApplication.Raster[xd + 16, yd - 1] = cl; RetroApplication.Raster[xd + 17, yd - 1] = cl; RetroApplication.Raster[xd + 18, yd - 1] = cl; RetroApplication.Raster[xd + 19, yd - 1] = cl; RetroApplication.Raster[xd + 20, yd - 1] = cl; RetroApplication.Raster[xd, yd + 1] = cl; return(true); }
public override bool MoveStep() { if (this.dead) { return(true); } double p2; this.p++; if (this.p >= 60) { this.p -= 60; } if (this.p >= 30) { p2 = 60 - this.p; } else { p2 = this.p; } p2 /= 30; Color cl = RetroApplication.Blend(color1, color2, p2); Color cl2; int x, y; bool Found = false; for (y = this.y1; y <= this.y2; y++) { for (x = this.x1; x <= this.x2; x++) { cl2 = RetroApplication.Raster[x, y]; if (cl2.A == 254) { Found = true; RetroApplication.Raster[x, y] = cl; } } } if (!Found) { this.Die(); } return(!Found); }
public override bool Draw(Color Color) { Color cl = RetroApplication.Blend(Color.Black, Color, p); int x = (int)(this.X + 0.5); int y = (int)(this.Y + 0.5); RetroApplication.Raster[x - 1, y] = cl; RetroApplication.Raster[x, y] = cl; RetroApplication.Raster[x + 1, y] = cl; RetroApplication.Raster[x, y - 1] = cl; RetroApplication.Raster[x, y + 1] = cl; return(this.Lifetime >= 0 && x >= -1 && x <= RetroApplication.RasterWidth + 1 && y >= -1 && y <= RetroApplication.RasterHeight + 1); }
public override bool Draw(Color Color) { this.R = Rnd.Next(0, 255); this.G = Rnd.Next(0, 255); this.B = Rnd.Next(0, 255); StarColor = Color.FromArgb(this.R, this.G, this.B); Color cl = RetroApplication.Blend(Color.Black, Color, 1); RetroApplication.Raster[this.x, this.y] = cl; RetroApplication.Raster[this.x + 1, this.y] = cl; RetroApplication.Raster[this.x, this.y - 1] = cl; RetroApplication.Raster[this.x + 1, this.y - 1] = cl; return(true); }
/// <summary> /// Loads a wav file from an embedded resource. /// </summary> /// <param name="ResourceName">Name of the resource, relative to the namespace of the caller.</param> /// <returns>Loaded Wav file.</returns> /// <exception cref="Exception">If the resource was not found.</exception> /// <exception cref="IOException">If the input is not a valid WAVE File</exception> public static WavAudio FromResource(string ResourceName) { StackFrame StackFrame = new StackFrame(1); Type Caller = StackFrame.GetMethod().ReflectedType; Assembly Assembly = Caller.Assembly; string Namespace = Caller.Namespace; ResourceName = Namespace + "." + ResourceName; Stream Stream = Assembly.GetManifestResourceStream(ResourceName); if (Stream is null) { throw RetroApplication.ResourceNotFoundException(ResourceName, Assembly); } Stream.Position = 0; return(FromStream(Stream)); }
public override bool MoveStep() { if (this.dead) { return(true); } if (this.currentRadius >= this.expectedRadius) { this.dead = true; RetroApplication.FillEllipse(this.xc, this.yc, this.currentRadius, this.currentRadius, Color.Black); } else { this.currentRadius++; RetroApplication.FillEllipse(this.xc, this.yc, this.currentRadius, this.currentRadius, RetroApplication.Blend(this.color, Color.Black, ((double)this.currentRadius) / this.expectedRadius)); } return(this.dead); }
public void Move() { bool Boing = false; this.x += this.vx; this.y += this.vy; if (this.x < this.minX) { this.x = this.minX + (this.minX - this.x); this.vx = -this.vx; Boing = true; } else if (this.x > this.maxX) { this.x = this.maxX - (this.x - this.maxX); this.vx = -this.vx; Boing = true; } if (this.y > this.maxY) { this.y = this.maxY - (this.y - this.maxY); this.vy = -this.vy; Boing = true; } this.vy += 5000; this.sprite.SetPosition(this.x >> 16, this.y >> 16); if (Boing) { Console.Out.Write("Boing.."); RetroApplication.PlayAudioSample(this.boingSound); } }
/// <summary> /// Moves the sprite along the z-axis to the top. /// </summary> public void MoveFront() { RetroApplication.MoveSpriteFront(this.node); }
/// <summary> /// Moves the sprite forwards in z-order one step. /// </summary> public void MoveForward() { RetroApplication.MoveSpriteForward(this.node); }
public void GetGift(int PlayerIndex, int GiftIndex, BinaryOutput Output, BinaryInput Input) { switch (GiftIndex) { case 0: this.framesPerPixel = 4; this.stepsPerFrame = 1; Program.PlayerMsg(this.playerNr, "Slow speed"); break; case 1: this.framesPerPixel = 5; this.stepsPerFrame = 1; Program.PlayerMsg(this.playerNr, "Slower speed"); break; case 2: this.framesPerPixel = 6; this.stepsPerFrame = 1; Program.PlayerMsg(this.playerNr, "Slowest speed"); break; case 3: this.framesPerPixel = 2; this.stepsPerFrame = 1; Program.PlayerMsg(this.playerNr, "Fast speed"); break; case 4: this.framesPerPixel = 1; this.stepsPerFrame = 1; Program.PlayerMsg(this.playerNr, "Faster speed"); break; case 5: this.framesPerPixel = 1; this.stepsPerFrame = 2; if (this.shotSpeed < 2) { this.shotSpeed = 2; } Program.PlayerMsg(this.playerNr, "Fastest speed"); break; case 6: this.framesPerPixel = 3; this.stepsPerFrame = 1; Program.PlayerMsg(this.playerNr, "Normal speed"); break; case 7: this.shotPower = 5; Program.PlayerMsg(this.playerNr, "Tiny bullets"); break; case 8: this.shotPower = 10; Program.PlayerMsg(this.playerNr, "Small bullets"); break; case 9: this.shotPower = 15; Program.PlayerMsg(this.playerNr, "Normal bullets"); break; case 10: this.shotPower = 20; Program.PlayerMsg(this.playerNr, "Large bullets"); break; case 11: this.shotPower = 25; Program.PlayerMsg(this.playerNr, "Huge bullets"); break; case 12: this.shotPower = 30; Program.PlayerMsg(this.playerNr, "Humongous bullets"); break; case 13: this.shotPower = 50; Program.PlayerMsg(this.playerNr, "Peace-maker bullets"); break; case 14: this.tail = false; Program.PlayerMsg(this.playerNr, "No tail"); break; case 15: this.tail = true; Program.PlayerMsg(this.playerNr, "Tail"); break; case 16: this.shotSpeed = Math.Max(1, this.stepsPerFrame); Program.PlayerMsg(this.playerNr, "Slow bullets"); break; case 17: this.shotSpeed = Math.Max(2, this.stepsPerFrame); Program.PlayerMsg(this.playerNr, "Fast bullets"); break; case 18: this.shotSpeed = Math.Max(3, this.stepsPerFrame); Program.PlayerMsg(this.playerNr, "Faster bullets"); break; case 19: this.shotSpeed = Math.Max(4, this.stepsPerFrame); Program.PlayerMsg(this.playerNr, "Fastest bullets"); break; case 20: int X, Y; int dx, dy; bool Ok; int TriesLeft = 100; int Black = Color.Black.ToArgb(); if (!(Input is null)) { this.x = 319 - (int)Input.ReadInt(); this.y = 207 - (int)Input.ReadInt(); } else { Ok = false; while (TriesLeft-- > 0 && !Ok) { X = RetroApplication.Random(30, 290); Y = RetroApplication.Random(38, 170); Ok = true; for (dy = -5; dy < 5; dy++) { for (dx = -5; dx < 5; dx++) { if (RetroApplication.Raster[X + dx, Y + dy].ToArgb() != Black) { Ok = false; dy = 5; break; } } } if (Ok) { Output.WriteInt(X); Output.WriteInt(Y); this.x = X; this.y = Y; } } if (!Ok && !(Output is null)) { Output.WriteInt(this.x); Output.WriteInt(this.y); } } Program.PlayerMsg(this.playerNr, "Teleport"); break;
/// <summary> /// Finds the best possible move for the opponent. /// </summary> /// <param name="Board">The game-board to be checked.</param> /// <returns>The board after the move.</returns> public static char[,] OpponentMove(char[,] Board) { int Best = -1000; int BestMoveRow = -1, BestMoveCol = -1; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (Board[i, j] == '-') { char[,] TestBoard = Board.Clone() as char[, ]; TestBoard[i, j] = 'O'; int MoveVal = MiniMax(TestBoard, 0, false); if (MoveVal > Best) { BestMoveRow = i; BestMoveCol = j; Best = MoveVal; } } } } Board[BestMoveRow, BestMoveCol] = 'O'; if (BestMoveRow == 2 && BestMoveCol == 0) { RetroApplication.DrawEllipse(220, 340, 40, 40, Color.White); RetroApplication.DrawEllipse(220, 340, 39, 39, Color.White); RetroApplication.DrawEllipse(220, 340, 38, 38, Color.White); } else if (BestMoveRow == 1 && BestMoveCol == 0) { RetroApplication.DrawEllipse(220, 240, 40, 40, Color.White); RetroApplication.DrawEllipse(220, 240, 39, 39, Color.White); RetroApplication.DrawEllipse(220, 240, 38, 38, Color.White); } else if (BestMoveRow == 0 && BestMoveCol == 0) { RetroApplication.DrawEllipse(220, 140, 40, 40, Color.White); RetroApplication.DrawEllipse(220, 140, 39, 39, Color.White); RetroApplication.DrawEllipse(220, 140, 38, 38, Color.White); } else if (BestMoveRow == 2 && BestMoveCol == 1) { RetroApplication.DrawEllipse(320, 340, 40, 40, Color.White); RetroApplication.DrawEllipse(320, 340, 39, 39, Color.White); RetroApplication.DrawEllipse(320, 340, 38, 38, Color.White); } else if (BestMoveRow == 1 && BestMoveCol == 1) { RetroApplication.DrawEllipse(320, 240, 40, 40, Color.White); RetroApplication.DrawEllipse(320, 240, 39, 39, Color.White); RetroApplication.DrawEllipse(320, 240, 38, 38, Color.White); } else if (BestMoveRow == 0 && BestMoveCol == 1) { RetroApplication.DrawEllipse(320, 140, 40, 40, Color.White); RetroApplication.DrawEllipse(320, 140, 39, 39, Color.White); RetroApplication.DrawEllipse(320, 140, 38, 38, Color.White); } else if (BestMoveRow == 2 && BestMoveCol == 2) { RetroApplication.DrawEllipse(420, 340, 40, 40, Color.White); RetroApplication.DrawEllipse(420, 340, 39, 39, Color.White); RetroApplication.DrawEllipse(420, 340, 38, 38, Color.White); } else if (BestMoveRow == 1 && BestMoveCol == 2) { RetroApplication.DrawEllipse(420, 240, 40, 40, Color.White); RetroApplication.DrawEllipse(420, 240, 39, 39, Color.White); RetroApplication.DrawEllipse(420, 240, 38, 38, Color.White); } else if (BestMoveRow == 0 && BestMoveCol == 2) { RetroApplication.DrawEllipse(420, 140, 40, 40, Color.White); RetroApplication.DrawEllipse(420, 140, 39, 39, Color.White); RetroApplication.DrawEllipse(420, 140, 38, 38, Color.White); } return(Board); }
/// <summary> /// Moves the sprite along the z-axis to the back. /// </summary> public void MoveBack() { RetroApplication.MoveSpriteBack(this.node); }
/// <summary> /// Disposes of the sprite. /// </summary> public void Dispose() { RetroApplication.SpriteDisposed(this.node); }