예제 #1
0
파일: Camera.cs 프로젝트: Gillium/cs204L
 public void Update(GameTime gameTime, Player player)
 {
     center = new Vector2(player.PlayerPostion().X + (player.PlayerRectangle().Width / 2) - 300,
     player.PlayerPostion().Y + (player.PlayerRectangle().Height / 2) - 400);//400 half of screen, 0 is y in description of video
     transform = Matrix.CreateScale(new Vector3(1, 1, 0)) * //how far zoomed in, 1 is null size
     Matrix.CreateTranslation(new Vector3(-center.X, -center.Y, 0));
     position.X = player.PlayerPostion().X;
     position.Y = player.PlayerPostion().Y;
     viewAt.X = position.X;
     viewAt.Y = position.Y;
     UpdateView();
 }
예제 #2
0
파일: Map.cs 프로젝트: Gillium/cs204L
 public bool CheckCollision(Player p)
 {
     int i = (int)((p.PlayerPostion().X + 50) / 100);
     int j = (int)((p.PlayerPostion().Y + 20) / 100);
     if (i < 1)
         i = 0;
     if (j < 1)
         j = 0;
     if ((i < mapDimensions.X) && (j < mapDimensions.Y) && !tiles[i, j].Equals('*'))
     {
         Vector3 pos = new Vector3(TileDimensions.X * i, TileDimensions.Y * j, 0);
         BoundingBox bb = new BoundingBox(new Vector3(pos.X - (int)(80 * .68), pos.Y, -(int)(80 * .68)), new Vector3(pos.X + (int)(80 * .68), pos.Y + (int)((IsPorch(i, j) ? 10 : 140) * .68), (int)(60 * .68)));
         bool hits = p.CollisionBox.Intersects(bb);
         if (hits)
             return true;
         else
             return false;
     }
     return false;
 }
예제 #3
0
파일: Level.cs 프로젝트: Gillium/cs204L
 public Level(Map map)
 {
     Player = new Player(map.SpawnPoint.X, map.SpawnPoint.Y, map.TileDimensions.X, map.TileDimensions.Y);
     activateMap = map;
 }
예제 #4
0
파일: Map.cs 프로젝트: Gillium/cs204L
        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);
                    }
                }
            }
        }
예제 #5
0
파일: Map.cs 프로젝트: Gillium/cs204L
        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);
            }
        }