Skip to content

PlanetTravel Class

Shaivika Anand edited this page Oct 19, 2023 · 5 revisions

PlanetTravel Class

PlanetTravel is a class responsible for managing travel between planets and storing information about the current game state. It is part of the com.csse3200.game.services package and is used in the GdxGame project.

Table of Contents

Introduction

The PlanetTravel class is used in the context of a game to handle transitions between planets and to provide various travel-related functionalities. It is responsible for initiating gameplay transitions, updating the current planet, and managing game screens.

Constructor

PlanetTravel(GdxGame game)

  • Constructor to set the current game state for use.

Parameters

  • game: An instance of GdxGame, which represents the current game.

Public Methods

beginFullTravel()

  • Initiates a transition to the next planet with intermediate gameplay in between.

beginInstantTravel()

  • Travels from the current planet to the next planet instantly.

returnToCurrent()

  • Travels back to the currently loaded planet, resetting player and companion health.

moveToNextPlanet(Object planet)

  • Moves to the next planet and spawns the minigame screen.

Parameters

  • planet: The destination planet.

returnCurrent()

  • Returns the current planet where the player is located.

Usage

To use the PlanetTravel class, you should create an instance of it and call its methods according to your game's logic. The class provides methods for transitioning between planets and updating the game state.

UML

Screenshot 2023-10-19 at 2 25 20 AM

Example

// Example of using PlanetTravel
GdxGame game = new GdxGame();  // Replace with your actual game initialization
PlanetTravel planetTravel = new PlanetTravel(game);

// Initiating a full travel to the next planet
planetTravel.beginFullTravel();

// Traveling instantly to the next planet
planetTravel.beginInstantTravel();

// Returning to the currently loaded planet
planetTravel.returnToCurrent();

// Moving to the next planet and spawning the minigame screen
Object nextPlanet = "Mars";  // Replace with the actual planet object
planetTravel.moveToNextPlanet(nextPlanet);

// Retrieving the current planet
Object currentPlanet = planetTravel.returnCurrent();

Clone this wiki locally