wokring in progres

This commit is contained in:
koneko 2024-12-24 16:36:09 +01:00
parent f089b7ac79
commit a14cca27ac
6 changed files with 100 additions and 13 deletions

View File

@ -1,7 +1,7 @@
[
{
"health": 2,
"speed": 0.25,
"speed": 0.04,
"special": null,
"resistance": {
"physical": 0,

View File

@ -3,7 +3,7 @@
"height": 4300,
"width": 2
},
"activeFile": "",
"activeFile": "Mission011.tmx",
"expandedProjectPaths": [
"."
],
@ -32,8 +32,17 @@
"y": 639.5548342221192
}
},
"Mission011.tmx": {
"scale": 0.5,
"selectedLayer": 0,
"viewCenter": {
"x": 1070,
"y": 448
}
},
"Tileset.tsx": {
"scaleInDock": 1
"scaleInDock": 0.5,
"scaleInEditor": 1
}
},
"last.externalTilesetPath": "/home/koneko/Programing/js/towerdefense/public",
@ -43,9 +52,13 @@
"map.tileWidth": 64,
"map.width": 30,
"openFiles": [
"Tileset.tsx",
"Mission011.tmx"
],
"project": "maps.tiled-project",
"recentFiles": [
"Tileset.tsx",
"Mission011.tmx",
"Mission01.tmx",
"/home/koneko/dumping/tiles/TiledTDThree64.tmx"
],

View File

@ -99,5 +99,5 @@ export default class GameAssets {
public static Missions: MissionDefinition[];
public static Towers: TowerDefinition[];
public static CreepStats: CreepStatsDefinition[];
public static DebuggingEnabled: boolean = true;
public static DebuggingEnabled: boolean = false;
}

View File

@ -59,7 +59,6 @@ export default class Creep extends GameObject {
const directionY = targetCell[0] - currentCell[0];
let deltaX = this.speed * elapsedMS * directionX;
let deltaY = this.speed * elapsedMS * directionY;
console.log(deltaX + ' DELTA X UPDATE\n' + deltaY + 'DELTA Y UPDATE ');
let increaseIndex = false;
if (deltaX > 0 && this.x + deltaX > targetX) {
@ -84,7 +83,6 @@ export default class Creep extends GameObject {
}
this.x += deltaX;
this.y += deltaY;
console.log(this.x + ' CREEP X UPDATE\n' + this.y + 'CREEP Y UPDATE ');
if (increaseIndex) this.pathIndex++;
this.draw();
}

View File

@ -0,0 +1,73 @@
import Assets from '../Assets';
import { Globals } from '../Bastion';
import GameObject from '../GameObject';
import * as PIXI from 'pixi.js';
export default class MissionStats extends GameObject {
private hp: number = 100;
private gold: number = 0;
public getHP() {
return this.hp;
}
public setHP(hp: number) {
this.hp = hp;
}
public takeDamage(damage: number) {
this.hp -= damage;
}
public setGold(gold: number) {
this.gold = gold;
}
constructor(initialHP: number, initialGold: number) {
super();
this.hp = initialHP;
this.gold = initialGold;
this.container.x = 0;
this.container.y = 20;
Globals.app.stage.addChild(this.container);
const healthText = new PIXI.Text({
text: `HP: ${this.hp}`,
style: new PIXI.TextStyle({
fill: 'white',
fontSize: 24,
fontWeight: 'bold',
dropShadow: true,
}),
});
healthText.x = 200;
const goldText = new PIXI.Text({
text: `Gold: ${this.gold}`,
style: new PIXI.TextStyle({
fill: 'white',
fontSize: 24,
fontWeight: 'bold',
dropShadow: true,
}),
});
goldText.x = 200;
goldText.y = 30;
const healthSprite = new PIXI.Sprite(Assets.HealthTexture);
healthSprite.x = 165;
healthSprite.width = 30;
healthSprite.height = 26;
healthSprite.y = 1;
const goldSprite = new PIXI.Sprite(Assets.GoldTexture);
goldSprite.x = 165;
goldSprite.width = 30;
goldSprite.height = 26;
goldSprite.y = 30;
this.container.addChild(healthText);
this.container.addChild(goldText);
this.container.addChild(healthSprite);
this.container.addChild(goldSprite);
}
public update() {}
}

View File

@ -8,6 +8,7 @@ import Sidebar from '../classes/gui/Sidebar';
import Button, { ButtonTexture } from '../classes/gui/Button';
import Scene from './Scene';
import * as PIXI from 'pixi.js';
import MissionStats from '../classes/game/MissionStats';
enum RoundMode {
Purchase = 0,
@ -19,6 +20,7 @@ export class GameScene extends Scene {
public missionIndex: number;
public roundMode: RoundMode;
public ticker: PIXI.Ticker;
public changeRoundButton: Button;
private currentRound: number = 0;
constructor(name: string) {
@ -36,8 +38,8 @@ export class GameScene extends Scene {
this.ticker.minFPS = 30;
this.ticker.add(() => this.update(this.ticker.elapsedMS)); // bruh
this.ticker.start();
const SidebarRect = new PIXI.Rectangle(Globals.WindowWidth - 350, 0, 350, Globals.app.canvas.height);
const StartButtonRect = new PIXI.Rectangle(Globals.WindowWidth - 200, Globals.WindowHeight, 200, 100);
const SidebarRect = new PIXI.Rectangle(64 * 30 - 350, 0, 350, Globals.app.canvas.height);
const changeRoundButtonRect = new PIXI.Rectangle(64 * 30 - 200, Globals.app.canvas.height - 100, 200, 100);
new Grid(this.mission.gameMap, this.missionIndex);
new WaveManager(this.mission.rounds, this.mission.gameMap.paths);
@ -48,14 +50,15 @@ export class GameScene extends Scene {
});
});
new Sidebar(SidebarRect);
// const changeRoundButton = new Button('Start', new PIXI.Color('white'), true);
const changeRoundButton = new Button(StartButtonRect, 'Start', ButtonTexture.Button01, true);
changeRoundButton.onClick = () => {
this.changeRoundButton = new Button(changeRoundButtonRect, 'Start', ButtonTexture.Button01, true);
this.changeRoundButton.onClick = () => {
console.log('clicked');
changeRoundButton.setEnabled(false);
changeRoundButton.setCaption('[X]');
this.changeRoundButton.setEnabled(false);
this.changeRoundButton.setCaption('[X]');
this.setRoundMode(RoundMode.Combat);
};
new MissionStats(100, 200);
}
public update(elapsedMS) {
Globals.WaveManager.update(elapsedMS);