Exemplo n.º 1
0
        private void Renderer(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.Clear(Color.Black);

            foreach (Shape2D aShape in shapeHandler.GetShapes().ToList())
            {
                g.FillRectangle(new SolidBrush(aShape.Color), aShape.Pos.X, aShape.Pos.Y, aShape.Scale.X, aShape.Scale.Y);
            }

            g.DrawRectangle(Pens.Black, new Rectangle(32, 32, 64, 200));
            g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(32, 32, 64, player.Health));

            if (player.CheckDead())
            {
                foreach (Shape2D aShape in shapeHandler.GetShapes())
                {
                    if (aShape.Type == TypeSpec.Falling)
                    {
                        shapeHandler.removeShape(aShape);
                    }
                }
                levelHandler.Levels = 0;
                Sound.Stop();
                g.DrawString("DEAD! Press ENTER to restart.", new Font("Arial", 24, FontStyle.Bold), new SolidBrush(Color.White), 400, 50);
            }
            else
            {
                string level = levelHandler.Levels.ToString();
                g.DrawString("Level: " + level, new Font("Arial", 24, FontStyle.Bold), new SolidBrush(Color.White), 550, 50);
            }
        }
        private bool ChargeExists()
        {
            bool exists = false;

            foreach (Shape2D aShape in shapeHandler.GetShapes().ToList())
            {
                if (aShape.Type == TypeSpec.Charge)
                {
                    exists = true;
                }
            }

            return(exists);
        }