Ejemplo n.º 1
0
        protected override void Initialize()
        {
            var screenData        = configData.ToResultType <ScreenData>("ScreenOptions");
            var player1Dictionary = configData.ToResultType <Dictionary <string, string> >("Player1Controls");
            var player1Keys       = GeneralExtensions.ConvertToKeySet <PlayerControls>(player1Dictionary);

            // Configure the screen.
            graphics.PreferredBackBufferWidth  = screenData.ScreenWidth;
            graphics.PreferredBackBufferHeight = screenData.ScreenHeight;
            graphics.IsFullScreen = screenData.FullScreen;
            graphics.ApplyChanges();
            // Assign the drawerer
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Can rotate
            this.fourway = new FourWayDirection(FourDirections.Stopped, 0.5f);
            // Allows you to rotate.
            this._keyboard4Way = new Keyboard4Way(this.fourway, player1Keys);

            var slowCloud = this.GraphicsDevice.TextureFromFileName("Content/backBackground.png");  // spriteBatch.CreateFilleRectTexture( new Rectangle(0,0, gameWidth + 50, gameHEight + 50), Color.LightCyan);
            var fastCloud = this.GraphicsDevice.TextureFromFileName("Content/frontBackground.png"); //spriteBatch.CreateFilleRectTexture(new Rectangle(0, 0, gameWidth + 50, gameHEight + 50), Color.Orange);
            var sprite    = this.GraphicsDevice.TextureFromFileName("Content/FatBlock.png");
            // all rects on a particular atlas.
            // It's also the entire map for the backfround.
            var atlasRects = FramesGenerator.GenerateFrames(new FrameInfo[] { new FrameInfo(32, 32) }, new Dimensions(96, 64));
            var map        = GeneralExtensions.LoadCsvMapData("Maps/BorderMap.csv");
            var topLeft    = new Vector2(-123, -127);

            backgroundMap = new BoundedBackground(spriteBatch, sprite, atlasRects, map, new Dimensions(32, 32), new Rectangle(0, 0, 1024, 1152), fourway, topLeft, GraphicsDevice.Viewport);

            base.Initialize();
        }
Ejemplo n.º 2
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            arial = this.Content.Load <SpriteFont>("Arial");

            this.rTater = new Rotator(348, 202);
            baseJeep    = Texture2d.FromFileName(this.GraphicsDevice, "Content/Jeep.png");
            var jeepFrames = FramesGenerator.GenerateFrames(new FrameInfo(243, 243), new Dimensions(baseJeep.Width, baseJeep.Height));

            player = new PlayerContainer(this.spriteBatch, this.baseJeep, new Character(jeepFrames), this.rTater, player1Keys, new Point(100, 125));
        }
Ejemplo n.º 3
0
        protected override void Initialize()
        {
            var screenData        = configData.ToResultType <ScreenData>("ScreenOptions");
            var player1Dictionary = configData.ToResultType <Dictionary <string, string> >("Player1Controls");
            var player1Keys       = GeneralExtensions.ConvertToKeySet <PlayerControls>(player1Dictionary);

            // Configure the screen.
            graphics.PreferredBackBufferWidth  = screenData.ScreenWidth;
            graphics.PreferredBackBufferHeight = screenData.ScreenHeight;
            graphics.IsFullScreen = screenData.FullScreen;
            graphics.ApplyChanges();
            // Assign the drawerer
            spriteBatch = new SpriteBatch(GraphicsDevice);

            var centreHoriz = this.GraphicsDevice.Viewport.Width / 2;
            var centreVert  = this.GraphicsDevice.Viewport.Height / 2;

            // create the integral to convert to float/
            _centrePoint = new Point(centreHoriz, centreVert).ToVector2();

            // Can rotate
            this.rotator = new Rotator(0, 202);
            // Allows you to rotate.
            this._keyboardRotator = new KeyboardRotation(this.rotator, player1Keys);

            var slowCloud = this.GraphicsDevice.TextureFromFileName("Content/backBackground.png");  // spriteBatch.CreateFilleRectTexture( new Rectangle(0,0, gameWidth + 50, gameHEight + 50), Color.LightCyan);
            var fastCloud = this.GraphicsDevice.TextureFromFileName("Content/frontBackground.png"); //spriteBatch.CreateFilleRectTexture(new Rectangle(0, 0, gameWidth + 50, gameHEight + 50), Color.Orange);

            // all rects on a particular atlas.
            // It's also the entire map for the backfround.
            var atlasRects = FramesGenerator.GenerateFrames(new FrameInfo[] { new FrameInfo(25, 25) }, new Dimensions(500, 500));
            var map        = Enumerable.Range(0, atlasRects.Length).Select(i => i).ToList();

            this._backgroundTiles   = new BackgroundTilesLayer(spriteBatch, new Texture2D[] { fastCloud, fastCloud }, atlasRects, map, rotator, 0.20f, new Vector2(0, 0));
            this._foregroundLayter  = new BackgroundRectanglesLayer(spriteBatch, new Texture2D[] { fastCloud, fastCloud }, rotator, 0.35f, new Vector2(876, 486));
            this._foregroundLayter2 = new BackgroundRectanglesLayer(spriteBatch, new Texture2D[] { slowCloud, slowCloud }, rotator, 0.20f, new Vector2(876, 486));

            base.Initialize();
        }