Beispiel #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);
            }
        }
Beispiel #2
0
        public void Window_MouseClick(object sender, MouseEventArgs e)
        {
            Vector2d mousePos = new Vector2d(e.X, e.Y);

            if (e.Button == MouseButtons.Left)
            {
                Console.WriteLine("CLICKED!");
                if (shapeHandler.IsCollided(mousePos, TypeSpec.Falling) != null)
                {
                    Shape2D clickedObject = shapeHandler.IsCollided(mousePos, TypeSpec.Falling);
                    shapeHandler.removeShape(clickedObject);
                }
            }
        }