public void draw(SpriteBatch spriteBatch) { //DRAW ONLY FOR THE CURRENT STATE//// switch (currentState) { case State.GameState.Menu: spriteBatch.DrawString(font, "Current State: Menu", new Vector2(100, 100), Color.White); newGameButton.draw(spriteBatch); exitGameButton.draw(spriteBatch); break; case State.GameState.Load_Game: spriteBatch.DrawString(font, "Current State: Load_Game", new Vector2(100, 100), Color.White); break; case State.GameState.Save_Game: spriteBatch.DrawString(font, "Current State: Save_Game", new Vector2(100, 100), Color.White); break; case State.GameState.Character_Creation: spriteBatch.DrawString(font, "Current State: Character_Creation", new Vector2(100, 100), Color.White); backButton.draw(spriteBatch); break; case State.GameState.Paused: spriteBatch.DrawString(font, "Current State: Paused", new Vector2(100, 100), Color.White); resumeButton.draw(spriteBatch); exitFromPausedButton.draw(spriteBatch); break; case State.GameState.Options: spriteBatch.DrawString(font, "Current State: Options", new Vector2(100, 100), Color.White); break; case State.GameState.In_Play: spriteBatch.DrawString(font, "Current State: In_Play", new Vector2(100, 100), Color.White); spriteBatch.Draw(TextureBank.InterfaceTextures.utilityBar, new Rectangle(-1, screenHeight - TextureBank.InterfaceTextures.utilityBar.Height, screenWidth + 1, TextureBank.InterfaceTextures.utilityBar.Height), Color.White); spriteBatch.Draw(TextureBank.InterfaceTextures.healthBar, new Rectangle((int)(0.10 * screenWidth), screenHeight - 135, (int)(healthRatio * TextureBank.InterfaceTextures.healthBar.Width), TextureBank.InterfaceTextures.healthBar.Height), Color.White); spriteBatch.Draw(TextureBank.InterfaceTextures.energyBar, new Rectangle((int)(0.55 * screenWidth), screenHeight - 135, (int)(energyRatio * TextureBank.InterfaceTextures.energyBar.Width), TextureBank.InterfaceTextures.energyBar.Height), Color.White); utilityBarMenuButton.draw(spriteBatch); if (mouseOverHealth) { spriteBatch.DrawString(font, Fagblo.getInstance().currentPlayer.health + " / " + Fagblo.getInstance().currentPlayer.maxHealth, new Vector2((float)(screenWidth * 0.10 + TextureBank.InterfaceTextures.healthBar.Width / 2), screenHeight - 133), Color.White); } if (mouseOverEnergy) { spriteBatch.DrawString(font, Fagblo.getInstance().currentPlayer.energy + " / " + Fagblo.getInstance().currentPlayer.maxEnergy, new Vector2((float)(screenWidth * 0.55 + TextureBank.InterfaceTextures.energyBar.Width / 2), screenHeight - 133), Color.White); } break; } cursor.draw(spriteBatch); }
public void Update() { PreviousKeyboardState = CurrentKeyboardState; CurrentKeyboardState = Keyboard.GetState(); currentState = Fagblo.getInstance().currentState; switch (currentState) { case State.GameState.Menu: if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { //EXIT MENU } break; case State.GameState.Load_Game: if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { //EXIT MENU } break; case State.GameState.Save_Game: if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { //EXIT MENU } break; case State.GameState.Character_Creation: if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { //EXIT MENU } break; case State.GameState.Paused: if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { //EXIT MENU } break; case State.GameState.Options: if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { //EXIT MENU } break; case State.GameState.In_Play: if (Keyboard.GetState().IsKeyDown(Keys.W) && Keyboard.GetState().IsKeyDown(Keys.A)) { Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Moving; Fagblo.getInstance().currentPlayer.move(State.Direction.NorthWest); } else if (Keyboard.GetState().IsKeyDown(Keys.W) && Keyboard.GetState().IsKeyDown(Keys.D)) { Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Moving; Fagblo.getInstance().currentPlayer.move(State.Direction.NorthEast); } else if (Keyboard.GetState().IsKeyDown(Keys.S) && Keyboard.GetState().IsKeyDown(Keys.A)) { Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Moving; Fagblo.getInstance().currentPlayer.move(State.Direction.SouthWest); } else if (Keyboard.GetState().IsKeyDown(Keys.S) && Keyboard.GetState().IsKeyDown(Keys.D)) { Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Moving; Fagblo.getInstance().currentPlayer.move(State.Direction.SouthEast); } else if (Keyboard.GetState().IsKeyDown(Keys.W)) { //MOVE PLAYER UP Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Moving; Fagblo.getInstance().currentPlayer.move(State.Direction.North); } else if (Keyboard.GetState().IsKeyDown(Keys.S)) { //MOVE PLAYER DOWN Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Moving; Fagblo.getInstance().currentPlayer.move(State.Direction.South); } else if (Keyboard.GetState().IsKeyDown(Keys.D)) { //MOVE PLAYER RIGHT Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Moving; Fagblo.getInstance().currentPlayer.move(State.Direction.East); } else if (Keyboard.GetState().IsKeyDown(Keys.A)) { //MOVE PLAYER LEFT Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Moving; Fagblo.getInstance().currentPlayer.move(State.Direction.West); } if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { //OPEN MENU } if (Keyboard.GetState().IsKeyDown(Keys.N)) { //OPEN CHARACTER MENU } if (Keyboard.GetState().IsKeyDown(Keys.I)) { //OPEN INVENTORY } if (Keyboard.GetState().IsKeyDown(Keys.M)) { //OPEN MAP MENU } if (Keyboard.GetState().IsKeyDown(Keys.P)) { //PAUSE GAME } if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { //OPEN OPTIONS } if (Keyboard.GetState().IsKeyDown(Keys.F8)) { //OPEN SAVE MENU } if (Keyboard.GetState().IsKeyDown(Keys.F9)) { //OPEN LOAD MENU } //MOVING TO IDLE STATE CHANGES if (PreviousKeyboardState.IsKeyDown(Keys.W) == true && CurrentKeyboardState.IsKeyUp(Keys.W) == true) { Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Idle; } if (PreviousKeyboardState.IsKeyDown(Keys.S) == true && CurrentKeyboardState.IsKeyUp(Keys.S) == true) { Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Idle; } if (PreviousKeyboardState.IsKeyDown(Keys.D) == true && CurrentKeyboardState.IsKeyUp(Keys.D) == true) { Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Idle; } if (PreviousKeyboardState.IsKeyDown(Keys.A) == true && CurrentKeyboardState.IsKeyUp(Keys.A) == true) { Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Idle; } //NE if (PreviousKeyboardState.IsKeyDown(Keys.W) && PreviousKeyboardState.IsKeyDown(Keys.D) == true && CurrentKeyboardState.IsKeyUp(Keys.W) && CurrentKeyboardState.IsKeyUp(Keys.D) == true) { Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Idle; } //NW if (PreviousKeyboardState.IsKeyDown(Keys.W) && PreviousKeyboardState.IsKeyDown(Keys.A) == true && CurrentKeyboardState.IsKeyUp(Keys.W) && CurrentKeyboardState.IsKeyUp(Keys.A) == true) { Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Idle; } //SE if (PreviousKeyboardState.IsKeyDown(Keys.S) && PreviousKeyboardState.IsKeyDown(Keys.D) == true && CurrentKeyboardState.IsKeyUp(Keys.S) && CurrentKeyboardState.IsKeyUp(Keys.D) == true) { Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Idle; } //SW if (PreviousKeyboardState.IsKeyDown(Keys.S) && PreviousKeyboardState.IsKeyDown(Keys.A) == true && CurrentKeyboardState.IsKeyUp(Keys.S) && CurrentKeyboardState.IsKeyUp(Keys.A) == true) { Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Idle; } //determine if we're clicking the playfield if (InterfaceManager.getInstance().cursor.isLeftPressed() && InterfaceManager.getInstance().cursor.getPos().Y < InterfaceManager.getInstance().getUtilityBarBoundary()) { Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Attacking; //now to determine the direction //the basic algorithm will be to split up the playfield into 8 fields, one for all eight directions //once the field is split, we then find which one the cursor is in //i hate math Vector2 mousePos = InterfaceManager.getInstance().cursor.getPos(); Vector2 playerPos = MapManager.getInstance().currentMap.positionOnScreen(Fagblo.getInstance().currentPlayer.getPos()); double angle; //easy cases first if (mousePos.X == playerPos.X && mousePos.Y < playerPos.Y) { Fagblo.getInstance().currentPlayer.playerDirection = State.Direction.North; } else if (mousePos.X == playerPos.X && mousePos.Y >= playerPos.Y) { Fagblo.getInstance().currentPlayer.playerDirection = State.Direction.South; } else if (mousePos.X >= playerPos.X && mousePos.Y == playerPos.Y) { Fagblo.getInstance().currentPlayer.playerDirection = State.Direction.East; } else if (mousePos.X < playerPos.X && mousePos.Y == playerPos.Y) { Fagblo.getInstance().currentPlayer.playerDirection = State.Direction.West; } else { //quadrant based, man this sucks if (playerPos.X < mousePos.X && playerPos.Y > mousePos.Y) { angle = (180 / Math.PI) * Math.Atan((playerPos.Y - mousePos.Y) / (mousePos.X - playerPos.X)); } else if (playerPos.X > mousePos.X && playerPos.Y > mousePos.Y) { angle = 90 + (90 - (180 / Math.PI) * Math.Atan((playerPos.Y - mousePos.Y) / (playerPos.X - mousePos.X))); } else if (playerPos.X > mousePos.X && playerPos.Y < mousePos.Y) { angle = 180 + (180 / Math.PI) * Math.Atan((mousePos.Y - playerPos.Y) / (playerPos.X - mousePos.X)); } else if (playerPos.X < mousePos.X && playerPos.Y < mousePos.Y) { angle = 270 + (90 - (180 / Math.PI) * Math.Atan((mousePos.Y - playerPos.Y) / (mousePos.X - playerPos.X))); } else { angle = 0; } //NOW, find which field the cursor is in if (angle > 330 || angle <= 30) { Fagblo.getInstance().currentPlayer.playerDirection = State.Direction.East; } else if (angle > 30 && angle <= 60) { Fagblo.getInstance().currentPlayer.playerDirection = State.Direction.NorthEast; } else if (angle > 60 && angle <= 120) { Fagblo.getInstance().currentPlayer.playerDirection = State.Direction.North; } else if (angle > 120 && angle <= 150) { Fagblo.getInstance().currentPlayer.playerDirection = State.Direction.NorthWest; } else if (angle > 150 && angle <= 210) { Fagblo.getInstance().currentPlayer.playerDirection = State.Direction.West; } else if (angle > 210 && angle <= 240) { Fagblo.getInstance().currentPlayer.playerDirection = State.Direction.SouthWest; } else if (angle > 240 && angle <= 300) { Fagblo.getInstance().currentPlayer.playerDirection = State.Direction.South; } else if (angle > 300 && angle <= 330) { Fagblo.getInstance().currentPlayer.playerDirection = State.Direction.SouthEast; } else { //if we got here, uh oh } } } //now check to see if we released if (InterfaceManager.getInstance().cursor.wasLeftJustReleased() && Fagblo.getInstance().currentPlayer.currentState == State.PlayerState.Attacking) { Fagblo.getInstance().currentPlayer.currentState = State.PlayerState.Idle; } break; } }
public void update() { this.mouseOverEnergy = false; this.mouseOverHealth = false; currentState = Fagblo.getInstance().currentState; cursor.update(); //UPDATE INTERFACE FOR THE CURRENT STATE//// switch (currentState) { case State.GameState.Menu: newGameButton.update(cursor); exitGameButton.update(cursor); //interactions//// if (newGameButton.wasJustPressed()) { Fagblo.getInstance().currentState = State.GameState.Character_Creation; newGameButton.committedAction(); } if (exitGameButton.wasJustPressed()) { Fagblo.getInstance().Exit(); exitGameButton.committedAction(); } break; case State.GameState.Load_Game: break; case State.GameState.Save_Game: break; case State.GameState.Character_Creation: backButton.update(cursor); //interactions//// if (backButton.wasJustPressed()) { Fagblo.getInstance().currentState = State.GameState.Menu; backButton.committedAction(); } break; case State.GameState.Paused: resumeButton.update(cursor); exitFromPausedButton.update(cursor); //interactions//// if (resumeButton.wasJustPressed()) { Fagblo.getInstance().currentState = State.GameState.In_Play; resumeButton.committedAction(); } if (exitFromPausedButton.wasJustPressed()) { Fagblo.getInstance().Exit(); exitFromPausedButton.committedAction(); } break; case State.GameState.Options: break; case State.GameState.In_Play: healthRatio = (float)Fagblo.getInstance().currentPlayer.health / Fagblo.getInstance().currentPlayer.maxHealth; energyRatio = (float)Fagblo.getInstance().currentPlayer.energy / Fagblo.getInstance().currentPlayer.maxEnergy; //if mouse cursor is hovering over health bar, tell the player their current/max health if (cursor.getPos().X >= screenWidth * 0.10 && cursor.getPos().X <= screenWidth * 0.10 + TextureBank.InterfaceTextures.healthBar.Width && cursor.getPos().Y >= screenHeight - 135 && cursor.getPos().Y <= screenHeight - 135 + TextureBank.InterfaceTextures.healthBar.Height) { this.mouseOverHealth = true; } //if mouse cursor is hovering over energy bar, tell the player their current/max energy if (cursor.getPos().X >= screenWidth * 0.55 && cursor.getPos().X <= screenWidth * 0.55 + TextureBank.InterfaceTextures.energyBar.Width && cursor.getPos().Y >= screenHeight - 135 && cursor.getPos().Y <= screenHeight - 135 + TextureBank.InterfaceTextures.energyBar.Height) { this.mouseOverEnergy = true; } utilityBarMenuButton.update(cursor); //interactions//// if (utilityBarMenuButton.wasJustPressed()) { Fagblo.getInstance().currentState = State.GameState.Paused; utilityBarMenuButton.committedAction(); } break; } }
public void draw(SpriteBatch spriteBatch) { Vector2 positionOnScreen = MapManager.getInstance().currentMap.positionOnScreen(PlayerPos); if (lolcolor == Color.Red) { lolcolor = Color.White; } else if (lolcolor == Color.White) { lolcolor = Color.Red; } switch (this.currentState) { //CASE IDLE//// case State.PlayerState.Idle: /*switch (this.playerDirection) * { * case State.Direction.East: * * break; * * case State.Direction.North: * * break; * * case State.Direction.NorthEast: * * break; * * case State.Direction.NorthWest: * * break; * * case State.Direction.South: * * break; * * case State.Direction.SouthEast: * * break; * * case State.Direction.SouthWest: * * break; * * case State.Direction.West: * * break; * }*/ spriteBatch.Draw(TextureBank.EntityTextures.Player, Fagblo.getInstance().camera.getPlayerOnScreenPosition(), Color.White); break; //CASE MOVING//// case State.PlayerState.Moving: /*switch (this.playerDirection) * { * case State.Direction.East: * * break; * * case State.Direction.North: * * break; * * case State.Direction.NorthEast: * * break; * * case State.Direction.NorthWest: * * break; * * case State.Direction.South: * * break; * * case State.Direction.SouthEast: * * break; * * case State.Direction.SouthWest: * * break; * * case State.Direction.West: * * break; * }*/ spriteBatch.Draw(TextureBank.EntityTextures.Player, Fagblo.getInstance().camera.getPlayerOnScreenPosition(), Color.Blue); break; //CASE ATTACKING//// case State.PlayerState.Attacking: switch (this.playerDirection) { case State.Direction.East: spriteBatch.DrawString(InterfaceManager.getInstance().getFont(), "ATTACKING EAST", new Vector2(Fagblo.getInstance().camera.getPlayerOnScreenPosition().X, Fagblo.getInstance().camera.getPlayerOnScreenPosition().Y - 100), lolcolor); break; case State.Direction.North: spriteBatch.DrawString(InterfaceManager.getInstance().getFont(), "ATTACKING NORTH", new Vector2(Fagblo.getInstance().camera.getPlayerOnScreenPosition().X, Fagblo.getInstance().camera.getPlayerOnScreenPosition().Y - 100), lolcolor); break; case State.Direction.NorthEast: spriteBatch.DrawString(InterfaceManager.getInstance().getFont(), "ATTACKING NORTHEAST", new Vector2(Fagblo.getInstance().camera.getPlayerOnScreenPosition().X, Fagblo.getInstance().camera.getPlayerOnScreenPosition().Y - 100), lolcolor); break; case State.Direction.NorthWest: spriteBatch.DrawString(InterfaceManager.getInstance().getFont(), "ATTACKING NORTHWEST", new Vector2(Fagblo.getInstance().camera.getPlayerOnScreenPosition().X, Fagblo.getInstance().camera.getPlayerOnScreenPosition().Y - 100), lolcolor); break; case State.Direction.South: spriteBatch.DrawString(InterfaceManager.getInstance().getFont(), "ATTACKING SOUTH", new Vector2(Fagblo.getInstance().camera.getPlayerOnScreenPosition().X, Fagblo.getInstance().camera.getPlayerOnScreenPosition().Y - 100), lolcolor); break; case State.Direction.SouthEast: spriteBatch.DrawString(InterfaceManager.getInstance().getFont(), "ATTACKING SOUTHEAST", new Vector2(Fagblo.getInstance().camera.getPlayerOnScreenPosition().X, Fagblo.getInstance().camera.getPlayerOnScreenPosition().Y - 100), lolcolor); break; case State.Direction.SouthWest: spriteBatch.DrawString(InterfaceManager.getInstance().getFont(), "ATTACKING SOUTHWEST", new Vector2(Fagblo.getInstance().camera.getPlayerOnScreenPosition().X, Fagblo.getInstance().camera.getPlayerOnScreenPosition().Y - 100), lolcolor); break; case State.Direction.West: spriteBatch.DrawString(InterfaceManager.getInstance().getFont(), "ATTACKING WEST", new Vector2(Fagblo.getInstance().camera.getPlayerOnScreenPosition().X, Fagblo.getInstance().camera.getPlayerOnScreenPosition().Y - 100), lolcolor); break; } spriteBatch.Draw(TextureBank.EntityTextures.Player, Fagblo.getInstance().camera.getPlayerOnScreenPosition(), Color.Red); break; //CASE DEAD//// case State.PlayerState.Dead: switch (this.playerDirection) { case State.Direction.East: break; case State.Direction.North: break; case State.Direction.NorthEast: break; case State.Direction.NorthWest: break; case State.Direction.South: break; case State.Direction.SouthEast: break; case State.Direction.SouthWest: break; case State.Direction.West: break; } break; } }
public void update() { pos = Fagblo.getInstance().currentPlayer.getPos(); MapManager.getInstance().currentMap.translatePixelToMapCell((int)pos.X - (screenWidth / 2), (int)pos.Y - (screenHeight / 2), out xStart, out yStart); MapManager.getInstance().currentMap.translatePixelToMapCell((int)pos.X + (screenWidth / 2), (int)pos.Y + (screenHeight / 2), out xEnd, out yEnd); //boundary cases if (xStart <= 0) { xStart = 0; xEnd = screenWidth / MapManager.TILE_WIDTH; xRemain = 0; } else if (xEnd > MapManager.getInstance().currentMap.width_pix / MapManager.getInstance().currentMap.TILE_WIDTH) { xEnd = MapManager.getInstance().currentMap.width_pix / MapManager.getInstance().currentMap.TILE_WIDTH; xStart = xEnd - (screenWidth / MapManager.TILE_WIDTH); xRemain = 0; } else { //xRemain = Math.Abs((int)(pos.X - (screenWidth / 2) % MapManager.getInstance().currentMap.TILE_WIDTH)); if (xStart == 0) { //yRemain = MapManager.TILE_HEIGHT - Math.Abs((int)((pos.Y - (screenHeight / 2)) % MapManager.getInstance().currentMap.TILE_HEIGHT)); xRemain = MapManager.TILE_WIDTH - Math.Abs((int)(pos.X - (screenWidth / 2))); } else { xRemain = Math.Abs(MapManager.TILE_WIDTH - (int)((pos.X - (screenWidth / 2)) % MapManager.getInstance().currentMap.TILE_WIDTH)); } } if (yStart <= 0) { yStart = 0; yEnd = screenHeight / MapManager.TILE_HEIGHT; yRemain = 0; } else if (yEnd > MapManager.getInstance().currentMap.height_pix / MapManager.getInstance().currentMap.TILE_HEIGHT) { yEnd = MapManager.getInstance().currentMap.height_pix / MapManager.getInstance().currentMap.TILE_HEIGHT; yStart = yEnd - (screenHeight / MapManager.TILE_HEIGHT); yRemain = 0; } else { //yRemain = Math.Abs((int)(pos.Y - (screenHeight / 2) % MapManager.getInstance().currentMap.TILE_HEIGHT)); if (yStart == 0) { //yRemain = MapManager.TILE_HEIGHT - Math.Abs((int)((pos.Y - (screenHeight / 2)) % MapManager.getInstance().currentMap.TILE_HEIGHT)); yRemain = MapManager.TILE_HEIGHT - Math.Abs((int)(pos.Y - (screenHeight / 2))); } else { yRemain = Math.Abs(MapManager.TILE_HEIGHT - (int)((pos.Y - (screenHeight / 2)) % MapManager.getInstance().currentMap.TILE_HEIGHT)); } } }
public void draw(SpriteBatch spriteBatch) { //draw all terrain int xScreen = 0 + xRemain; int yScreen = 0 + yRemain; for (int i = yStart; i < yEnd; i++) { xScreen = 0 + xRemain; for (int j = xStart; j < xEnd; j++) { spriteBatch.Draw(MapManager.getInstance().currentMap.tileGrid[j, i].texture, new Rectangle(xScreen, yScreen, MapManager.TILE_WIDTH, MapManager.TILE_HEIGHT), Color.White); xScreen = xScreen + MapManager.getInstance().currentMap.TILE_WIDTH; } yScreen = yScreen + MapManager.getInstance().currentMap.TILE_HEIGHT; } //boundary terrain if (xRemain != 0) { yScreen = 0 + yRemain; for (int i = yStart; i < yEnd; i++) { spriteBatch.Draw(MapManager.getInstance().currentMap.tileGrid[xStart, i].texture, new Rectangle(0, yScreen, xRemain, MapManager.TILE_HEIGHT), new Rectangle(MapManager.TILE_WIDTH - xRemain, 0, xRemain, MapManager.TILE_HEIGHT), Color.White); yScreen = yScreen + MapManager.getInstance().currentMap.TILE_HEIGHT; } if (xEnd == MapManager.TILE_WIDTH * MapManager.getInstance().currentMap.width_pix - 1) { yScreen = 0 + yRemain; for (int i = yStart; i < yEnd; i++) { spriteBatch.Draw(MapManager.getInstance().currentMap.tileGrid[xEnd, i].texture, new Rectangle(0, yScreen, xRemain, MapManager.TILE_HEIGHT), new Rectangle(MapManager.TILE_WIDTH - xRemain, 0, xRemain, MapManager.TILE_HEIGHT), Color.White); yScreen = yScreen + MapManager.getInstance().currentMap.TILE_HEIGHT; } } } if (yRemain != 0) { xScreen = 0 + xRemain; for (int i = xStart; i < xEnd; i++) { spriteBatch.Draw(MapManager.getInstance().currentMap.tileGrid[i, yStart].texture, new Rectangle(xScreen, 0, MapManager.TILE_WIDTH, yRemain), new Rectangle(0, MapManager.TILE_HEIGHT - yRemain, MapManager.TILE_WIDTH, yRemain), Color.White); xScreen = xScreen + MapManager.getInstance().currentMap.TILE_WIDTH; } if (yEnd == MapManager.TILE_HEIGHT * MapManager.getInstance().currentMap.height_pix - 1) { xScreen = 0 + xRemain; for (int i = xStart; i < xEnd; i++) { spriteBatch.Draw(MapManager.getInstance().currentMap.tileGrid[i, yEnd].texture, new Rectangle(xScreen, 0, MapManager.TILE_WIDTH, yRemain), new Rectangle(0, MapManager.TILE_HEIGHT - yRemain, MapManager.TILE_WIDTH, yRemain), Color.White); xScreen = xScreen + MapManager.getInstance().currentMap.TILE_WIDTH; } } } if (xRemain != 0 && yRemain != 0 && Fagblo.getInstance().currentPlayer.playerDirection == State.Direction.NorthWest) { if (xStart - 1 >= 0 && yStart - 1 >= 0) { spriteBatch.Draw(MapManager.getInstance().currentMap.tileGrid[xStart - 1, yStart - 1].texture, new Rectangle(0, 0, xRemain, yRemain), new Rectangle(MapManager.TILE_WIDTH - xRemain, MapManager.TILE_HEIGHT - yRemain, xRemain, yRemain), Color.White); } } else if (xRemain != 0 && yRemain != 0 && Fagblo.getInstance().currentPlayer.playerDirection == State.Direction.SouthEast) { if (xStart - 1 >= 0 && yStart - 1 >= 0) { spriteBatch.Draw(MapManager.getInstance().currentMap.tileGrid[xStart - 1, yStart - 1].texture, new Rectangle(0, 0, xRemain, yRemain), new Rectangle(MapManager.TILE_WIDTH - xRemain, MapManager.TILE_HEIGHT - yRemain, xRemain, yRemain), Color.White); } } //TODO: draw map objects //TODO: draw entities //draw player Fagblo.getInstance().currentPlayer.draw(spriteBatch); }