Example #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     //Initialize grapthics and gameworld
     dc = CreateGraphics();
     gameWorld = new GameWorld(dc, this.DisplayRectangle);
     gameWorld.SetupWorld();
 }
Example #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (isRunning)
            {
                //run gameloop every tick
                gameWorld.GameLoop();

                if (gameWorld.IsRunning == false)
                {
                    isRunning = false;
                    dc.Clear(Color.White);
                    gameWorld.Dispose();
                    gameWorld = new GameWorld(dc, DisplayRectangle);
                    gameWorld.SetupWorld();
                    menuDrawn = false;
                }
            }
            else if (!paused && !isRunning && !menuDrawn)
            {
                dc.Clear(Color.White);
                dc.DrawImage(Image.FromFile(@"Images\MainMenu.jpg"), 0, 0, DisplayRectangle.Width, DisplayRectangle.Height);
                dc.DrawString("███████╗██╗   ██╗██████╗ ███████╗██████╗     ██████╗ ██╗   ██╗██████╗ ███████╗██████╗     ███╗   ███╗ █████╗  ██████╗ ███████╗", new Font("Consolas", 10), Brushes.Black, 150, 50);
                dc.DrawString("██╔════╝██║   ██║██╔══██╗██╔════╝██╔══██╗    ██╔══██╗██║   ██║██╔══██╗██╔════╝██╔══██╗    ████╗ ████║██╔══██╗██╔════╝ ██╔════╝", new Font("Consolas", 10), Brushes.Black, 150, 60);
                dc.DrawString("███████╗██║   ██║██████╔╝█████╗  ██████╔╝    ██║  ██║██║   ██║██████╔╝█████╗  ██████╔╝    ██╔████╔██║███████║██║  ███╗█████╗  ", new Font("Consolas", 10), Brushes.Black, 150, 70);
                dc.DrawString("╚════██║██║   ██║██╔═══╝ ██╔══╝  ██╔══██╗    ██║  ██║██║   ██║██╔═══╝ ██╔══╝  ██╔══██╗    ██║╚██╔╝██║██╔══██║██║   ██║██╔══╝  ", new Font("Consolas", 10), Brushes.Black, 150, 80);
                dc.DrawString("███████║╚██████╔╝██║     ███████╗██║  ██║    ██████╔╝╚██████╔╝██║     ███████╗██║  ██║    ██║ ╚═╝ ██║██║  ██║╚██████╔╝███████╗", new Font("Consolas", 10), Brushes.Black, 150, 90);
                dc.DrawString("╚══════╝ ╚═════╝ ╚═╝     ╚══════╝╚═╝  ╚═╝    ╚═════╝  ╚═════╝ ╚═╝     ╚══════╝╚═╝  ╚═╝    ╚═╝     ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚══════╝", new Font("Consolas", 10), Brushes.Black, 150, 100);

                dc.DrawImage(playGame, DisplayRectangle.Width/2 - playGame.Width/2, DisplayRectangle.Height/2);
                dc.DrawImage(exitGame, DisplayRectangle.Width / 2 - exitGame.Width / 2, DisplayRectangle.Height / 2 + 200);

                menuDrawn = true;
            }
            else if (paused && !isRunning)
            {

            }
        }