-
Notifications
You must be signed in to change notification settings - Fork 4
Game flow
This game consists of multiple screens. This wiki page is to help and keep track of the flow of screens.
- Main Menu
- Help Screen
- Settings Screen
- Story Screen
- Level Select Screen
- Turret Select Screen
- Main Game Screen
- Main Game Lose
- Main Game Exit
The "Main Menu Screen" serves as the initial screen when the game is launched. It provides options for starting the game, accessing help, adjusting settings, and exiting the game. UI Elements:
-
Start Button: Clicking the "Start" button triggers the "start" event.
-
Help Button: Clicking the "Help" button triggers the "help" event.
-
Settings Button: Clicking the "Settings" button triggers the "settings" event.
-
Exit Button: Clicking the "Exit" button triggers the "exit" event.
Transition Results:
-
Start Button Clicked: Transitions to the "Story Screen" (GdxGame.ScreenType.STORY_SCREEN).
-
Help Button Clicked: Transitions to the "Help Screen" (GdxGame.ScreenType.HELP_SCREEN).
-
Settings Button Clicked: Transitions to the "Settings Screen" (GdxGame.ScreenType.SETTINGS).
-
Exit Button Clicked: Exits the game.
Code Snippet (Main Menu Screen):
public class MainMenuScreen extends ScreenAdapter {
// ... (Initialization and other code)
@Override
public void show() {
// Create UI buttons and add listeners
Skin skin = new Skin(Gdx.files.internal("flat-earth/skin/flat-earth-ui.json"));
TextButton startButton = new TextButton("Start", skin);
TextButton helpButton = new TextButton("Help", skin);
TextButton settingsButton = new TextButton("Settings", skin);
TextButton exitButton = new TextButton("Exit", skin);
startButton.addListener(new ClickListener() {
@Override
public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) {
// Handle start button click
game.setScreen(GdxGame.ScreenType.STORY_SCREEN);
}
});
// Add buttons to the stage
// ...
}
// ...
The "Help Screen" provides players with information, instructions, or tutorials related to the game. It serves to guide players on how to play and understand the game mechanics.
UI Elements: Back Button: Clicking the "Back" button triggers the "back" event.
Transition Results: Back Button Clicked: Returns to the "Main Menu Screen" (GdxGame.ScreenType.MAIN_MENU).
Code Snippet (Help Screen):
// Sample code for the Help Screen
public class HelpScreen extends ScreenAdapter {
// ... (Initialization and other code)
@Override
public void show() {
// Create UI elements for displaying help content
// ...
// Create and configure the "Back" button
Skin skin = new Skin(Gdx.files.internal("flat-earth/skin/flat-earth-ui.json"));
TextButton backButton = new TextButton("Back", skin);
// Add a listener to handle button click
backButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
// Handle back button click
game.setScreen(GdxGame.ScreenType.MAIN_MENU); // Return to the main menu
}
});
// Add UI elements and the back button to the stage
// ...
}
// ...
}
The "Settings Screen" allows players to configure game settings such as graphics options, sound settings, or controls customization.
UI Elements:
- Apply Button: Clicking the "Apply" button triggers the "applyChanges" event.
- Exit Button: Clicking the "Exit" button triggers the "exitMenu" event.
Transition Results:
- Apply Button Clicked: Applies the changes made in the settings (e.g., FPS cap, fullscreen mode) and saves them. No screen transition occurs.
- Exit Button Clicked: Exits the settings menu and returns to the "Main Menu Screen" (GdxGame.ScreenType.MAIN_MENU).
Code Snippet (Settings Screen):
// Sample code for the Settings Screen
public class SettingsScreen extends ScreenAdapter {
// ... (Initialization and other code)
@Override
public void show() {
// Create UI elements for displaying and configuring settings
// ...
// Create and configure the "Apply" button
Skin skin = new Skin(Gdx.files.internal("flat-earth/skin/flat-earth-ui.json"));
TextButton applyButton = new TextButton("Apply", skin);
TextButton exitButton = new TextButton("Exit", skin);
// Add a listener to handle "Apply" button click
applyButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
// Handle apply button click and save settings
// ...
}
});
// Add a listener to handle "Exit" button click
exitButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
// Handle exit button click
game.setScreen(GdxGame.ScreenType.MAIN_MENU); // Return to the main menu
}
});
// Add UI elements, apply button, and exit button to the stage
// ...
}
// ...
}
The "Story Screen" displays a narrative with images and text. It serves to introduce the game's backstory and set the stage for gameplay.
UI Elements:
- Continue Button: Clicking the "Continue" button triggers the "next" event.
- Skip Button: Clicking the "Skip" button triggers the "next" event.
Transition Results:
- Continue Button Clicked: Advances to the next image and text in the story. If the story is completed, transitions to the "Level Select Screen" (GdxGame.ScreenType.LEVEL_SELECT).
- Skip Button Clicked: Skips the entire story and transitions to the "Level Select Screen" (GdxGame.ScreenType.LEVEL_SELECT) immediately if the story is not completed.
Code Snippet (Story Screen):
// Sample code for the Story Screen
public class StoryScreen extends ScreenAdapter {
// ... (Initialization and other code)
@Override
public void show() {
// Create UI buttons and add listeners
Skin skin = new Skin(Gdx.files.internal("flat-earth/skin/flat-earth-ui.json"));
TextButton continueButton = new TextButton("Continue", skin);
TextButton skipButton = new TextButton("Skip", skin);
continueButton.addListener(new ClickListener() {
@Override
public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) {
// Handle continue button click
next();
}
});
skipButton.addListener(new ClickListener() {
@Override
public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) {
// Handle skip button click
currentIndex = images.length; // Skip to the end
next();
}
});
// Add buttons to the stage
// ...
}
// ...
}
The "Level Select Screen" allows players to choose from available levels or game modes before starting gameplay. It provides a selection of levels or planets to explore.
UI Elements: Level Buttons: Clicking a level button triggers the "selectLevel" event for the chosen level.
Transition Results: Level Button Clicked: Initiates the selected level or game mode based on the chosen level. Transitions to the main gameplay screen (GdxGame.ScreenType.MAIN_GAME).
Code Snippet (Level Select Screen):
// Sample code for the Level Select Screen
public class LevelSelectScreen extends ScreenAdapter {
// ... (Initialization and other code)
@Override
public void show() {
// Create level selection buttons and add listeners
Skin skin = new Skin(Gdx.files.internal("flat-earth/skin/flat-earth-ui.json"));
TextButton level1Button = new TextButton("Level 1", skin);
TextButton level2Button = new TextButton("Level 2", skin);
// Add more level buttons as needed
level1Button.addListener(new ClickListener() {
@Override
public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) {
// Handle level 1 button click
game.setLevel(1); // Set the selected level
game.setScreen(GdxGame.ScreenType.MAIN_GAME); // Transition to main gameplay
}
});
// Add buttons to the stage
// ...
}
// ...
}
The "Turret Selection Screen" allows players to choose and configure turrets or weapons before starting a level. It is essential for customizing the player's strategy and defenses.
UI Elements:
- Turret Selection Grid: Displays available turrets or weapons for selection.
- Confirm Button: Clicking the "Confirm" button triggers the "confirmSelection" event.
Transition Results:
- Confirm Button Clicked: Confirms the selected turrets/weapons and transitions to the "Main Game Screen" (GdxGame.ScreenType.MAIN_GAME) to start the level.
Code Snippet (Turret Selection Screen):
// Sample code for the Turret Selection Screen
public class TurretSelectionScreen extends ScreenAdapter {
// ... (Initialization and other code)
@Override
public void show() {
// Create UI elements for turret selection and configuration
// ...
// Create and configure the "Confirm" button
Skin skin = new Skin(Gdx.files.internal("flat-earth/skin/flat-earth-ui.json"));
TextButton confirmButton = new TextButton("Confirm", skin);
// Add a listener to handle "Confirm" button click
confirmButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
// Handle confirm button click and start the game with selected turrets
// ...
}
});
// Add UI elements, turret selection grid, and the confirm button to the stage
// ...
}
// ...
}
The "Main Game Screen" is the core gameplay screen where players interact with the game world. It includes elements like the game area, entities, and user interfaces.
UI Elements: Exit Button: Clicking the "Quit" button in the "MainGameExitDisplay" triggers the "exit" event.
Transition Results: Exit Button Clicked: Exits the main game screen and returns to the "Main Menu Screen" (GdxGame.ScreenType.MAIN_MENU).
Code Snippet (Main Game Screen):
// Sample code for the Main Game Screen
public class MainGameScreen extends ScreenAdapter {
// ... (Initialization and other code)
@Override
public void render(float delta) {
// Clear the screen and render background
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
// Render the game world and entities
// ...
}
// ...
}
The "MainGameLoseDisplay" component displays a "Lose" button in the main game screen. Clicking this button triggers the "lose" event to handle game over scenarios.
UI Elements: Lose Button: A "Lose" button is displayed in the main game screen.
Functionality: When the "Lose" button is clicked, it triggers the "lose" event, allowing for custom game over actions or transitions.
Code Snippet (MainGameLoseDisplay Component):
// Sample code for the MainGameLoseDisplay Component
public class MainGameLoseDisplay extends UIComponent {
// ... (Initialization and other code)
@Override
public void create() {
super.create();
addActors(); // Add UI components
}
private void addActors() {
// Create and configure the "Lose" button
Skin skin = new Skin(Gdx.files.internal("flat-earth/skin/flat-earth-ui.json"));
TextButton loseButton = new TextButton("Lose", skin);
// Add a listener to handle button click
loseButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
// Handle lose button click
entity.getEvents().trigger("lose");
}
});
// Add the button to the stage
stage.addActor(loseButton);
}
// ...
}
The "MainGameExitDisplay" component is responsible for displaying a "Quit" button in the main game screen. Clicking this button triggers the "exit" event to return to the main menu.
UI Elements: Quit Button: A "Quit" button is displayed in the main game screen.
Functionality: When the "Quit" button is clicked, it triggers the "exit" event, facilitating the transition back to the "Main Menu Screen."
Code Snippet (MainGameExitDisplay Component):
// Sample code for the MainGameExitDisplay Component
public class MainGameExitDisplay extends UIComponent {
// ... (Initialization and other code)
@Override
public void create() {
super.create();
addActors(); // Add UI components
}
private void addActors() {
// Create and configure the "Quit" button
Skin skin = new Skin(Gdx.files.internal("flat-earth/skin/flat-earth-ui.json"));
TextButton quitButton = new TextButton("Quit", skin);
// Add a listener to handle button click
quitButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
// Handle quit button click
entity.getEvents().trigger("exit");
}
});
// Add the button to the stage
stage.addActor(quitButton);
}
// ...
}
```****