protected override void DrawNotes(long elapsedMilliseconds) { RectangleShape replayNote = new RectangleShape(new Vector2f(NoteSize, NoteMinHeight)); replayNote.FillColor = new Color(0, 255, 0, 100); RectangleShape beatmapNote = new RectangleShape(new Vector2f(NoteSize, NoteMinHeight)); beatmapNote.FillColor = new Color(255, 0, 0, 100); foreach (var item in ReplayFile) { float yPos = HitPosition + (-item.Timing + elapsedMilliseconds) * ScrollSpeed / 1000 + MainWindow.NoteOffset; float yPosEnd = HitPosition + (-item.Timing + elapsedMilliseconds + item.Length) * ScrollSpeed / 1000 + MainWindow.NoteOffset; float noteHeight = Math.Max(NoteMinHeight, Math.Abs(yPosEnd - yPos)); replayNote.Size = new Vector2f(NoteSize, noteHeight); if (yPos > -noteHeight && yPos < 900 + noteHeight) { replayNote.Position = new Vector2f(ReplayXStart + item.Key * (NoteSize + ColumnSpacing), yPos - noteHeight); Win.Draw(replayNote); } } foreach (var item in BeatmapFile) { float yPos = HitPosition + (-item.Timing + elapsedMilliseconds) * ScrollSpeed / 1000 + MainWindow.NoteOffset; float yPosEnd = HitPosition + (-item.Timing + elapsedMilliseconds + item.Length) * ScrollSpeed / 1000 + MainWindow.NoteOffset; float noteHeight = Math.Max(NoteMinHeight, Math.Abs(yPosEnd - yPos)); //item.length beatmapNote.Size = new Vector2f(NoteSize, noteHeight); if (yPos > -noteHeight && yPos < 900 + noteHeight) { beatmapNote.Position = new Vector2f(BeatmapXStart + item.Key * (NoteSize + ColumnSpacing), yPos - noteHeight); Win.Draw(beatmapNote); } } }
protected override void DrawNotes(long elapsedMilliseconds) { CircleShape replayNote = new CircleShape(NoteSize / 2); CircleShape beatmapNote = new CircleShape(NoteSize / 2); int actualNoteSize = NoteSize / 2; foreach (var item in ReplayFile) { float xPos = HitPosition + (item.Timing - elapsedMilliseconds) * ScrollSpeed / 1000 + MainWindow.NoteOffset; replayNote.FillColor = item.Key == 1 || item.Key == 2 ? Color.Red : Color.Blue; if (xPos < 2300 && xPos > HitPosition) { replayNote.Position = new SFML.System.Vector2f(xPos - NoteSize / 2, ReplayYStart - NoteSize / 2); Win.Draw(replayNote); } } foreach (var item in BeatmapFile) { actualNoteSize = item.Key >= 2 ? NoteSize : NoteSize / 2; float xPos = HitPosition + (item.Timing - elapsedMilliseconds) * ScrollSpeed / 1000 + MainWindow.NoteOffset; beatmapNote.FillColor = item.Key == 0 || item.Key == 2 ? Color.Red : Color.Blue; beatmapNote.Radius = actualNoteSize; if (xPos < 2300 && xPos > HitPosition) { beatmapNote.Position = new SFML.System.Vector2f(xPos - actualNoteSize, BeatmapYStart - actualNoteSize); Win.Draw(beatmapNote); } } }
protected override void DrawDefaultStuff() { CircleShape hitPositionCircles = new CircleShape(NoteSize / 2); hitPositionCircles.OutlineColor = Color.White; hitPositionCircles.FillColor = new Color(100, 100, 100); hitPositionCircles.Position = new SFML.System.Vector2f(HitPosition - NoteSize / 2, ReplayYStart - NoteSize / 2); Win.Draw(hitPositionCircles); hitPositionCircles.Position = new SFML.System.Vector2f(HitPosition - NoteSize / 2, BeatmapYStart - NoteSize / 2); Win.Draw(hitPositionCircles); }
protected override void DrawDefaultStuff() { RectangleShape hitPositionBar = new RectangleShape(new Vector2f(WIN_WIDTH, 5)); hitPositionBar.FillColor = Color.White; hitPositionBar.Position = new Vector2f(0, HitPosition); Win.Draw(hitPositionBar); int keyCount = BeatmapFile.Max(x => x.Key); RectangleShape columnLine = new RectangleShape(new Vector2f(2, WIN_HEIGHT)); columnLine.FillColor = new Color(200, 200, 200); for (int i = 1; i <= keyCount; i++) { float xPos = Math.Min(ReplayXStart, BeatmapXStart) + i * (ColumnSpacing + NoteSize); columnLine.Position = new Vector2f(xPos, 0); Win.Draw(columnLine); } }
public void Start() { DateTime currentTime = DateTime.Now; while (Win.IsOpen) { Win.DispatchEvents(); double elapsed = (DateTime.Now - currentTime).TotalSeconds; if (elapsed < 1.0 / FPS) { continue; } currentTime = DateTime.Now; Win.Clear(BackColor); if (!Stopped) { Snakes.RemoveAll(snake => snake.Dead); GameField.Update(Snakes); Snakes.ForEach(snake => snake.Update(GameField, Snakes)); foreach (DividingStudentSnake created in CreatedSnakes) { Snakes.Add(created); } CreatedSnakes.Clear(); } Win.Draw(GameField); Snakes.ForEach(snake => snake.Draw(Win, RenderStates.Default, GameField.CellWidthPixel, GameField.CellHeightPixel)); for (int i = 0; i < Snakes.Count; ++i) { DividingStudentSnake snake = Snakes[i]; BRAIN_SHAPE.Size = new Vector2f( snake.Brain.BrainWidth * GameField.CellWidthPixel, snake.Brain.BrainHeight * GameField.CellHeightPixel ); BRAIN_SHAPE.Position = new Vector2f( (snake.Head.Position.X - snake.Brain.BrainWidth / 2) * GameField.CellWidthPixel, (snake.Head.Position.Y - snake.Brain.BrainHeight / 2) * GameField.CellHeightPixel ); Win.Draw(BRAIN_SHAPE); Text score = new Text($"{i + 1}) size = {snake.Body.Count + 1}; energy = {snake.CurrentEnergy}; " + $"daughters = {snake.TotalCreated}; mutations = {snake.Brain.Mutations}", FONT) { FillColor = Color.Black, CharacterSize = 24 }; score.Position = new Vector2f(GameField.Width * GameField.CellWidthPixel + 60, i * 25 + 20); Win.Draw(score); RectangleShape colorIndicator = new RectangleShape(new Vector2f(20, 20)) { OutlineColor = Color.Black, FillColor = snake.BodyColor }; colorIndicator.Position = new Vector2f(GameField.Width * GameField.CellWidthPixel + 30, i * 25 + 25); Win.Draw(colorIndicator); } DrawExtra(); Win.Display(); } }