Exemple #1
0
        protected override void Initialize()
        {
            this.IsMouseVisible = true;
            Window.AllowUserResizing = true;
            camera = new Camera(GraphicsDevice.Viewport);

            windowBlock = new GameObject();
            windowBlock.initializeMovement(new Vector3(0,0,0),
                new Vector3(0, 0, 0));
            topBlock = new GameObject();
            topBlock.initializeMovement(new Vector3(0, 0, 0),
                new Vector3(0, 0, 0));
            rightBlock = new GameObject();
            rightBlock.initializeMovement(new Vector3(0, 0, 0),
                new Vector3(0, 0, 0));
            leftBlock = new GameObject();
            leftBlock.initializeMovement(new Vector3(0, 0, 0),
                new Vector3(0, 0, 0));
            rightCornerBlock = new GameObject();
            rightCornerBlock.initializeMovement(new Vector3(0, 0, 0),
                new Vector3(0, 0, 0));
            leftCornerBlock = new GameObject();
            leftCornerBlock.initializeMovement(new Vector3(0, 0, 0),
                new Vector3(0, 0, 0));
            porchBlock = new GameObject();
            porchBlock.initializeMovement(new Vector3(0, 0, 0),
                new Vector3(0, 0, 0));
            backgroundBlocks = new GameObject();
            backgroundBlocks.initializeMovement(new Vector3(0, 100, -4000), new Vector3(0, 0, 0));

            player = new GameObject();
            player.initializeMovement(new Vector3(0, 0, 0),
                new Vector3(0, 0, 0));

            map1 = new Map(Content, Path.Combine(Content.RootDirectory, "level1.txt"),
               new Point(100, 100), '*', 'P');
            map1.AddRegion('P', player);
            map1.AddRegion('X', windowBlock);
            map1.AddRegion('T', topBlock);
            map1.AddRegion('>', rightBlock);
            map1.AddRegion('<', leftBlock);
            map1.AddRegion('E', windowBlock); // enemy
            map1.AddRegion('B', windowBlock); // boss
            map1.AddRegion('R', porchBlock);
            map1.AddRegion('A', leftCornerBlock);
            map1.AddRegion('C', rightCornerBlock);
            map1.AddBackground(backgroundBlocks);
            level1 = new Level(map1);
            currentGameState = GameState.TitleScreen;

            base.Initialize();
        }
Exemple #2
0
        public void Draw(SpriteBatch spriteBatch, Camera camera, GraphicsDevice g)
        {
            obj.Position = new Vector3(position.X,position.Y, 0);
            obj.Draw(camera.ViewMatrix, camera.ProjectionMatrix, g);

            //BoundingBoxRenderer.Render(
            //CollisionBox,
            //g,
            //camera.ViewMatrix,
            //camera.ProjectionMatrix,
            //Collision ? Color.Red : Color.Green);
        }
Exemple #3
0
 public void DrawMap(GameTime gameTime, Camera camera, GraphicsDevice g)
 {
     if (activateMap != null)
         activateMap.Draw(camera, g, Player);
 }
Exemple #4
0
 public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Camera camera, GraphicsDevice g)
 {
     Player.Draw(spriteBatch, camera, g);
 }
Exemple #5
0
        private void DrawTiles(Camera camera, GraphicsDevice g, Player p)
        {
            Rectangle bgRect = new Rectangle(0, 0, (int)(mapDimensions.X * TileDimensions.X),
                (int)(mapDimensions.Y * TileDimensions.Y));

            for (int j = 0; j < mapDimensions.Y; j++) {
                for (int i = 0; i < mapDimensions.X; i++) {
                    if (tiles[i, j] != '*') {
                        //look up block type in dictionary and draw the block
                        GameObject tile = tileRegions[tiles[i, j]];
                        tile.Position = new Vector3(TileDimensions.X * i, TileDimensions.Y * j, 0);
                        ////tron mode
                        tile.Draw(camera.ViewMatrix, camera.ProjectionMatrix, g);
                        //BoundingBox bb = new BoundingBox(new Vector3(tile.Position.X - (int)(60 * .68), tile.Position.Y, -(int)(60 * .68)), new Vector3(tile.Position.X + (int)(80 * .68), tile.Position.Y + (int)(140 * .68), (int)(60 * .68)));
                        //BoundingBoxRenderer.Render(bb, g, camera.ViewMatrix, camera.ProjectionMatrix,  p.CollisionBox.Intersects(bb) ? Color.Red : Color.Green);
                    }
                }
            }
        }
Exemple #6
0
 public void DrawBackground(Camera camera, GraphicsDevice g)
 {
     background.Draw(camera.ViewMatrix, camera.ProjectionMatrix, g);
     for (int i = -50; i < 150; i++)
     {
         BoundingBox bb = new BoundingBox(new Vector3(i * 100, 0, -5000), new Vector3((i * 100) + 50, 0, 0));
         BoundingBoxRenderer.Render(bb, g, camera.ViewMatrix, camera.ProjectionMatrix, Color.LightBlue);
     }
 }
Exemple #7
0
        public void Draw(Camera camera, GraphicsDevice g, Player p)
        {
            if (tileRegions.Count == 0)
                throw new Exception("Tile region must be populated by calling AddRegion");
            else {
                Rectangle bgRect = new Rectangle(0, 0, (int)(mapDimensions.X * TileDimensions.X),
                    (int)(mapDimensions.Y * TileDimensions.Y));

                DrawTiles(camera, g, p);
            }
        }