feat: add poc
This commit is contained in:
parent
43d27b04d9
commit
4a4fa05ce4
53 changed files with 6191 additions and 0 deletions
52
src/components/Combat.js
Normal file
52
src/components/Combat.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import { Component } from '../core/Component.js';
|
||||
|
||||
export class Combat extends Component {
|
||||
constructor() {
|
||||
super('Combat');
|
||||
this.attackDamage = 10;
|
||||
this.defense = 5;
|
||||
this.attackSpeed = 1.0; // Attacks per second
|
||||
this.attackRange = 50;
|
||||
this.lastAttackTime = 0;
|
||||
this.attackCooldown = 0;
|
||||
|
||||
// Combat state
|
||||
this.isAttacking = false;
|
||||
this.attackDirection = 0; // Angle in radians
|
||||
this.knockbackResistance = 0.5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if can attack
|
||||
*/
|
||||
canAttack(currentTime) {
|
||||
return (currentTime - this.lastAttackTime) >= (1.0 / this.attackSpeed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform attack
|
||||
*/
|
||||
attack(currentTime, direction) {
|
||||
if (!this.canAttack(currentTime)) return false;
|
||||
|
||||
this.lastAttackTime = currentTime;
|
||||
this.isAttacking = true;
|
||||
this.attackDirection = direction;
|
||||
this.attackCooldown = 0.3; // Attack animation duration
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update attack state
|
||||
*/
|
||||
update(deltaTime) {
|
||||
if (this.attackCooldown > 0) {
|
||||
this.attackCooldown -= deltaTime;
|
||||
if (this.attackCooldown <= 0) {
|
||||
this.isAttacking = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue