Skip to content

Liaksej/ajs-diplom

Repository files navigation

Retro Game 2D for desktop browser

Build status

Game concept

A two-dimensional fantasy game where the player has to pit their characters vs. characters of the undead. Each round restores the lives of the surviving characters. of the player's surviving characters and level up. The maximum level is 4.

The game can be saved and restored from a save.

File structure

Key Entities:

  1. GamePlay - class responsible for interaction with HTML-page
  2. GameController - class responsible for the application logic
  3. Character - base class from which characters are inherited
  4. GameState - object that stores the current state of the game (can recreate itself from another object)
  5. GameStateService - object that interacts with the current state (saves data to localStorage for later loading)
  6. PositionedCharacter - Character bound to a coordinate on the field
  7. Team - a class for a team (a set of characters) representing the computer and the player
  8. generators - module containing auxiliary functions for generating team and characters

1. Game levels

There are 4 levels in the game:

  • Level 1: prairie
  • Level 2: desert
  • Level 3: arctic
  • Level 4: mountain

2. Character Features

Player characters

  1. Bowman
  2. Swordsman
  3. Magician

Rival characters

  1. Vampire
  2. Undead
  3. Daemon

Initial characteristics of the characters

Class attack defence
Bowman 25 25
Swordsman 40 10
Magician 10 40
Vampire 25 25
Undead 40 10
Daemon 10 10

3. Displaying character information

When you move the cursor over a character, information about that character appears.

4. Player's turn

  1. If we are going to select another character, the field is not highlighted and the cursor takes the shape of pointer:

  2. If we are going to move to another cell (within the allowed transitions), the field is highlighted green, the cursor takes the form of pointer:

  3. If we are going to attack the enemy (within the allowed attack radius), the field is highlighted in red, the cursor takes the shape of crosshair:

  4. If we are about to perform an invalid action, the cursor takes the form of notallowed (in this case an error message is also displayed when clicking):

5. Character attack and movement features

The direction of movement is similar to the queen in chess. Characters of different types can walk different distances (in the basic version you can jump over other characters, i.e. like a horse in chess, the only rule is that you have to go in straight lines and diagonally):

  • Swordsmans/Undeads - 4 squares in any direction
  • Лучники/Vampires - 2 клетки в любом направлении
  • Magicians/Демоны - 1 клетка в любом направлении

Дальность атаки тоже ограничена:

  • Мечники/Скелеты - can only attack a neighboring cell
  • Bowmans/Вампиры - for the next two squares
  • Маги/Daemons - for the next four squares

Cells are counted "by radius", let's say for a swordsman the attack zone will look like this:

For the archer (marked in red):

6. Character level up

  1. When moving to a new level, the health indicator is brought to the value: current level + 80 (but not more than 100).

    That is, if character 1 had a life level of 10 after the end of the round, and character 2 had a life level of 80, after level up:

    • character 1 - life becomes 90
    • character 2 - life will become 100
  2. Attack/defense increases are tied to remaining life by a formula:

    attackAfter = Math.max(attackBefore, attackBefore * (80 + life) / 100), i.e. if a character has 50% life left after the end of a round, his stats will improve by 30%. If the character has 1% life left, his stats will not increase in any way.

7. Game Over, New Game and Statistics

After the game is over (player loses) or all 4 levels are completed, the playing field is blocked (i.e. does not react to events occurring on it).

When you click on the New Game button, a new game starts.

The game score is displayed above the buttons and reflects the points earned by the player and the computer during the game.

8. Storing game state, saving and loading a saved game.

You can save the game by clicking on the Save Game button. The game will be saved at the level and state at which the save was invoked.

You can load a saved game by pressing the Load Game button. The game will open at the level and state at which it was saved.

The state is stored in a byte type in localstorage and restored from it on boot.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published