Skip to content

Air Kingdom

chloemicah edited this page Oct 17, 2024 · 4 revisions
Screenshot 2024-10-17 at 12 52 03 PM

Description

Air Kingdom is the third and final level after defeating the second Final Boss is defeated. Likewise, players will explore different areas, interact with air creatures, and collect items. The main goal is to complete quests and lead to combat the third Final Boss.

The Air Kingdom is the Final level so once unlocked, players will be able to travel from Air Kingdom to either Land Kingdom or Water Kingdom anytime.

In Air Kingdom, Gameareas represent areas in the game, such as levels or different map scenes. Different types of maps (e.g., forest, sea, sky, etc.) are managed and switched through MapHandler. MapHandler is also responsible for handling the storage and switching of map states, as well as unlocking logic for specific areas such as "water" or "air".

APIs, code, features & design used

APIs

  • LibGDX: Game framework used for graphics, input handling, and sound.

  • JSON: Used to load and configure levels such as terrain types and spawn points.

Code

  • Game Logic: Written in Java using object-oriented principles.

  • Modular Architecture: Terrain, player, and item components are managed using independent classes to improve scalability.

  • MapHandler: responsible for map switching and map state management, decoupling the dependencies between different maps.

Features

  • Map switching: Support for free switching between multiple maps, such as forest, sea and sky areas.

  • Entity Management: The GameArea supports generating entities by tile and absolute coordinates (Vector2).

  • Map status saving: Use the switchMapTo() method to determine whether to save the current map status for future restoration. The resetMapHandler() method resets all map states.

Design Principles

  • Pixel Art Design: Custom-made tiles that fit 3x3 grids to create visually consistent maps.

  • Seamless Map Transitions: Ensures smooth movement between different terrain types.

Pixel Art can be found here::

UML

image

Testing

Check if Game Area is initialised

@Test
void testInitialisation() {
        assertNotNull(forestGameArea, "ForestGameArea should be initialised");
    }

Check if Entities Spawn

@Test
  void shouldSpawnEntities() {
    TerrainFactory factory = mock(TerrainFactory.class);

    GameArea gameArea =
        new GameArea() {
          @Override
          public void create() {}

          @Override
          public Entity getPlayer() {
            return null;
          }

          @Override
          public void unloadAssets() {
          }

          @Override
          public void pauseMusic() {
            // TODO Auto-generated method stub
            throw new UnsupportedOperationException("Unimplemented method 'pauseMusic'");
          }

          @Override
          public void playMusic() {
            // TODO Auto-generated method stub
            throw new UnsupportedOperationException("Unimplemented method 'playMusic'");
          }

          @Override
          public List<Entity> getEnemies() {
            // TODO Auto-generated method stub
            throw new UnsupportedOperationException("Unimplemented method 'getEnemies'");
          }
        };

    ServiceLocator.registerEntityService(new EntityService());
    Entity entity = mock(Entity.class);

    gameArea.spawnEntity(entity);
    verify(entity).create();

    gameArea.dispose();
    verify(entity).dispose();
  }

Testing Tiles

    @Test
    public void testGetName() {
        assertEquals("TestTile", tile.getName());
    }

    @Test
    public void testGetTexture() {
        assertNotNull(tile.getTexture());
    }

    @Test
    public void testGetEdgeTiles() {
        assertEquals(2, tile.getEdgeTiles().size());
    }

    @Test
    public void testGetCentre() {
        assertEquals("CentreTile", tile.getCentre());
    }
}

Testing Tile Config

 @Test
    void testForestMapTilesInitialization() {
        // ensure the number of forestMapTiles is not null and greater than 0
        assertNotNull(ForestTileConfig.getForestMapTiles(), "forestMapTiles should not be null");
        assertTrue(ForestTileConfig.getForestMapTiles().length > 0, "forestMapTiles should contain at least one tile configuration");

        // check the property of each tile
        for (TileConfig tile : ForestTileConfig.getForestMapTiles()) {
            assertNotNull(tile.id, "Tile ID should not be null");
            assertNotNull(tile.fp, "File path should not be null");
            assertNotNull(tile.edges, "Edges should not be null");
            assertNotNull(tile.centre, "Centre should not be null");
        }
    }
}
Clone this wiki locally