2Platform Games Character jumps from platform to platform World terrain is made of tilesAdd player, bad guys, power ups
3Creating the game map Make the world (game map) for one level. Don’t use one huge image!Use grid – each slot points to a tile image or null
4Issues with Drawing the World Tile world is bigger than screenNeed to move the screen (instead of the player, often)Often want background image that moves slower than the rest of the world
5Calculate New Position Keep the player in the middle of the screen…Percentage of left and right of screen that makes the scroll happenif (Player.Position.X < marginLeft)cameraMovement = Player.Position.X - marginLeft
6Offset Don’t scroll off ends: float maxCameraPosition = Tile.Width * Width – viewport.Width;That is, (the width of one tile * # tiles in a row) – (width of screen)Screen
7Drawing the Tiles Efficiency: only draw visible tiles: int left = (int)Math.Floor(cameraPosition/Tile.Width);int right = left + <viewport width>/Tile.Width;right = Math.Min(right, Width-1) // where Width is the width of the 2D table.
8Drawing the Sprites Not many – just draw all (brute force) Many – only draw visible spritesKeep sprites in a list ordered by positionPartition map into screen – sized portions, keep sprites from each portion
9Drawing Backgrounds Choices: Keep background staticScroll background image at same rate as tilesScroll background image slower to mimic distanceLast method is known as Parallax Scrolling
10Scrolling Often will have segments of backgrounds. As scrolling happens, rotate backgrounds.Usually no more than 2 backgrounds segments drawn at any given time.