Skip to content
Open

Temp #53

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
8c5a106
GitHub Classroom Feedback
github-classroom[bot] Mar 21, 2024
23cd6d1
Setting up GitHub Classroom Feedback
github-classroom[bot] Mar 21, 2024
fd9c2b8
Update egdd.md
Larry-Collins1 Mar 21, 2024
f924ce6
Update egdd2.md
Larry-Collins1 Mar 21, 2024
f6fde4e
pre-alpha commit
Larry-Collins1 Apr 4, 2024
0c5bf8b
created some of the class for a character
Vicbrill44 Apr 5, 2024
46d478e
Merge pull request #2 from UD-S24-CISC374/characterSkeleton1
Vicbrill44 Apr 5, 2024
644182c
forgot to import
Vicbrill44 Apr 5, 2024
ac2613b
Merge pull request #3 from UD-S24-CISC374/characterSkeleton1
Vicbrill44 Apr 5, 2024
a2c135b
Update characterSkeleton.ts
Vicbrill44 Apr 5, 2024
a99e1f3
Merge pull request #4 from UD-S24-CISC374/characterSkeleton1
Vicbrill44 Apr 5, 2024
8bb9c5e
alpha build
Larry-Collins1 Apr 12, 2024
ac4883e
random grunt spawn
Larry-Collins1 Apr 14, 2024
3908fc1
main functionality of characters and their interactions
Vicbrill44 Apr 17, 2024
98a3569
Merge pull request #5 from UD-S24-CISC374/characterSkelly
Vicbrill44 Apr 17, 2024
bcbb26a
implemented new characters and made some more strucural changes to ho…
Vicbrill44 Apr 18, 2024
6c6d106
Merge pull request #6 from UD-S24-CISC374/charactersBuilt
Vicbrill44 Apr 18, 2024
407d78c
sum stuff
Larry-Collins1 Apr 30, 2024
990ac8a
unfinished command line, title screen (in wrong place)
Larry-Collins1 May 1, 2024
4910f12
fixed title screen
Vicbrill44 May 2, 2024
5a265f7
board in progress
Vicbrill44 May 2, 2024
9d7eca9
Merge pull request #7 from UD-S24-CISC374/charactersBuilt
Vicbrill44 May 2, 2024
9b6f5bc
health bar
Vicbrill44 May 2, 2024
8287cf8
Merge pull request #8 from UD-S24-CISC374/charactersBuilt
Vicbrill44 May 2, 2024
9a13680
working buttons
Larry-Collins1 May 2, 2024
f4dbc72
Merge branch 'main' of https://github.com/UD-S24-CISC374/final-projec…
Larry-Collins1 May 2, 2024
2a4e009
cleaned up map and board
Vicbrill44 May 6, 2024
b55b333
started working on economy stuff
Vicbrill44 May 6, 2024
6c66cb8
added command line stuff
Vicbrill44 May 7, 2024
5cfbde4
progressing on terminal
Vicbrill44 May 7, 2024
0a1ab0c
Merge branch 'main' into charactersBuilt
Vicbrill44 May 7, 2024
8ecadae
Merge pull request #9 from UD-S24-CISC374/charactersBuilt
Vicbrill44 May 7, 2024
57e5a1f
Revert "Characters built"
Vicbrill44 May 7, 2024
98ff7ee
Merge pull request #10 from UD-S24-CISC374/revert-9-charactersBuilt
Vicbrill44 May 7, 2024
af1e228
Update mainScene.ts
Vicbrill44 May 7, 2024
fa09cf1
Merge branch 'main' into charactersBuilt
Vicbrill44 May 7, 2024
4c50629
Merge pull request #11 from UD-S24-CISC374/charactersBuilt
Vicbrill44 May 7, 2024
e92c3ff
Revert "Update mainScene.ts"
Vicbrill44 May 7, 2024
510d109
Merge pull request #12 from UD-S24-CISC374/revert-11-charactersBuilt
Vicbrill44 May 7, 2024
b6a4cfd
Update RangerChar.ts
Vicbrill44 May 7, 2024
d491a3d
Update SoldierChar.ts
Vicbrill44 May 7, 2024
37003c9
Update WizardChar.ts
Vicbrill44 May 7, 2024
5c33ab6
Update ZombieChar.ts
Vicbrill44 May 7, 2024
3e7a31d
Update board.ts
Vicbrill44 May 7, 2024
bea2e52
Create commandLine.ts
Vicbrill44 May 7, 2024
f4702e0
Create folderSystem.ts
Vicbrill44 May 7, 2024
de29e26
Update GameCharacter.ts
Vicbrill44 May 7, 2024
d68daa0
Update mainScene.ts
Vicbrill44 May 7, 2024
02b6927
Update preloadScene.ts
Vicbrill44 May 7, 2024
bb7dd14
Add files via upload
Vicbrill44 May 7, 2024
6ae6f30
Update README.md
Larry-Collins1 May 14, 2024
b171061
Update README.md
Larry-Collins1 May 14, 2024
cb09540
implemented waves
Vicbrill44 May 14, 2024
5e11f72
cleaned up the directories
Vicbrill44 May 14, 2024
2a50048
Merge pull request #14 from UD-S24-CISC374/commandLineFix
Vicbrill44 May 14, 2024
12b7604
bunch of stuff
Larry-Collins1 May 14, 2024
be8464b
music, conditions, tutorial
Larry-Collins1 May 14, 2024
2ef8167
Update README.md
Larry-Collins1 May 15, 2024
786937d
Update tutorialScene.ts
Larry-Collins1 May 15, 2024
c296c49
Update README.md
Larry-Collins1 May 16, 2024
0a16ff5
startwave command fully working
Vicbrill44 May 16, 2024
95e8224
Merge pull request #15 from UD-S24-CISC374/gameLike
Vicbrill44 May 16, 2024
3f57d0f
created new commands and folder dir and files
Vicbrill44 May 16, 2024
f192b14
added grid positions
Vicbrill44 May 16, 2024
b12975c
Merge pull request #16 from UD-S24-CISC374/gameLike
Vicbrill44 May 16, 2024
05a91f0
some changes
Larry-Collins1 May 16, 2024
95fa158
tutorial scene running
Vicbrill44 May 16, 2024
4c1af89
Merge pull request #17 from UD-S24-CISC374/newBaddy
Vicbrill44 May 16, 2024
3ca19dc
img updates
Larry-Collins1 May 16, 2024
d424f68
test
Larry-Collins1 May 16, 2024
799f9ef
Merge branch 'main' into temp
Larry-Collins1 May 16, 2024
273e28e
updates
Larry-Collins1 May 16, 2024
b57d290
Merge branch 'temp' of https://github.com/UD-S24-CISC374/final-projec…
Larry-Collins1 May 16, 2024
ba1dfae
Merge branch 'main' into temp
Larry-Collins1 May 16, 2024
fac0f68
yes
Larry-Collins1 May 16, 2024
dba6716
Merge branch 'temp' of https://github.com/UD-S24-CISC374/final-projec…
Larry-Collins1 May 16, 2024
ac0ead0
again
Larry-Collins1 May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .github/.keep
Empty file.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Game Name

Terminal Tactics

# Team Color

Olive

# Developers

Lawrence Collins (larryc@udel.edu)
Victor Vasquez (vicvas@udel.edu)

# Blurb

In "Terminal Tactics," players face a zombie onslaught using strategic Unix commands as their arsenal. Mimicking the tower defense genre, players must strategically arrange their troops in the correct sequence to repel the zombie invasion. Just like in "Plants vs. Zombies," each command possesses unique attributes, from defensive capabilities to offensive strikes, requiring players to think tactically to outsmart the undead hordes. This educational twist not only challenges players' gaming skills but also enhances their understanding of Unix commands, making "Terminal Tactics" an engaging fusion of entertainment and education in the battle against the undead.

# Basic Instructions

Type into the command line to find your troops (cd, ls, etc.)
=======
TEXT GOES HERE

# Team Color
Expand Down Expand Up @@ -29,6 +48,16 @@ TEXT GOES HERE
TEXT GOES HERE

# Educational Game Design Document
(https://github.com/UD-S24-CISC374/final-project-olive/blob/main/docs/egdd.md)
# Credits

GitHub: Ideas and some code
Phaser Forums: Ideas and some code
Pixabay: Music
ChatGPT
Microsoft Designer AI Image Creator

=======

Link to our [egdd](Educational Game Design Document)

Expand Down
Binary file added assets/audio/backgroundMusic.mp3
Binary file not shown.
Binary file added assets/audio/defeatMusic.mp3
Binary file not shown.
Binary file added assets/audio/endGameMusic.mp3
Binary file not shown.
Binary file added assets/audio/titleScreenMusic.mp3
Binary file not shown.
Binary file added assets/audio/tutorialMusic.mp3
Binary file not shown.
Binary file added assets/audio/victoryMusic.mp3
Binary file not shown.
Binary file added assets/img/arrow-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/book.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/button.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/dnd_titlescreen1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/dude.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/energy-ball-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/file.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/finishLine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/fire-ball-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/grass-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/grass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/left-trees.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/map1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/platform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/play_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/questionMark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/ranger-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/ranger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/right-trees.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/soldier-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/soldier.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/sword.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/titlePage.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/trainGrounds.png
Binary file added assets/img/tree.png
Binary file added assets/img/tutorial_icon.png
Binary file added assets/img/wizard-small.png
Binary file added assets/img/wizard.png
Binary file added assets/img/wizardNPC.jpg
Binary file added assets/img/youLose.jpeg
Binary file added assets/img/youWin.jpeg
Binary file added assets/img/zombie-small.png
Binary file added assets/img/zombie.png
182 changes: 181 additions & 1 deletion docs/egdd.md
Original file line number Diff line number Diff line change
@@ -1 +1,181 @@
REPLACE THIS TEXT WITH YOUR EGDD MARKDOWN.
# Alliance vs The Council


## Elevator Pitch

A tower defense game where the user must survive an onslaught of creatures by placing towers using Unix commands


## Influences (Brief)

- *Plants Vs Zombies*:
- Medium: *Video Game*
- Explanation: *This game is a major influence on what we are creating. As we are taking this idea and expanding it. We are utilizing the idea of a board-based tower defense game and modifying it by forcing the player to use Unix commands to move around.*
- *CISC210*:
- Medium: *UD Course*
- Explanation: *CISC201 is a UD course where we learned basic terminal commands to be able to gain a better understanding of UNIX. By modeling our game based on some of the material we learned we can gain a better understanding of how to make the game educational.*
- *DnD / Baulders Gate*:
- Medium: *Game*
- Explanation: *We are using the fantasy aspect of DnD to change around the allies and enemies. This influence has a large variety of small and large-scale enemies for us to use to make the game more interesting to look at. This also works for the placeable allies as we can use the various classes as stackable/movable/combinable characters.*

## Core Gameplay Mechanics (Brief)

*Give a very high-level description of any core gameplay mechanics*

- *Health*
- *Battle Phases (Buying phase and monster wave phase)*
- *Level progression*
- *Currency*

# Learning Aspects


## Learning Domains

*Unix Commands*

## Target Audiences

Middle School to high school-aged kids new to Unix commands

## Target Contexts

*This would be used within a lesson plan of a *

## Learning Objectives

*Remember, Learning Objectives are NOT simply topics. They are statements of observable behavior that a learner can do after the learning experience. You cannot observe someone "understanding" or "knowing" something.*

- *Unix Commands*: *By the end of instruction, students will be able to identify common Unix commands and describe their effects.*
- *Unix Complexity*: *Students should be able to combine unix commands to do more complex tasks.*

## Prerequisite Knowledge

*What do they need to know prior to trying this game?*

- *An idea of what Unix commands are*
- *Why they would use Unix commands*

## Assessment Measures

*Given a preexisting directory and be able to traverse and modify it with little to no help*


# What sets this project apart?

*Give some reasons why this game is not like every other game out there. Whether the learning objective is unique, the gameplay mechanics are new, or what. You should persuade the reader that your game is novel and worthy of development. Consider arguments that would be persuasive to a Venture Capitalist, Teacher, or Researcher. These might be focused on learning needs, too.*

- *It is unique*
- *Educational while still being fun*
- *Most coding or systems-based assignments are the same or throw you in headfirst. This will visualize the learning curve and shorten said curve*

# Player Interaction Patterns and Modes

## Player Interaction Pattern

*People will play our game using keyboard and mouse on a browser. There will only be one player involved at once.*

## Player Modes

*Your game has one or more player modes. Describe each discrete mode, considering things like menus too. Generally describe the transitions between modes too.*

- *Single Player Mode*: *A player will be able to access a folder menu that allows them to understand all of the different characters available, different abilities offered in the game, what level you are on, etc.*
- *Battle Board Menu*: *This menu is where *
- *etc.*

# Gameplay Objectives

- *Protect the castle*:
- Description: *The player must place allies to protect against the waves of enemies *
- Alignment: *This aligns with learning how to adapt and work under pressure*
- *Navigate the “Book”*:
- Description: *The player must use Unix commands to navigate the “Book” to pick out their allies*
- Alignment: *This follows the learning objective of learning Unix commands*

# Procedures/Actions

*The player will type Unix commands (turning the pages) to place allies to protect the castle *

# Rules

If the player types in an incorrect or currently unknown Unix command the book will flash red
*What resources are available to the player that they make use of? How does this affect gameplay? How are these resources finite?*

# Objects/Entities

*We will have to design the board and some sort of terminal implementation*

## Core Gameplay Mechanics (Detailed)

- *Zombie Wave Defense*: *The game challenges players with progressively tougher waves of “zombies.” The idea is a “zombie” wave of defense. The different types of zombies require the player to adapt their strategy by choosing different plants and placements of those plants to handle the wave of zombies. The idea is that players should anticipate and plan out their defense to beat the wave. *
- *Plant Placement and Resource Management:*: *Strategically placing different types of “plants” on the board to defend against the wave of zombies trying to get past your defense. Each plant has unique abilities that are good for defending against certain zombies or waves of zombies. Players must manage their resources to strategically have good defense throughout their progression. Deciding which plants to place before each wave is a core mechanic of the game. *
- *Progression and Unlocking New Plants*: *As you progress in the game you will unlock new plants/characters that will aid you in defeating the waves of zombies. The progression mechanic will encourage users to create new strategies and find different ways to defeat the waves of zombies. *


## Feedback

*Explicitly describe what visual/audio/animation indicators there are that give players feedback on their progress towards their gameplay objectives (and ideally the learning objectives): A player will know how they are doing in terms of their learning objective because they will have to use UNIX commands to progress in the game. The further they make it into the game the more “reps” they will have with UNIX command built into the game. The more they play the more the commands are being reinforced into their brain.*

*Describe what longer-term feedback you detect and give that guides the player in their learning and lets them know how they are doing in regard to the learning objectives: The player will know how they are doing in regard to the learning objectives when they are seamlessly navigating our commands. This will help the player translate their learned understanding into a real Linux environment.*

# Story and Gameplay

## Presentation of Rules

*The player will learn the game mechanics by being presented with a tutorial (level 0) which allows them to experiment with the game and its mechanics. They will also be introduced to a cheat sheet which will help them understand the built-in UNIX-like commands that they will need to use in the game.*

## Presentation of Content

*Briefly describe how the player will be taught the core material they are meant to learn: The player will be taught the core material by being forced to use UNIX-like commands that will help them familiarize themselves with real UNIX commands and other concepts related to the topic. *

## Story (Brief)

*The Summary or TL;DR version of below*

## Storyboarding

*Go into as much detail as needs be to visually convey the Dynamics of your game. Be detailed. Create storyboards and freeze frame images that concisely capture important key elements of your game. You are strongly recommended to sketch pictures on paper and embed them here. Be sure make it clear how previously-described mechanics come through in the dynamics.*

# Assets Needed

## Aethestics

*Give a sense of the aesthetics of your game, the spirit and atmosphere: In this game, gardens are transformed into battlefields where magical plants, inspired by D&D characters, defend against a zombie invasion. The setting mixes a touch of fantasy with light-hearted horror, creating a unique backdrop for strategy and action. It's a straightforward yet engaging world where players navigate through challenges with strategy and a bit of humor.*

## Graphical

- Characters List
- *Mage character*
- *Wizard Character*
- *Zombies Characters*
- Textures:
- *Dungeon textures*
- *Zombie Textures*
- *...*
- Environment Art/Textures:
- *DnD like battlefields*


## Audio


*Game region/phase/time are ways of designating a particularly important place in the game.*

- Music List (Ambient sound)
- *Zombie Phase*: *Dark advancing music*
- *Buying Phase*: *Relax ambient music*
*Game Interactions are things that trigger SFX, like character movement, hitting a spiky enemy, collecting a coin.*

- Sound List (SFX)
- *Hitting a zombie*: *OOF sound*, *hurt sounds*
- *Buying a character*: *satisfaction sound*
- *Placing a character*: *satisfaction sound*
- *Correct UNIX-like command*: *satisfaction sound*


# Metadata

* Template created by Austin Cory Bart <acbart@udel.edu>, Mark Sheriff, Alec Markarian, and Benjamin Stanley.
* Version 0.0.3


4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Phaser from "phaser";
import MainScene from "./scenes/mainScene";
import PreloadScene from "./scenes/preloadScene";
import TitleScene from "./scenes/titleScene";
import TutorialScene from "./scenes/tutorialScene";

const DEFAULT_WIDTH = 1280;
const DEFAULT_HEIGHT = 720;
Expand All @@ -17,12 +19,12 @@ export const CONFIG = {
width: DEFAULT_WIDTH,
height: DEFAULT_HEIGHT,
},
scene: [PreloadScene, MainScene],
scene: [PreloadScene, TitleScene, MainScene, TutorialScene],
physics: {
default: "arcade",
arcade: {
debug: false,
gravity: { y: 300 },
gravity: { y: 0 },
},
},
input: {
Expand Down
6 changes: 6 additions & 0 deletions src/interfaces/directories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Phaser from "phaser";

export interface Directories {
curDir: string | undefined;
dialogue: Phaser.GameObjects.Text | undefined;
}
7 changes: 7 additions & 0 deletions src/interfaces/terminalCommandInterface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Phaser from "phaser";

export interface terminalCommandInterface {
text: string;
curDir: string;
consoleDialogue?: Phaser.GameObjects.Text;
}
58 changes: 58 additions & 0 deletions src/objects/CharacterManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import Phaser from "phaser";
import { GameCharacter } from "./GameCharacter";

export class CharacterManager {
characters = new Set<Phaser.GameObjects.GameObject>();

addCharacter(character: Phaser.GameObjects.GameObject) {
this.characters.add(character);
}

sameCoord(x: number, y: number): boolean {
const foundCharacter = Array.from(this.characters).find((character) => {
const gameChar = character as GameCharacter;
return gameChar.x === x && gameChar.y === y;
});
if (foundCharacter) {
return true;
}

return false;
}

removeCharacter(character: Phaser.GameObjects.GameObject) {
character.destroy();
this.characters.delete(character);
}
removeCharacterByNameAndPosition(
name: string,
x: number,
y: number
): boolean {
const characterToRemove = Array.from(this.characters).find(
(character) => {
const gameChar = character as GameCharacter;
return (
gameChar.name === name &&
gameChar.x === x &&
gameChar.y === y
);
}
);

if (characterToRemove) {
this.removeCharacter(characterToRemove);
return true;
}

return false;
}

update() {
this.characters.forEach((character) => {
if ("update" in character) {
(character as GameCharacter).update();
}
});
}
}
50 changes: 50 additions & 0 deletions src/objects/GameCharacter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import Phaser from "phaser";
import MainScene from "../scenes/mainScene";

export abstract class GameCharacter extends Phaser.Physics.Arcade.Sprite {
name: string;
health: number;
position: Phaser.Math.Vector2;
alive: boolean;
cost: number;
dmg: number;

constructor(
scene: Phaser.Scene,
name: string,
health: number,
x: number,
y: number,
texture: string,
cost: number,
dmg: number
) {
super(scene, x, y, texture); // Call the super constructor with necessary parameters
this.scene.add.existing(this); // Add this sprite to the scene
this.name = name;
this.health = health;
this.position = new Phaser.Math.Vector2(x, y);
this.alive = true;
this.cost = cost;
scene.physics.add.existing(this);
this.setOrigin(0.5, 0.5); // Set the origin of the sprite
this.dmg = dmg;
}

abstract attack(): void;

// Method for the character to take damage. Reduces health and checks for death.
takeDamage(damage: number): void {
this.health -= damage;
if (this.health <= 0) {
this.alive = false;
(this.scene as MainScene).characterManager.removeCharacter(this);
}
}

// Method to remove the character from the game, e.g., when health is 0.
remove(): void {
this.destroy(); // Just destroy this sprite
console.log(`${this.name} has been removed from the game.`);
}
}
Loading