Exemple #1
0
        public void TestPlayerNotMoves()
        {
            var model = new HungerGameModel(Controller);

            Cursor.Position = new Point(ScreenCenter.X + 14, ScreenCenter.Y);
            Controller.UpdatePositionShift();
            Assert.AreEqual(new Point(0, 0), Controller.PositionShift);
        }
Exemple #2
0
        public void TestPlayerEatObject()
        {
            var model             = new HungerGameModel(Controller);
            var levelObjectsCount = model.Level.LevelObjects.Count();

            model.Level.LevelObjects.Add(new GameObjects.Apple_Stump(new Point(0, 0)));
            model.UpdateLevel();
            Assert.AreEqual(levelObjectsCount - 1, model.Level.LevelObjects.Count());
        }
Exemple #3
0
        public HungerGameForm()
        {
            Controller      = new MouseController();
            Model           = new HungerGameModel(Controller);
            DoubleBuffered  = true;
            FormBorderStyle = FormBorderStyle.None;
            WindowState     = FormWindowState.Maximized;
            KeyDown        += (sender, args) =>
            {
                if (args.KeyCode == Keys.Escape)
                {
                    Close();
                }
            };
            Paint += (sender, args) =>
            {
                args.Graphics.TranslateTransform(Model.Offset.X, Model.Offset.Y);
                args.Graphics.DrawImage(Model.Level.LevelBackground, Model.Level.LevelBorder);
                foreach (var objectToDraw in Model.Level.LevelObjects)
                {
                    DrawGameObject(objectToDraw, args);
                }
                DrawGameObject(Model.Player, args);
            };
            MouseMove += (sender, args) =>
            {
                Controller.UpdatePositionShift();
            };
            var timer = new Timer();

            timer.Interval = 30;
            timer.Tick    += (sender, args) =>
            {
                Model.UpdatePlayer();
                Model.UpdateLevel();
                Invalidate();
            };
            timer.Start();
        }
Exemple #4
0
 public void TestRectangleNotInRectangle()
 {
     Assert.False(HungerGameModel.IsRectangleInRectangle(new Rectangle(0, 0, 1, 1), new Rectangle(2, 2, 1, 1)));
 }
Exemple #5
0
 public void TestRectangleInRectangle()
 {
     Assert.True(HungerGameModel.IsRectangleInRectangle(new Rectangle(0, 0, 10, 10), new Rectangle(0, 0, 1, 1)));
 }