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(); }
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; }