Skip to content

Implementation

Syed Muhammad Zahir edited this page Oct 3, 2022 · 14 revisions

Description

This page explains the implementation of the guidebook. This means the creation of the new java classes that implement the page and link the buttons to other pages. The layout of the page and the importing of data.

Classes

New classes were made to implement the guidebook's new page. Classes that were added were GuidebookActions, GuidebookDisplay, GuidebookScreen and GuidebookExit.

The connection between these classes can be seen in the UML below.

Diagram Guidebook

A sequence diagram is shown below to illustrate how the JSON file and content are updated.

Sequence Diagram guidebook

A more detailed explanation is below.

JSON

A JSON file was created to fill the content of the Guidebook. We chose a JSON file type because it has an easy maintainability feature; if we want to add new things to the Guidebook, we can easily add the contents here without having to change the code that has been written. We separated the JSON into three parts.

[
  {
    "pageNumber" = ...,
    "header" = ...,
    "content" = ...,
    "image" = ...,
    "imagePosition" = ...
  },
  ...
]

The header corresponds to the topics that are covered specifically by the respective section, with content being the actual content displayed on the page. The image and imagePosition sections (which can be the empty string "" [if one is, then the other must be too]). Below is a glimpse of the JSON file for the Guidebook. Please click this link to see the full JSON file.

[
  {
    "pageNumber": 0,
    "header": "Table of Contents",
    "content": "Page 1 - How to Play \nPage 2 - Crystal \nPage 3 - Main Character \nPage 4 - Day and Night Cycles \nPage 5 - Enemies \nPage 7 - Types of Buildings \nPage 9 - Resource Buildings \nPage 10 - Currency \nPage 11 - Shop \nPage 13 - Inventory \nPage 14 - Achievements",
    "image": "",
    "imagePosition": ""
  },
...
]

Please note that the number of pages in the JSON file must be even (even if there are empty pages) in order for the guidebook to be displayed and not break the game. And empty page can be created by making all the fields - as an entry of a page in the JSON file - an empty string. Additionally, a page with an empty header will not produce a title and title frame for that page. If the "image" and imagePosition are left as empty strings then no image will be loaded on the screen. The imagePosition controls the layout of the image on the screen. Currently, "UP" and "DOWN" - as the only valid values when parsed - position the image above and below the content respectively. Refer to the image below in Figure 1 to see what this means in practice.

image Figure 1: Guidebook with left page having no header and content while right page having both

Animation

Animation was achieved first by the creation of assets for each animation step. In summary, 5 unique assets were created, which can be seen below in Figure 2.

image Figure 2: Top-left - closed, top-middle - opening, top-right - open, bottom-left - flipping to previous page, bottom-right - flipping to next page

Youtube Videos for Implementation

Entry to Guidebook Feature

Guidebook Content Responsiveness

Table of Contents

Home

How to Play

Introduction

Game Features

Main Character

Enemies
The Final Boss

Landscape Objects

Shop
Inventory
Achievements
Camera

Crystal

Infrastructure

Audio

User Interfaces Across All Pages
Juicy UI
User Interfaces Buildings
Guidebook
[Resource Management](Resource-Management)
Map
Day and Night Cycle
Unified Grid System (UGS)
Polishing

Game Engine

Getting Started

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