Example #1
0
        public Map(MainGame game, World world, ScreenManager screenManager)
        {
            _screenManager = screenManager;
            _floorSprite = new Sprite(screenManager.Content.Load<Texture2D>("bg/Environment_Floor_Tilable"));

            float oneSixth = screenManager.GraphicsDevice.Viewport.Width*0.175f;
            Size = new Vector2(ConvertUnits.ToSimUnits(screenManager.GraphicsDevice.Viewport.Width * 2.5f + oneSixth*2),
                            ConvertUnits.ToSimUnits(screenManager.GraphicsDevice.Viewport.Height));

            CreateTowers(screenManager, oneSixth);
            _gameBorder = new GameBorder(world, game, Size);
        }
Example #2
0
        /// <summary>
        ///     Allows the game to perform any initialization it needs to before starting to run.
        ///     This is where it can query for any required services and load any non-graphic
        ///     related content.  Calling base.Initialize will enumerate through any components
        ///     and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();

            var main1 = new MainGame();
            var menuScreen = new MenuScreen("Change of Heart");

            menuScreen.AddMenuItem("A Global Game Jam 2013 Game", EntryType.Separator, null);
            menuScreen.AddMenuItem(main1.GetTitle(), EntryType.Screen, main1);

            menuScreen.AddMenuItem("", EntryType.Separator, null);
            menuScreen.AddMenuItem("Exit", EntryType.ExitItem, null);

            ScreenManager.AddScreen(new BackgroundScreen());
            ScreenManager.AddScreen(menuScreen);
            //ScreenManager.AddScreen(new LogoScreen(TimeSpan.FromSeconds(3.0)));
        }
        public GameBorder(World world, MainGame screen, Vector2 viewport)
        {
            _world = world;
            _screen = screen;

            float halfWidth = viewport.X;
            float halfHeight = viewport.Y/2f - 0.8f;

            var borders = new Vertices(4)
                {
                    new Vector2(-halfWidth, halfHeight),
                    new Vector2(halfWidth, halfHeight),
                    new Vector2(halfWidth, -halfHeight),
                    new Vector2(-halfWidth, -halfHeight)
                };

            _anchor = BodyFactory.CreateLoopShape(_world, borders);
            _anchor.CollisionCategories = Category.All;
            _anchor.CollidesWith = Category.All;

            _basicEffect = new BasicEffect(GameScreen.ScreenManager.GraphicsDevice)
                {
                    VertexColorEnabled = true,
                    TextureEnabled = true,
                    Texture = GameScreen.ScreenManager.Content.Load<Texture2D>("Materials/pavement")
                };

            var vertice = new VertexPositionColorTexture[8];
            vertice[0] = new VertexPositionColorTexture(new Vector3(-halfWidth, -halfHeight, 0f),
                                                        Color.LightGray, new Vector2(-halfWidth, -halfHeight)/5.25f);
            vertice[1] = new VertexPositionColorTexture(new Vector3(halfWidth, -halfHeight, 0f),
                                                        Color.LightGray, new Vector2(halfWidth, -halfHeight)/5.25f);
            vertice[2] = new VertexPositionColorTexture(new Vector3(halfWidth, halfHeight, 0f),
                                                        Color.LightGray, new Vector2(halfWidth, halfHeight)/5.25f);
            vertice[3] = new VertexPositionColorTexture(new Vector3(-halfWidth, halfHeight, 0f),
                                                        Color.LightGray, new Vector2(-halfWidth, halfHeight)/5.25f);
            vertice[4] = new VertexPositionColorTexture(new Vector3(-halfWidth, -halfHeight, 0f),
                                                        Color.LightGray,
                                                        new Vector2(-halfWidth, -halfHeight)/5.25f);
            vertice[5] = new VertexPositionColorTexture(new Vector3(halfWidth , -halfHeight, 0f),
                                                        Color.LightGray,
                                                        new Vector2(halfWidth , -halfHeight)/5.25f);
            vertice[6] = new VertexPositionColorTexture(new Vector3(halfWidth , halfHeight , 0f),
                                                        Color.LightGray,
                                                        new Vector2(halfWidth, halfHeight)/5.25f);
            vertice[7] = new VertexPositionColorTexture(new Vector3(-halfWidth, halfHeight, 0f),
                                                        Color.LightGray,
                                                        new Vector2(-halfWidth, halfHeight)/5.25f);

            _borderVerts = new VertexPositionColorTexture[24];
            _borderVerts[0] = vertice[0];
            _borderVerts[1] = vertice[5];
            _borderVerts[2] = vertice[4];
            _borderVerts[3] = vertice[0];
            _borderVerts[4] = vertice[1];
            _borderVerts[5] = vertice[5];
            _borderVerts[6] = vertice[1];
            _borderVerts[7] = vertice[6];
            _borderVerts[8] = vertice[5];
            _borderVerts[9] = vertice[1];
            _borderVerts[10] = vertice[2];
            _borderVerts[11] = vertice[6];
            _borderVerts[12] = vertice[2];
            _borderVerts[13] = vertice[7];
            _borderVerts[14] = vertice[6];
            _borderVerts[15] = vertice[2];
            _borderVerts[16] = vertice[3];
            _borderVerts[17] = vertice[7];
            _borderVerts[18] = vertice[3];
            _borderVerts[19] = vertice[4];
            _borderVerts[20] = vertice[7];
            _borderVerts[21] = vertice[3];
            _borderVerts[22] = vertice[0];
            _borderVerts[23] = vertice[4];
        }