Beispiel #1
0
 //set focus
 public Game()
 {
     this.Paint += new PaintEventHandler(Screen_Paint);
     this.KeyDown += new KeyEventHandler(Screen_KeyDown);
     this.KeyUp += new KeyEventHandler(Screen_KeyUp);
     //Size = new System.Drawing.Size(900, 600);
     FormBorderStyle = FormBorderStyle.FixedSingle;
     //FormBorderStyle = FormBorderStyle.None;
     ClientSize = new System.Drawing.Size(900, 600); // make this non resizeable
     MaximizeBox = false;
     //DoubleBuffered = true;
     keysDown = new List<Keys>();
     keyHandler = new KeyHandler();
     paintHandler = new PaintHandler();
     SetStyle(ControlStyles.UserPaint, true);
     SetStyle(ControlStyles.AllPaintingInWmPaint, true);
     SetStyle(ControlStyles.DoubleBuffer, true);
     player = new Player();
     player.setGlobalLocation(100, 1000);
     zoneFactory = new ZoneFactory();
     stopwatch = new Stopwatch();
     stopwatch.Start();
     gameState = new GameState();
     menuFactory = new MenuFactory(gameState);
     gameLoop();
 }
Beispiel #2
0
 public void drawMenu(Graphics g, MenuFactory menuFactory)
 {
     if (menuFactory.getCurrentMenu().isAnimationFinished())
     {
         g.DrawImage(menuFactory.getCurrentMenu().getMenuImage(), MENU_DRAW_LOCATION);
     }
     else
     {
         g.DrawImage(menuFactory.getCurrentMenu().getAnimationImages()[menuFactory.getCurrentMenu().getAnimationIndex()], MENU_DRAW_LOCATION);
         menuFactory.getCurrentMenu().advanceAnimation();
     }
 }
Beispiel #3
0
        public void menuMove(MenuFactory menuFactory, GameState gs)
        {
            if (keysDown.Contains(Keys.W))
            {
                menuFactory.getCurrentMenu().moveUp();
            }
            else if (keysDown.Contains(Keys.A))
            {
                menuFactory.getCurrentMenu().moveLeft();
            }
            else if (keysDown.Contains(Keys.S))
            {
                menuFactory.getCurrentMenu().moveDown();

            }
            else if (keysDown.Contains(Keys.D))
            {
                menuFactory.getCurrentMenu().moveLeft();
            }
            else if (keysDown.Contains(Keys.Enter))
            {
                menuFactory.swapMenus();
            }
        }
Beispiel #4
0
 public void drawHighlightedMenu(Graphics g, MenuFactory menuFactory)
 {
     currentButton =  menuFactory.getCurrentMenu().getButtons()[menuFactory.getCurrentMenu().getPosition().Y, menuFactory.getCurrentMenu().getPosition().X];
     g.DrawImage(currentButton.getHighlightImage(), currentButton.getLocation());
 }