Skip to content

Checkpoint Design and Functionality

sh4453 edited this page Sep 14, 2021 · 6 revisions

Checkpoint Design

The checkpoint was decided to be a rover, keeping in line with the space theme, but there are also Viking longship elements like the curving of the main body of the rover and the flag with a rune symbol on it. The coloring and style is all adhering to the minimalist 2D style we're going for.

First coloured draft

Rough attempt on Illustrator to create a generic rover

Finalised colored version

Edited to add more viking imagery, resembling a longship by the shape and a flag with a rune on it

Checkpoint Functionality

The checkpoint was designed to be easily implemented into future levels as its very modular and really only relies on the levels that the checkpoints will be on and the pop up menus. The main checkpoint was generated as an obstacle entity under the function createCheckpoint

public static Entity createCheckpoint(Entity target, ForestGameArea area) { Entity checkpoint = new Entity() .addComponent(new PhysicsComponent()) .addComponent(new PhysicsMovementComponent()) .addComponent(new ColliderComponent().setLayer(PhysicsLayer.NONE)) .addComponent(new HitboxComponent().setLayer(PhysicsLayer.NPC)) .addComponent(new CheckPointComponent(PhysicsLayer.PLAYER, area)) .addComponent(new TextureRenderComponent("images/untouchedCheckpoint.png"));

PhysicsUtils.setScaledCollider(checkpoint, 0.9f, 0.4f);
return checkpoint;

}

This function is in charge of creating the simple obstacle that the checkpoint will be appear like and its physical elements such as its hit box and colliusion layer. CheckPointComponent is a class component that is in charge of the logic of the checkpoint and will keep track of if the player collides with the checkpoint and then alert the game that this has occurred. This is the on collision logic of the CheckPointComponent that the checkpoint will use.

private void onCollisionStart(Fixture me, Fixture other) { if (hitboxComponent.getFixture() != me) { // Not triggered by hitbox, ignore return; }

    if (!PhysicsLayer.contains(targetLayer, other.getFilterData().categoryBits)) {
        // Doesn't match our target layer, ignore
        return;
    }

    // Try to attack target.
    Entity target = ((BodyUserData) other.getBody().getUserData()).entity;
    CombatStatsComponent targetStats = target.getComponent(CombatStatsComponent.class);
    if (targetStats != null) {
        area.setCheckPointStatus(1);
    }
}

This simple function will be in the areas that the checkpoints will be loaded into e.g. ForestGameArea simply replace the grid coordinates with the location the checkpoint will be spawned.

private void createCheckpoint() { GridPoint2 checkPoint = new GridPoint2(20, 10); Entity checkpoint = ObstacleFactory.createCheckpoint(player, this); spawnEntityAt(checkpoint, checkPoint, true, false); }

A check was added into the Popups such that it will do a simple check before reloading the main game to see if they will either spawn at the check point or at the start of the map. This check will only last as the player is with in the specific area. For example the memory of the player passing the check point is lost once they return to the main menu. Code for the pop ups such as the pause pup have been edited to all for this checkpoint mechanic such as the onReplay() this contains the logic:

public void onReplay() {

    if (area.getCheckPointStatus() == 1) {
        game.setScreen(GdxGame.ScreenType.CHECKPOINT);
    } else {
        game.setScreen(GdxGame.ScreenType.MAIN_GAME);
    }
}

The constructors also can now accept a parameter for the checkpoint being the ForestGameArea. This was designed like this as only one map is present but can be easily modified to accept different GameAreas. The onReplay() was also designed for the potential of multiple checkpoints but currently only works for one checkpoint.

Table of Contents

Home

Introduction

Main Menu

Main Game Screen

Gameplay

Player Movement

Character Animations

Enemy Monster Design and Animations

Game basic functionalities

User Testing

GitHub Wiki Tutorial

Game Engine

Getting Started

Documentation

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally