public bool Intersects(ref Terrain world) { int midX = (int) this.Position.X + (_width/2); if (world.terrainContour[midX] <= this.Position.Y +_height ) { return true; } else { return false; } }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; this.graphics.PreferredBackBufferWidth = screenWidth; this.graphics.PreferredBackBufferHeight = screenHeight; this.graphics.IsFullScreen = false; this.IsMouseVisible = true; playground = new Terrain() { screenHeight = this.backgroundHeight, screenWidth = this.backgroundWidth }; //Dodaje graczy tutaj tymczasowo: manager.AddPlayer(new Player() { Name = "Player 1", PlayerColor = Color.Aqua }); manager.AddPlayer(new Player() { Name = "Player 2", PlayerColor = Color.Red }); manager.AddPlayer(new Player() { Name = "Player 3", PlayerColor = Color.Yellow }); manager.AddPlayer(new Player() { Name = "Player 4", PlayerColor = Color.Green }); manager.screenWidth = backgroundWidth; }
/// <summary> /// Used to move fighters all around the world ;) /// </summary> /// <param name="world">Terrain</param> public void MoveLeft(ref Terrain world) { if (this.Position.X - speed > 0) { this.Position.X -= speed; } this.MoveY(ref world); }
public void MoveY(ref Terrain world) { int midX = (int)this.Position.X + (_width / 2); if (!this.Intersects(ref world)) { this.Position.Y = world.terrainContour[midX] - _height; //if (midX > 0 && midX < world.terrainContour.Count()) { // int yBorder = world.terrainContour[midX]; // if (yBorder > this.FighterArea.Bottom) { // Gravity.FreeFall(this.Position); // } //} } else { this.Position.Y = world.terrainContour[midX] - _height; } }
/// <summary> /// Used to move fighters all around the world ;) /// </summary> /// <param name="world">Terrain</param> public void MoveRight(ref Terrain world) { if (Position.X + speed + this.Width < world.terrainContour.Length) { this.Position.X += speed; } this.MoveY(ref world); }