3D game
This commit is contained in:
@@ -3,10 +3,12 @@ import { Component } from "$/common/ecs/component.ts";
|
||||
export class Position extends Component {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
|
||||
constructor(x: number, y: number) {
|
||||
constructor(x: number, y: number, z = 0) {
|
||||
super();
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@ import { Component } from "$/common/ecs/component.ts";
|
||||
export class Velocity extends Component {
|
||||
vx: number;
|
||||
vy: number;
|
||||
vz: number;
|
||||
|
||||
constructor(vx: number, vy: number) {
|
||||
constructor(vx: number, vy: number, vz = 0) {
|
||||
super();
|
||||
this.vx = vx;
|
||||
this.vy = vy;
|
||||
this.vz = vz;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,7 @@ export class MovementSystem extends System {
|
||||
if (position && velocity) {
|
||||
position.x += velocity.vx * delta;
|
||||
position.y += velocity.vy * delta;
|
||||
position.x = Math.round(position.x);
|
||||
position.y = Math.round(position.y);
|
||||
position.z += velocity.vz * delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user