Reorganized files

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-13 23:10:39 +01:00
parent 3086e5a8f4
commit a4bc6f8520
6 changed files with 15 additions and 14 deletions

View File

@@ -2,10 +2,10 @@ import 'dart:math' as math;
import 'package:wolf_dart/classes/linear_coordinates.dart';
import 'package:wolf_dart/features/entities/collectible.dart';
import 'package:wolf_dart/features/player/weapon.dart';
import 'package:wolf_dart/features/player/weapons/knife.dart';
import 'package:wolf_dart/features/player/weapons/machine_gun.dart';
import 'package:wolf_dart/features/player/weapons/pistol.dart';
import 'package:wolf_dart/features/weapon/weapons/knife.dart';
import 'package:wolf_dart/features/weapon/weapons/machine_gun.dart';
import 'package:wolf_dart/features/weapon/weapons/pistol.dart';
import 'package:wolf_dart/features/weapon/weapons/weapon.dart';
class Player {
// Spatial

View File

@@ -1,48 +0,0 @@
enum WeaponState { idle, firing }
abstract class Weapon {
final String name;
final int idleSprite;
final List<int> fireFrames;
final int damage;
final int msPerFrame;
WeaponState state = WeaponState.idle;
int frameIndex = 0;
int lastFrameTime = 0;
Weapon({
required this.name,
required this.idleSprite,
required this.fireFrames,
required this.damage,
this.msPerFrame = 100,
});
int get currentSprite =>
state == WeaponState.idle ? idleSprite : fireFrames[frameIndex];
/// Core firing logic. Returns true if a bullet was spent.
bool fire(int currentTime, {required int currentAmmo}) {
if (state == WeaponState.idle && currentAmmo > 0) {
state = WeaponState.firing;
frameIndex = 0;
lastFrameTime = currentTime;
return true;
}
return false;
}
void update(int currentTime) {
if (state == WeaponState.firing) {
if (currentTime - lastFrameTime > msPerFrame) {
frameIndex++;
lastFrameTime = currentTime;
if (frameIndex >= fireFrames.length) {
state = WeaponState.idle;
frameIndex = 0;
}
}
}
}
}

View File

@@ -1,23 +0,0 @@
import 'package:wolf_dart/features/player/weapon.dart';
class Knife extends Weapon {
Knife()
: super(
name: "Knife",
idleSprite: 416,
fireFrames: [417, 418, 419, 420],
damage: 15,
msPerFrame: 120,
);
@override
bool fire(int currentTime, {required int currentAmmo}) {
if (state == WeaponState.idle) {
state = WeaponState.firing;
frameIndex = 0;
lastFrameTime = currentTime;
return true;
}
return false;
}
}

View File

@@ -1,12 +0,0 @@
import 'package:wolf_dart/features/player/weapon.dart';
class MachineGun extends Weapon {
MachineGun()
: super(
name: "Machine Gun",
idleSprite: 413,
fireFrames: [414, 415], // Faster 2-frame loop
damage: 20,
msPerFrame: 80,
);
}

View File

@@ -1,11 +0,0 @@
import 'package:wolf_dart/features/player/weapon.dart';
class Pistol extends Weapon {
Pistol()
: super(
name: "Pistol",
idleSprite: 421,
fireFrames: [422, 423, 424, 425],
damage: 20,
);
}