Add player container

This commit is contained in:
schmelczerandras 2020-10-24 10:01:54 +02:00
parent 1cd8f5fbe6
commit b55e927a34
16 changed files with 159 additions and 133 deletions

View file

@ -1,6 +1,13 @@
import { vec2 } from 'gl-matrix';
import { Renderer } from 'sdf-2d';
import { CharacterBase, CharacterTeam, Circle, Id, UpdateMessage } from 'shared';
import {
CharacterBase,
CharacterTeam,
Circle,
Id,
settings,
UpdateMessage,
} from 'shared';
import { BlobShape } from '../shapes/blob-shape';
import { ViewObject } from './view-object';
@ -10,15 +17,14 @@ export class CharacterView extends CharacterBase implements ViewObject {
constructor(
id: Id,
colorIndex: number,
team: CharacterTeam,
health: number,
head?: Circle,
leftFoot?: Circle,
rightFoot?: Circle,
) {
super(id, colorIndex, team, health, head, leftFoot, rightFoot);
this.shape = new BlobShape(colorIndex);
super(id, team, health, head, leftFoot, rightFoot);
this.shape = new BlobShape(settings.colorIndices[team]);
}
public get position(): vec2 {

View file

@ -19,26 +19,14 @@ export class PlayerCharacterView extends PlayerCharacterBase implements ViewObje
name: string,
killCount: number,
deathCount: number,
colorIndex: number,
team: CharacterTeam,
health: number,
head?: Circle,
leftFoot?: Circle,
rightFoot?: Circle,
) {
super(
id,
name,
killCount,
deathCount,
colorIndex,
team,
health,
head,
leftFoot,
rightFoot,
);
this.shape = new BlobShape(colorIndex);
super(id, name, killCount, deathCount, team, health, head, leftFoot, rightFoot);
this.shape = new BlobShape(settings.colorIndices[team]);
this.previousHealth = this.health;
this.nameElement.className = 'player-tag ' + this.team;

View file

@ -1,6 +1,6 @@
import { vec2 } from 'gl-matrix';
import { CircleLight, ColorfulCircle, Renderer } from 'sdf-2d';
import { Id, ProjectileBase, settings, UpdateMessage } from 'shared';
import { CharacterTeam, Id, ProjectileBase, settings, UpdateMessage } from 'shared';
import { ViewObject } from './view-object';
export class ProjectileView extends ProjectileBase implements ViewObject {
@ -11,12 +11,16 @@ export class ProjectileView extends ProjectileBase implements ViewObject {
id: Id,
center: vec2,
radius: number,
colorIndex: number,
team: CharacterTeam,
strength: number,
) {
super(id, center, radius, colorIndex, strength);
this.circle = new ColorfulCircle(center, radius / 2, colorIndex);
this.light = new CircleLight(center, settings.palette[colorIndex], 0);
super(id, center, radius, team, strength);
this.circle = new ColorfulCircle(center, radius / 2, settings.colorIndices[team]);
this.light = new CircleLight(
center,
settings.paletteDim[settings.colorIndices[team]],
0,
);
}
public step(deltaTimeInMilliseconds: number): void {