-
Notifications
You must be signed in to change notification settings - Fork 0
Side scroller screen functionality guide
Dollar0712 edited this page Aug 30, 2021
·
1 revision
This session focuses on how to make changes to the map from the side scroller perspective
Related files: TerrainFactory
, ForestGameArea
.
The entire terrain is made up of multiple tiles.
The terrain is created by generating different types of tiles at specified locations.
- Map size
private static final GridPoint2 MAP_SIZE = new GridPoint2(30, 30);
- Tile size
GridPoint2 tilePixelSize = new GridPoint2(example_tile.getRegionWidth(), example_tile.getRegionHeight());
- In the
TerrainFactory
, theprivate TiledMap createSideScrollTiles
function, create a new background look
//A new tile with side scroll-er
private TiledMap createSideScrollTiles(
GridPoint2 tileSize, TextureRegion surface, TextureRegion underground, TextureRegion sky, TextureRegion tree) {
TiledMap tiledMap = new TiledMap();
TerrainTile surfaceTile = new TerrainTile(surface);
TerrainTile undergroundTile = new TerrainTile(underground);
TerrainTile skyTile = new TerrainTile(sky);
TerrainTile treeTile = new TerrainTile(tree);
TiledMapTileLayer layer = new TiledMapTileLayer(MAP_SIZE.x, MAP_SIZE.y, tileSize.x, tileSize.y);
// Create base grass
fillTilesAt(layer, new GridPoint2(0, 9), new GridPoint2(30, 10), surfaceTile);
fillTilesAt(layer, new GridPoint2(0, 0), new GridPoint2(30, 9), undergroundTile);
fillTilesAt(layer, new GridPoint2(0, 10), new GridPoint2(30, 30), skyTile);
tiledMap.getLayers().add(layer);
return tiledMap;
}
- In
private TerrainComponent createSideScrollTerrain
, Package the tilemap that just created into a component and return it
GridPoint2 tilePixelSize = new GridPoint2(surface.getRegionWidth(), surface.getRegionHeight());
TiledMap tiledMap = createSideScrollTiles(tilePixelSize, surface, underground, sky, tree);
TiledMapRenderer renderer = createRenderer(tiledMap, tileWorldSize / tilePixelSize.x);
return new TerrainComponent(camera, tiledMap, renderer, orientation, tileWorldSize);
- In
public TerrainComponent createTerrain
, import the image you need for the terrain you just created
ResourceService resourceService = ServiceLocator.getResourceService();
TextureRegion surface =
new TextureRegion(resourceService.getAsset("images/surface.png", Texture.class));
TextureRegion underground =
new TextureRegion(resourceService.getAsset("images/underground.png", Texture.class));
TextureRegion sky =
new TextureRegion(resourceService.getAsset("images/sky.png", Texture.class));
TextureRegion tree =
new TextureRegion(resourceService.getAsset("images/tree.png", Texture.class));
return createSideScrollTerrain(0.5f, surface, underground, sky, tree);
-
Visual terrain generation complete
-
Adding air walls to visual terrain by using the
private void spawnTerrain()
function inForestGameArea
class
private void spawnTerrain() {
// Background terrain
terrain = terrainFactory.createTerrain(TerrainType.SIDE_SCROLL_ER);
spawnEntity(new Entity().addComponent(terrain));
// Terrain walls
float tileSize = terrain.getTileSize();
GridPoint2 tileBounds = terrain.getMapBounds(0);
Vector2 worldBounds = new Vector2(tileBounds.x * tileSize, tileBounds.y * tileSize);
// Left air wall
spawnEntityAt(
ObstacleFactory.createWall(WALL_WIDTH, worldBounds.y), GridPoint2Utils.ZERO, false, false);
// Right air wall
spawnEntityAt(
ObstacleFactory.createWall(WALL_WIDTH, worldBounds.y),
new GridPoint2(tileBounds.x, 0),
false,
false);
// Top air wall
spawnEntityAt(
ObstacleFactory.createWall(worldBounds.x, WALL_WIDTH),
new GridPoint2(0, tileBounds.y),
false,
false);
// Bottom air wall
spawnEntityAt(
//change a wall with high:10
ObstacleFactory.createWall(worldBounds.x, WALL_WIDTH), new GridPoint2(0, 10), false, false);
}
- the terrain with a working air wall is done
p.s: Don't forget to import the png files for both class
- Player UI
- Popup Menus
- Obstacles
- Boss Enemies
- Progress Tracker
- Checkpoint Design and Functionality
- Score System
- Lives System
- Game Background
- Multiple game-level
- Visual Improvements
- Tutorial Level
- Character Design and Animations
- Character Damage Animations
- Player Animation Functionalities
- Player and Serpent Portal Transition
- Pop-up Menus
- Obstacles
- Lives & Score User Testing
- Buffs & Debuffs
- Buffs & Debuffs redesign
- Obstacle Animation
- Background Design
- Level 2 Background Appearance
- Enemy Monster User Testing
- Level 1 Floor Terrain Testing
- Introduction Screens User Testing
- Character Movement Interviews & User Testing
- Sound user testing
- Level 2 Obstacles and enemy
- Story, Loading, Level 4 and Win Condition Sound Design User Testing
- Giant Bug and Purple Squid animation user testing
- General Gameplay and Tutorial Level User Testing
- Level 4 Terrain User Testing
- Game Outro User Testing