Exemplo n.º 1
0
        public G1(Game parent) : base(parent, 1024 * 2, 768 * 2, Color.White)
        {
            SpatialMode = SpatialMode.SafeArea;

            OnUpdate += UpdateAction;
            OnDraw   += DrawAction;
            OnUnLoad += OnUnload;

            Keyboard.KeyPressed += (sender, args) =>
            {
                if (args.Key == Key.Space)
                {
                    ParentGame.Window.VSync = !ParentGame.Window.VSync;
                }

                if (args.Key == Key.X)
                {
                    Player.Position = new Vector2(80, 80);
                }

                if (args.Key == Key.Escape)
                {
                    ParentGame.Exit();
                }
            };

            var wall = new Sprite(ContentLoader.Texture2DFromFile("Test_Wall.png"), new Vector2(0, 0));

            fnt = ContentLoader.FontFromFile("Segoe UI_24.fnt");

            for (var i = 0; i < 50; i++)
            {
                AddInstance(new Wall(this, new Vector2(i * 16, 12), wall));
                AddInstance(new Wall(this, new Vector2(i * 16, 52), wall));
            }

            AddInstance(new MovingWall(this, new Vector2(200, 100), wall));

            Player = new Player(this, new Vector2(80, 80));
            AddInstance(Player);

            var btn = new Button(new Vector2(20, 100), "Hello", fnt, Color.Red);

            btn.ControlClicked += delegate { Console.WriteLine("CLICKED"); };

            Zoom = new Label(new Vector2(10, 10), "Zoom: 0", fnt, Color.Red);

            Rotation = new Label(new Vector2(10, 10 + fnt.LineHeight), "Rotation: 0 deg", fnt, Color.Red);

            INSIDE = new Label(new Vector2(10, 150), "Player is in: ", fnt, Color.Red);

            UserInterface.AddControl(btn);
            UserInterface.AddControl(Zoom);
            UserInterface.AddControl(Rotation);
            UserInterface.AddControl(INSIDE);
            var cursor = new Sprite(ContentLoader.Texture2DFromFile("Cursor.png"), new Vector2(0, 0))
            {
                Width  = 64,
                Height = 64
            };

            cur = new Cursor(cursor);
            UserInterface.AddControl(cur);

            TestTexture = cursor.Texture;

            Camera.Zoom = 0.7f;

            SafeZoneEnabled = true;
            SafeZone        = new Rectangle(0, 0, 256, 256);

            //DrawMode = DrawMode.DrawCheck;

            //Disable the animation collision exception
            Settings.AttemptToPerPixelCheckAnimation = false;



            /*if (!Directory.Exists(Directory.GetCurrentDirectory() + "\\Fonts"))
             *  Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\Fonts");
             *
             * var standardSizes = new[] { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36 };
             *
             * foreach (var size in standardSizes)
             * {
             *  foreach (var fontFamily in System.Drawing.FontFamily.Families)
             *  {
             *      if (fontFamily.Name == "") continue;
             *      Console.WriteLine(fontFamily.Name + " : " + size);
             *      using (var stream =
             *          new FileStream(
             *              Directory.GetCurrentDirectory() + "\\Fonts\\" + fontFamily.Name + "_" + size + ".fnt",
             *              FileMode.Create))
             *      {
             *          var font = FontBuilder.CreateFontFromName(fontFamily.Name, size);
             *          font.WriteOut(stream);
             *      }
             *  }
             * }
             *
             * MessageBox.Show("Build fonts", "Complete");*/



            var testSound = ContentLoader.LoadWaveFromFile("TestWave.wav");

            testSound.Volume  = 0.25f;
            testSound.Pitch   = 2;
            testSound.Looping = true;
            testSound.Play();
        }