refactor: real time damage position
This commit is contained in:
parent
d8323ed9f3
commit
06066e5c43
|
@ -57,8 +57,6 @@ class Damage {
|
||||||
tick(elapsed, stepSize) {
|
tick(elapsed, stepSize) {
|
||||||
this.elapsed += elapsed;
|
this.elapsed += elapsed;
|
||||||
this.step += elapsed;
|
this.step += elapsed;
|
||||||
if (this.step > stepSize) {
|
|
||||||
this.step = this.step % stepSize;
|
|
||||||
// offset
|
// offset
|
||||||
let offsetX = 0, offsetY = 0;
|
let offsetX = 0, offsetY = 0;
|
||||||
if (this.elapsed <= 0.5) {
|
if (this.elapsed <= 0.5) {
|
||||||
|
@ -75,6 +73,8 @@ class Damage {
|
||||||
}
|
}
|
||||||
this.element.style.setProperty('--offsetX', offsetX);
|
this.element.style.setProperty('--offsetX', offsetX);
|
||||||
this.element.style.setProperty('--offsetY', offsetY);
|
this.element.style.setProperty('--offsetY', offsetY);
|
||||||
|
if (this.step > stepSize) {
|
||||||
|
this.step = this.step % stepSize;
|
||||||
// scale
|
// scale
|
||||||
let scale = 0.35;
|
let scale = 0.35;
|
||||||
if (this.elapsed <= 0.5) {
|
if (this.elapsed <= 0.5) {
|
||||||
|
@ -149,7 +149,7 @@ function Damages({scale}) {
|
||||||
pool.current.push(new Damage());
|
pool.current.push(new Damage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const stepSize = keys.length > 150 ? (keys.length / 500) * 0.25 : elapsed;
|
const stepSize = keys.length > 150 ? (keys.length / 500) * 0.5 : elapsed;
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
const damage = damages.current[key];
|
const damage = damages.current[key];
|
||||||
damage.tick(elapsed, stepSize);
|
damage.tick(elapsed, stepSize);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user