Skip to content

Navigation Component

Shaivika Anand edited this page Oct 26, 2023 · 6 revisions

Introduction

The Navigation component in our game is responsible for managing navigation between different areas or planets. It allows players to explore the game world by interacting with various planets or locations. This wiki page provides an overview of the Navigation component and its associated classes

Overview

The Navigation component utilizes LibGDX's scene2d.ui framework to create interactive UI elements representing planets or locations.

Navigation Class

Class Definition

package com.csse3200.game.areas;

// ... (import statements)

public class Navigation extends GameArea {
    private final TerrainFactory terrainFactory;
    private static final Logger logger = LoggerFactory.getLogger(Navigation.class);
    private static final String[] NavigationTextures = {"images/box_boy_title.png"};
    private final String image;
    
    // Constructor
    public Navigation(TerrainFactory terrainFactory, String image) {
        this.terrainFactory = terrainFactory;
        this.image = image;
    }

    // ... (other methods)
}

The Navigation class is the main component responsible for managing the navigation between game areas. It extends the GameArea class and includes the necessary instance variables, constructor, and methods for setting up navigation and disposing of resources.

Level Component

Class Definition

package com.csse3200.game.components.navigation;

// ... (import statements)

public class level3 extends UIComponent {
    private final String PlanetImage;
    private final float x;
    private final float y;
    private Table table;
    
    // Constructor
    public level3(String PlanetImage, float x, float y) {
        this.PlanetImage = PlanetImage;
        this.x = x;
        this.y = y;
    }

    // ... (other methods)
}

The level class is a specialized UI component used to represent level in our game. It extends UIComponent and includes the necessary instance variables, constructor, and methods for creating the UI component and handling its disposal.

Usage

To use the Navigation component and its associated classes in your game, follow these steps:

  1. Instantiate the Navigation class by providing a TerrainFactory and the image path for the navigation area.
  2. In the create method of the Navigation class, configure the UI elements representing planets or locations. Add listeners to these elements to define navigation logic when they are interacted with.
  3. Customize the level class or create similar components for other game levels or areas, specifying the image, coordinates, and interaction behavior.
  4. Incorporate the Navigation component into your game's main logic or state machine to enable navigation between different areas.

Code Examples

Here are code snippets for the key classes in the Navigation component: Navigation Class

// ... (import statements)

public class Navigation extends GameArea {
    // ... (class definition)

    // Constructor
    public Navigation(TerrainFactory terrainFactory, String image) {
        // ... (constructor code)
    }

    @Override
    public void create() {
        // ... (create method code)
    }

    // ... (other methods)
}

Level Component

// ... (import statements)

public class level3 extends UIComponent {
    // ... (class definition)

    // Constructor
    public level3(String PlanetImage, float x, float y) {
        // ... (constructor code)
    }

    @Override
    public void create() {
        // ... (create method code)
    }

    // ... (other methods)
}

These code examples provide a starting point for understanding how to use the Navigation component and its associated classes.

Clone this wiki locally