예제 #1
0
        public override void Draw(float delta)
        {
            var maxHeight = Height * 0.66f;

            History.Add(GetCpuUsage(Timing.TotalFramesRendered));
            if (History.Count > Width)
            {
                History.RemoveAt(0);
            }

            Art.Background(Paint.CornflowerBlue);
            Art.Fill(Paint.White);
            Art.Stroke(Paint.Black);
            Art.StrokeWeight(1);

            Art.BeginShape();

            for (var i = 0; i < History.Count; i++)
            {
                var p = (float)History[i];
                var x = ((float)i).Map(0, History.Count, 0, Width);
                var y = p.Map(0, 100, Height, maxHeight);
                Art.Vertex(x, y);
            }

            Art.Vertex(Width, Height);
            Art.Vertex(0, Height);

            Art.EndShape(EndShapeType.Close);

            Art.Line(0, maxHeight, Width, maxHeight);
        }
예제 #2
0
        public static void ChangeBackground(Map map)
        {
            ///Check if it works?
            int    rw            = 0;
            int    cl            = 0;
            int    elm           = 0;
            String MapToSwitchTo = Art.Background(map.GameSectionMap[map.CurrentSection].SectionName);
            String junk          = "";

            for (int i = 0; i < MapToSwitchTo.Length; i++)
            {
                if (MapToSwitchTo[elm] == '%')
                {
                    rw++;
                    cl = 0;
                }
                else
                {
                    if (rw >= Globals.GSH || cl >= Globals.GSW)
                    {
                        //only works for whole screen rendering
                        junk += MapToSwitchTo[elm];
                    }
                    else
                    {
                        Globals.CurrentBackground[rw, cl] = MapToSwitchTo[elm];
                    }
                    cl++;
                }
                elm++;
            }
        }
예제 #3
0
        private void Draw(float delta)
        {
            Art.Graphics.ScaleTransform(100, 100);
            Art.Background(PColor.CornflowerBlue);

            Art.Stroke(PColor.Black);
            Art.StrokeWeight(0.2f);
            Art.NoFill();

            var size = (float)Client.Arena.Size;

            Art.BeginShape();
            Art.Vertex(0, 0);
            Art.Vertex(size, 0);
            Art.Vertex(size, size);
            Art.Vertex(0, size);
            Art.EndShape(EndShapeType.Close);

            Art.NoStroke();
            Client.Arena.Obstacles.ForEach(o =>
            {
                Art.Fill(PColor.Grey);
                Art.Circle((float)o.Position.X, (float)o.Position.Y, 0.5f);
                Art.Fill(PColor.Black);
                Art.Text(o.ID, (float)o.Position.X, (float)o.Position.Y);
            });

            if (Client.Arena.ClientBot is object)
            {
                Art.Fill(PColor.White);
                Art.Circle((float)Client.Arena.ClientBot.Position.X, (float)Client.Arena.ClientBot.Position.Y, 0.5f);
                Art.Fill(PColor.Black);
                Art.Text("BOT\n" + Client.Arena.ClientBot.ID, (float)Client.Arena.ClientBot.Position.X, (float)Client.Arena.ClientBot.Position.Y);
            }
        }
예제 #4
0
        public void NextScreen()
        {
            //IMPROVE - null case?
            if (CurrentSection < this.GameSectionMap.Count - 1 && MainClass.Player_1.Position == 6 && this.CurrentEnemies.Count == 0)
            {
                //checks when in new section
                var oldBiome = this.GameSectionMap[CurrentSection].Type;
                this.CurrentSection++;
                if (this.GameSectionMap[CurrentSection].Type != oldBiome)
                {
                    Log.UpdateLog($"Entered {this.GameSectionMap[CurrentSection].Type}");
                    //heals player
                    MainClass.Player_1.Health = MainClass.Player_1.MaxHealth;
                }
                Render.ChangeBackground(this);
                //System.Diagnostics.Debug.WriteLine($"{this.this.CurrentSection}: {this.GameSectionMap[this.this.CurrentSection].SectionName}");
                Globals.Terrain = this.GameSectionMap[this.CurrentSection].Type;
                Render.ChangeScreen(0, 0, Art.Background($"{this.GameSectionMap[this.CurrentSection].SectionName}"));

                //initalize the new enemies
                for (int i = 0; i < this.GameSectionMap[this.CurrentSection].Enemies; i++)
                {
                    Enemy NewEnemy = new Enemy(this.GameSectionMap[this.CurrentSection].Enemies, this.GameSectionMap[this.CurrentSection].Type, this.GameSectionMap[this.CurrentSection].EnemyDifficulty);
                    //randomised enemy spawn if only 1
                    if (this.GameSectionMap[this.CurrentSection].Enemies == 1)
                    {
                        NewEnemy.Position = 6 - (new Random()).Next(1, 3);
                    }
                    else
                    {
                        if (this.CurrentEnemies.Count >= 1)
                        {
                            NewEnemy.Position = 5 - this.CurrentEnemies.Count;
                        }
                        else
                        {
                            NewEnemy.Position = 6 - (new Random()).Next(0, 2);
                        }
                    }
                    this.CurrentEnemies.Add(NewEnemy);
                    //make it so they appear on screen
                    this.CurrentEnemies[i].RenderEntity();
                }

                //render everything
                MainClass.Player_1.Position = 1;
                MainClass.Player_1.RenderEntity();
                Render.RenderScreen("all");
            }
            else
            {
                // System.Diagnostics.Debug.WriteLine($"at end {CurrentSection < this.GameSectionMap.Count - 1}|| player positon not at enterance {MainClass.Player_1.Position == 6 }|| enemies remaining {this.CurrentEnemies.Count}");
                if (CurrentSection == this.GameSectionMap.Count - 1 && this.CurrentEnemies.Count == 0)
                {
                    Globals.GameGoing    = false;
                    Globals.KingDefeated = true;
                }
            }
        }
예제 #5
0
 public void LoadCurrentScreen()
 {
     Render.RenderOutline(Globals.GSW, Globals.GSH);
     Render.ChangeBackground(this);
     Globals.Terrain = this.GameSectionMap[this.CurrentSection].Type;
     Render.ChangeScreen(0, 0, Art.Background($"{this.GameSectionMap[this.CurrentSection].SectionName}"));
     Render.RenderScreen("all");
 }
예제 #6
0
 public void Draw(float delta)
 {
     Title(FrameRateCurrent);
     Art.Background(off);
     Art.NoStroke();
     Art.Fill(on);
     for (var y = 0; y < h; y++)
     {
         for (var x = 0; x < w; x++)
         {
             if (cells[x, y])
             {
                 Art.Rect(x * cellWidth, y * cellHeight, cellWidth, cellHeight);
             }
         }
     }
 }
예제 #7
0
        public void PrevScreen()
        {
            //CHANGE ? can back out even if enemies not dead?
            if (this.CurrentSection > 0 && MainClass.Player_1.Position == 1 && this.CurrentEnemies.Count == 0)
            {
                this.CurrentSection--;
                Render.ChangeBackground(this);
                //System.Diagnostics.Debug.WriteLine($"{this.CurrentSection}: {this.GameSectionMap[this.CurrentSection].SectionName}");
                Globals.Terrain = this.GameSectionMap[this.CurrentSection].Type;
                Render.ChangeScreen(0, 0, Art.Background($"{this.GameSectionMap[this.CurrentSection].SectionName}"));

                //renders the past sceen
                //IMPROVE make the player walk on from off screen
                MainClass.Player_1.Position = 6;
                MainClass.Player_1.RenderEntity();
                Render.RenderScreen("all");
            }
            else
            {
                //System.Diagnostics.Debug.WriteLine($"@Beginning {this.CurrentSection} {this.CurrentSection > 0 }|| @enterance? {MainClass.Player_1.Position == 1 } {MainClass.Player_1.Position}|| enemies {this.CurrentEnemies.Count} {this.CurrentEnemies.Count == 0}");
            }
        }
예제 #8
0
        public override void Draw(float delta)
        {
            //Title($"FPS: {Timing.ActualFramesPerSecond}/{Timing.TargetFramesPerSecond}");
            Art.Background(Paint.Black);

            var mag = 0f;

            Particles.ForEach(p => mag += p.Velocity.SquareMagnitude);
            mag /= Particles.Count;
            mag *= 1;

            var frame  = new Sprite(Width, Height);
            var pixels = frame.Art.GetPixels();

            foreach (var p in Particles)
            {
                //p.Position = new Vector2()
                //{
                //    X = p.Position.X % Width,
                //    Y = p.Position.Y % Height,
                //};

                //p.Position = new Vector2()
                //{
                //    X = p.Position.X < 0 ? p.Position.X + Width - 1 : p.Position.X,
                //    Y = p.Position.Y < 0 ? p.Position.Y + Height - 1 : p.Position.Y,
                //};

                var pass = ((int)p.Position.X >= Width ||
                            (int)p.Position.Y >= Height ||
                            (int)p.Position.X < 0 ||
                            (int)p.Position.Y < 0);

                if (!pass)
                {
                    var pixelIndex = ((int)p.Position.X + ((int)p.Position.Y * Width)) * 4;

                    var color = (p.Velocity.SquareMagnitude / mag) * 255;
                    color = color > 255 ? 255 : color < 0 ? 0 : color;

                    pixels[pixelIndex]     = 255;
                    pixels[pixelIndex + 1] = 255;
                    pixels[pixelIndex + 2] = 255;
                    pixels[pixelIndex + 3] = 255;
                }

                p.Position += p.Velocity * delta;

                //if (MouseIsDown)
                //{
                var positions = new List <Vector2>()
                {
                    MousePosition,
                    //new Vector2(0, 0),
                };
                var forces = positions.ConvertAll(
                    p2 =>
                    Vector2.Right.Rotate(Vector2.Zero, p.Position.AngleToRadians(p2)) / (p.Position.DistanceFrom(p2).Square() / 1000)
                    );

                var average = Vector2.Zero;
                foreach (var f in forces)
                {
                    average += f;
                }
                average /= forces.Count;
                average *= 10;

                p.Velocity += (average * Timing.TargetFramesPerSecond) * delta;
                //}

                p.Velocity *= 0.99f;
            }
            frame.Art.SetPixels(pixels);

            PreviousFrames.Add(frame);
            if (PreviousFrames.Count > TailSize)
            {
                PreviousFrames.RemoveAt(0);
            }

            foreach (var f in PreviousFrames)
            {
                Art.DrawImage(f, 0, 0, Width, Height);
            }

            //var magSum = 0f;
            //Particles.ForEach(p => magSum += p.Velocity.Magnitude);
            //magSum /= Particles.Count;
            //Title(magSum);

            //Art.Fill(Paint.White);
            //Art.Stroke(Paint.Black);
            //Art.StrokeWeight(1f);
            //Art.TextFont("Airal", 36f);
            //Art.Text(MousePosition + " " + MouseIsDown, 300, 300);
        }
예제 #9
0
        public void Draw(float delta)
        {
            z += delta * 50;

            for (var y = 0; y < ArrHeight; y++)
            {
                for (var x = 0; x < ArrWidth; x++)
                {
                    //Map[x, y] = (float)r.NextDouble();
                    Map[x, y] = PMath.Clamp(noise.GetPerlin(x * PMath.PI, y * PMath.PI, z) + 0.5f, 0, 1);
                }
            }

            Title(Thresh);
            Art.Background(PColor.Grey);
            Art.NoStroke();

            for (var y = 0; y < ArrHeight; y++)
            {
                for (var x = 0; x < ArrWidth; x++)
                {
                    Art.Fill(new PColor((int)(Map[x, y] * 200)));
                    Art.Rect(x * Rez, y * Rez, Rez + 1, Rez + 1);
                    //Art.Circle(x * Rez, y * Rez, Rez * 0.55f);
                }
            }

            Art.NoFill();
            Art.Stroke(PColor.Black);
            Art.StrokeWeight(2);

            for (var y = 0f; y < ArrHeight - 1; y++)
            {
                for (var x = 0f; x < ArrWidth - 1; x++)
                {
                    var a = ((x * Rez) + (Rez / 2f), (y * Rez));
                    var b = ((x * Rez) + Rez, (y * Rez) + (Rez / 2f));
                    var c = ((x * Rez) + (Rez / 2f), (y * Rez) + Rez);
                    var d = ((x * Rez), (y * Rez) + (Rez / 2f));



                    var which = 0;
                    if (Map[(int)x, (int)y] > Thresh)
                    {
                        which += 8;
                    }
                    if (Map[(int)x + 1, (int)y] > Thresh)
                    {
                        which += 4;
                    }
                    if (Map[(int)x + 1, (int)y + 1] > Thresh)
                    {
                        which += 2;
                    }
                    if (Map[(int)x, (int)y + 1] > Thresh)
                    {
                        which += 1;
                    }

                    if (which == 4 || which == 10 || which == 11)
                    {
                        Line(a, b);
                    }
                    if (which == 6 || which == 9)
                    {
                        Line(a, c);
                    }
                    if (which == 5 || which == 7 || which == 8)
                    {
                        Line(a, d);
                    }
                    if (which == 2 || which == 5 || which == 13)
                    {
                        Line(b, c);
                    }
                    if (which == 3 || which == 12)
                    {
                        Line(b, d);
                    }
                    if (which == 1 || which == 10 || which == 14)
                    {
                        Line(c, d);
                    }

                    void Line((float, float) one, (float, float) two)
                    {
                        Art.Line(one.Item1, one.Item2, two.Item1, two.Item2);
                    }
                }
            }
        }