WIP: Refactoring game engine and entities into packages
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -2,10 +2,8 @@ import 'dart:math' as math;
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/classes/coordinate_2d.dart';
|
import 'package:wolf_3d_engine/wolf_3d_engine.dart';
|
||||||
import 'package:wolf_dart/features/entities/entity.dart';
|
import 'package:wolf_3d_entities/wolf_3d_entities.dart';
|
||||||
import 'package:wolf_dart/features/entities/pushwall_manager.dart';
|
|
||||||
import 'package:wolf_dart/features/player/player.dart';
|
|
||||||
import 'package:wolf_dart/features/renderer/color_palette.dart';
|
import 'package:wolf_dart/features/renderer/color_palette.dart';
|
||||||
|
|
||||||
class RaycasterPainter extends CustomPainter {
|
class RaycasterPainter extends CustomPainter {
|
||||||
|
|||||||
@@ -3,17 +3,8 @@ import 'dart:math' as math;
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/classes/coordinate_2d.dart';
|
import 'package:wolf_3d_engine/wolf_3d_engine.dart';
|
||||||
import 'package:wolf_dart/features/difficulty/difficulty.dart';
|
import 'package:wolf_3d_entities/wolf_3d_entities.dart';
|
||||||
import 'package:wolf_dart/features/entities/collectible.dart';
|
|
||||||
import 'package:wolf_dart/features/entities/door_manager.dart';
|
|
||||||
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
|
|
||||||
import 'package:wolf_dart/features/entities/entity.dart';
|
|
||||||
import 'package:wolf_dart/features/entities/entity_registry.dart';
|
|
||||||
import 'package:wolf_dart/features/entities/map_objects.dart';
|
|
||||||
import 'package:wolf_dart/features/entities/pushwall_manager.dart';
|
|
||||||
import 'package:wolf_dart/features/input/input_manager.dart';
|
|
||||||
import 'package:wolf_dart/features/player/player.dart';
|
|
||||||
import 'package:wolf_dart/features/renderer/raycast_painter.dart';
|
import 'package:wolf_dart/features/renderer/raycast_painter.dart';
|
||||||
import 'package:wolf_dart/features/renderer/weapon_painter.dart';
|
import 'package:wolf_dart/features/renderer/weapon_painter.dart';
|
||||||
import 'package:wolf_dart/features/ui/hud.dart';
|
import 'package:wolf_dart/features/ui/hud.dart';
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/difficulty/difficulty.dart';
|
|
||||||
import 'package:wolf_dart/features/renderer/renderer.dart';
|
import 'package:wolf_dart/features/renderer/renderer.dart';
|
||||||
import 'package:wolf_dart/wolf_3d.dart';
|
import 'package:wolf_dart/wolf_3d.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:wolf_dart/features/player/player.dart';
|
import 'package:wolf_3d_engine/wolf_3d_engine.dart';
|
||||||
|
|
||||||
class Hud extends StatelessWidget {
|
class Hud extends StatelessWidget {
|
||||||
final Player player;
|
final Player player;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
|
import 'package:wolf_3d_entities/wolf_3d_entities.dart';
|
||||||
import 'package:wolf_dart/features/renderer/color_palette.dart';
|
import 'package:wolf_dart/features/renderer/color_palette.dart';
|
||||||
|
|
||||||
class SpriteGallery extends StatelessWidget {
|
class SpriteGallery extends StatelessWidget {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'package:wolf_dart/classes/cardinal_direction.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/difficulty/difficulty.dart';
|
import 'package:wolf_3d_entities/wolf_3d_entities.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
|
|
||||||
|
|
||||||
abstract class MapObject {
|
abstract class MapObject {
|
||||||
// --- Player Spawns ---
|
// --- Player Spawns ---
|
||||||
@@ -3,10 +3,14 @@
|
|||||||
/// More dartdocs go here.
|
/// More dartdocs go here.
|
||||||
library;
|
library;
|
||||||
|
|
||||||
|
export 'src/cardinal_direction.dart' show CardinalDirection;
|
||||||
|
export 'src/coordinate_2d.dart' show Coordinate2D;
|
||||||
|
export 'src/difficulty.dart' show Difficulty;
|
||||||
export 'src/episode.dart' show Episode;
|
export 'src/episode.dart' show Episode;
|
||||||
export 'src/game_file.dart' show GameFile;
|
export 'src/game_file.dart' show GameFile;
|
||||||
export 'src/game_version.dart' show GameVersion;
|
export 'src/game_version.dart' show GameVersion;
|
||||||
export 'src/image.dart' show VgaImage;
|
export 'src/image.dart' show VgaImage;
|
||||||
|
export 'src/map_objects.dart' show MapObject;
|
||||||
export 'src/sound.dart'
|
export 'src/sound.dart'
|
||||||
show PcmSound, AdLibSound, ImfMusic, ImfInstruction, WolfMusicMap;
|
show PcmSound, AdLibSound, ImfMusic, ImfInstruction, WolfMusicMap;
|
||||||
export 'src/sprite.dart' hide Matrix;
|
export 'src/sprite.dart' hide Matrix;
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ environment:
|
|||||||
|
|
||||||
resolution: workspace
|
resolution: workspace
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
wolf_3d_entities: any
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
lints: ^6.0.0
|
lints: ^6.0.0
|
||||||
test: ^1.25.6
|
test: ^1.25.6
|
||||||
|
|||||||
7
packages/wolf_3d_engine/.gitignore
vendored
Normal file
7
packages/wolf_3d_engine/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# https://dart.dev/guides/libraries/private-files
|
||||||
|
# Created by `dart pub`
|
||||||
|
.dart_tool/
|
||||||
|
|
||||||
|
# Avoid committing pubspec.lock for library packages; see
|
||||||
|
# https://dart.dev/guides/libraries/private-files#pubspeclock.
|
||||||
|
pubspec.lock
|
||||||
3
packages/wolf_3d_engine/CHANGELOG.md
Normal file
3
packages/wolf_3d_engine/CHANGELOG.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
## 1.0.0
|
||||||
|
|
||||||
|
- Initial version.
|
||||||
39
packages/wolf_3d_engine/README.md
Normal file
39
packages/wolf_3d_engine/README.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<!--
|
||||||
|
This README describes the package. If you publish this package to pub.dev,
|
||||||
|
this README's contents appear on the landing page for your package.
|
||||||
|
|
||||||
|
For information about how to write a good package README, see the guide for
|
||||||
|
[writing package pages](https://dart.dev/tools/pub/writing-package-pages).
|
||||||
|
|
||||||
|
For general information about developing packages, see the Dart guide for
|
||||||
|
[creating packages](https://dart.dev/guides/libraries/create-packages)
|
||||||
|
and the Flutter guide for
|
||||||
|
[developing packages and plugins](https://flutter.dev/to/develop-packages).
|
||||||
|
-->
|
||||||
|
|
||||||
|
TODO: Put a short description of the package here that helps potential users
|
||||||
|
know whether this package might be useful for them.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
TODO: List what your package can do. Maybe include images, gifs, or videos.
|
||||||
|
|
||||||
|
## Getting started
|
||||||
|
|
||||||
|
TODO: List prerequisites and provide or point to information on how to
|
||||||
|
start using the package.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
TODO: Include short and useful examples for package users. Add longer examples
|
||||||
|
to `/example` folder.
|
||||||
|
|
||||||
|
```dart
|
||||||
|
const like = 'sample';
|
||||||
|
```
|
||||||
|
|
||||||
|
## Additional information
|
||||||
|
|
||||||
|
TODO: Tell users more about the package: where to find more information, how to
|
||||||
|
contribute to the package, how to file issues, what response they can expect
|
||||||
|
from the package authors, and more.
|
||||||
30
packages/wolf_3d_engine/analysis_options.yaml
Normal file
30
packages/wolf_3d_engine/analysis_options.yaml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# This file configures the static analysis results for your project (errors,
|
||||||
|
# warnings, and lints).
|
||||||
|
#
|
||||||
|
# This enables the 'recommended' set of lints from `package:lints`.
|
||||||
|
# This set helps identify many issues that may lead to problems when running
|
||||||
|
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
|
||||||
|
# style and format.
|
||||||
|
#
|
||||||
|
# If you want a smaller set of lints you can change this to specify
|
||||||
|
# 'package:lints/core.yaml'. These are just the most critical lints
|
||||||
|
# (the recommended set includes the core lints).
|
||||||
|
# The core lints are also what is used by pub.dev for scoring packages.
|
||||||
|
|
||||||
|
include: package:lints/recommended.yaml
|
||||||
|
|
||||||
|
# Uncomment the following section to specify additional rules.
|
||||||
|
|
||||||
|
# linter:
|
||||||
|
# rules:
|
||||||
|
# - camel_case_types
|
||||||
|
|
||||||
|
# analyzer:
|
||||||
|
# exclude:
|
||||||
|
# - path/to/excluded/files/**
|
||||||
|
|
||||||
|
# For more information about the core and recommended set of lints, see
|
||||||
|
# https://dart.dev/go/core-lints
|
||||||
|
|
||||||
|
# For additional information about configuring this file, see
|
||||||
|
# https://dart.dev/guides/language/analysis-options
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:wolf_dart/features/weapon/weapon.dart';
|
import 'package:wolf_3d_entities/wolf_3d_entities.dart';
|
||||||
|
|
||||||
class InputManager {
|
class InputManager {
|
||||||
Set<LogicalKeyboardKey> _previousKeys = {};
|
Set<LogicalKeyboardKey> _previousKeys = {};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/entities/door.dart';
|
import 'package:wolf_3d_entities/wolf_3d_entities.dart';
|
||||||
|
|
||||||
class DoorManager {
|
class DoorManager {
|
||||||
// Key is '$x,$y'
|
// Key is '$x,$y'
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/entities/map_objects.dart';
|
|
||||||
|
|
||||||
class Pushwall {
|
class Pushwall {
|
||||||
int x;
|
int x;
|
||||||
@@ -1,15 +1,7 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:wolf_dart/classes/coordinate_2d.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/entities/collectible.dart';
|
import 'package:wolf_3d_entities/wolf_3d_entities.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
|
|
||||||
import 'package:wolf_dart/features/entities/entity.dart';
|
|
||||||
import 'package:wolf_dart/features/entities/map_objects.dart';
|
|
||||||
import 'package:wolf_dart/features/weapon/weapon.dart';
|
|
||||||
import 'package:wolf_dart/features/weapon/weapons/chain_gun.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';
|
|
||||||
|
|
||||||
enum WeaponSwitchState { idle, lowering, raising }
|
enum WeaponSwitchState { idle, lowering, raising }
|
||||||
|
|
||||||
349
packages/wolf_3d_engine/lib/src/wolf_3d_engine_base.dart
Normal file
349
packages/wolf_3d_engine/lib/src/wolf_3d_engine_base.dart
Normal file
@@ -0,0 +1,349 @@
|
|||||||
|
// No flutter imports allowed!
|
||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
|
import 'package:wolf_3d_engine/wolf_3d_engine.dart';
|
||||||
|
import 'package:wolf_3d_entities/wolf_3d_entities.dart';
|
||||||
|
|
||||||
|
class WolfEngine {
|
||||||
|
WolfEngine({
|
||||||
|
required this.data,
|
||||||
|
required this.difficulty,
|
||||||
|
required this.startingEpisode,
|
||||||
|
required this.onGameWon,
|
||||||
|
});
|
||||||
|
|
||||||
|
final WolfensteinData data;
|
||||||
|
final Difficulty difficulty;
|
||||||
|
final int startingEpisode;
|
||||||
|
|
||||||
|
// Standard Dart function instead of Flutter's VoidCallback
|
||||||
|
final void Function() onGameWon;
|
||||||
|
|
||||||
|
// Managers
|
||||||
|
final InputManager inputManager = InputManager();
|
||||||
|
final DoorManager doorManager = DoorManager();
|
||||||
|
final PushwallManager pushwallManager = PushwallManager();
|
||||||
|
|
||||||
|
// State
|
||||||
|
late Player player;
|
||||||
|
late Level currentLevel;
|
||||||
|
late WolfLevel activeLevel;
|
||||||
|
List<Entity> entities = [];
|
||||||
|
|
||||||
|
int _currentEpisodeIndex = 0;
|
||||||
|
int _currentLevelIndex = 0;
|
||||||
|
int? _returnLevelIndex;
|
||||||
|
|
||||||
|
double damageFlashOpacity = 0.0;
|
||||||
|
bool isInitialized = false;
|
||||||
|
|
||||||
|
void init() {
|
||||||
|
_currentEpisodeIndex = startingEpisode;
|
||||||
|
_currentLevelIndex = 0;
|
||||||
|
_loadLevel();
|
||||||
|
isInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expect standard Dart Duration. The host app is responsible for the loop.
|
||||||
|
void tick(Duration elapsed) {
|
||||||
|
if (!isInitialized) return;
|
||||||
|
|
||||||
|
final inputResult = _processInputs(elapsed);
|
||||||
|
|
||||||
|
doorManager.update(elapsed);
|
||||||
|
pushwallManager.update(elapsed, currentLevel);
|
||||||
|
|
||||||
|
player.updateWeaponSwitch();
|
||||||
|
player.angle += inputResult.dAngle;
|
||||||
|
|
||||||
|
if (player.angle < 0) player.angle += 2 * math.pi;
|
||||||
|
if (player.angle >= 2 * math.pi) player.angle -= 2 * math.pi;
|
||||||
|
|
||||||
|
final Coordinate2D validatedPos = _calculateValidatedPosition(
|
||||||
|
player.position,
|
||||||
|
inputResult.movement,
|
||||||
|
);
|
||||||
|
|
||||||
|
player.x = validatedPos.x;
|
||||||
|
player.y = validatedPos.y;
|
||||||
|
|
||||||
|
_updateEntities(elapsed);
|
||||||
|
|
||||||
|
if (damageFlashOpacity > 0) {
|
||||||
|
damageFlashOpacity = math.max(0.0, damageFlashOpacity - 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.updateWeapon(
|
||||||
|
currentTime: elapsed.inMilliseconds,
|
||||||
|
entities: entities,
|
||||||
|
isWalkable: isWalkable,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _loadLevel() {
|
||||||
|
entities.clear();
|
||||||
|
damageFlashOpacity = 0.0;
|
||||||
|
|
||||||
|
final episode = data.episodes[_currentEpisodeIndex];
|
||||||
|
activeLevel = episode.levels[_currentLevelIndex];
|
||||||
|
|
||||||
|
currentLevel = List.generate(64, (y) => List.from(activeLevel.wallGrid[y]));
|
||||||
|
final Level objectLevel = activeLevel.objectGrid;
|
||||||
|
|
||||||
|
doorManager.initDoors(currentLevel);
|
||||||
|
pushwallManager.initPushwalls(currentLevel, objectLevel);
|
||||||
|
|
||||||
|
// TODO: Consider abstracting audio so the engine doesn't depend on Wolf3d singleton
|
||||||
|
Wolf3d.I.audio.playLevelMusic(activeLevel);
|
||||||
|
|
||||||
|
for (int y = 0; y < 64; y++) {
|
||||||
|
for (int x = 0; x < 64; x++) {
|
||||||
|
int objId = objectLevel[y][x];
|
||||||
|
|
||||||
|
if (!MapObject.shouldSpawn(objId, difficulty)) continue;
|
||||||
|
|
||||||
|
if (objId >= MapObject.playerNorth && objId <= MapObject.playerWest) {
|
||||||
|
double spawnAngle = 0.0;
|
||||||
|
if (objId == MapObject.playerNorth) {
|
||||||
|
spawnAngle = 3 * math.pi / 2;
|
||||||
|
} else if (objId == MapObject.playerEast) {
|
||||||
|
spawnAngle = 0.0;
|
||||||
|
} else if (objId == MapObject.playerSouth) {
|
||||||
|
spawnAngle = math.pi / 2;
|
||||||
|
} else if (objId == MapObject.playerWest) {
|
||||||
|
spawnAngle = math.pi;
|
||||||
|
}
|
||||||
|
|
||||||
|
player = Player(x: x + 0.5, y: y + 0.5, angle: spawnAngle);
|
||||||
|
} else {
|
||||||
|
Entity? newEntity = EntityRegistry.spawn(
|
||||||
|
objId,
|
||||||
|
x + 0.5,
|
||||||
|
y + 0.5,
|
||||||
|
difficulty,
|
||||||
|
data.sprites.length,
|
||||||
|
isSharewareMode: data.version == GameVersion.shareware,
|
||||||
|
);
|
||||||
|
if (newEntity != null) entities.add(newEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int y = 0; y < 64; y++) {
|
||||||
|
for (int x = 0; x < 64; x++) {
|
||||||
|
int id = currentLevel[y][x];
|
||||||
|
if (!((id >= 1 && id <= 63) || (id >= 90 && id <= 101))) {
|
||||||
|
currentLevel[y][x] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_bumpPlayerIfStuck();
|
||||||
|
print("Loaded Floor: ${_currentLevelIndex + 1} - ${activeLevel.name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onLevelCompleted({bool isSecretExit = false}) {
|
||||||
|
Wolf3d.I.audio.stopMusic();
|
||||||
|
|
||||||
|
final currentEpisode = data.episodes[_currentEpisodeIndex];
|
||||||
|
|
||||||
|
if (isSecretExit) {
|
||||||
|
_returnLevelIndex = _currentLevelIndex + 1;
|
||||||
|
_currentLevelIndex = 9;
|
||||||
|
} else {
|
||||||
|
if (_currentLevelIndex == 9 && _returnLevelIndex != null) {
|
||||||
|
_currentLevelIndex = _returnLevelIndex!;
|
||||||
|
_returnLevelIndex = null;
|
||||||
|
} else {
|
||||||
|
_currentLevelIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_currentLevelIndex >= currentEpisode.levels.length ||
|
||||||
|
_currentLevelIndex > 9) {
|
||||||
|
print("Episode Completed! You win!");
|
||||||
|
onGameWon();
|
||||||
|
} else {
|
||||||
|
_loadLevel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
({Coordinate2D movement, double dAngle}) _processInputs(Duration elapsed) {
|
||||||
|
inputManager.update();
|
||||||
|
|
||||||
|
const double moveSpeed = 0.14;
|
||||||
|
const double turnSpeed = 0.10;
|
||||||
|
|
||||||
|
Coordinate2D movement = const Coordinate2D(0, 0);
|
||||||
|
double dAngle = 0.0;
|
||||||
|
|
||||||
|
if (inputManager.requestedWeapon != null) {
|
||||||
|
player.requestWeaponSwitch(inputManager.requestedWeapon!);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputManager.isFiring) {
|
||||||
|
player.fire(elapsed.inMilliseconds);
|
||||||
|
} else {
|
||||||
|
player.releaseTrigger();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputManager.isTurningLeft) dAngle -= turnSpeed;
|
||||||
|
if (inputManager.isTurningRight) dAngle += turnSpeed;
|
||||||
|
|
||||||
|
Coordinate2D forwardVec = Coordinate2D(
|
||||||
|
math.cos(player.angle),
|
||||||
|
math.sin(player.angle),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (inputManager.isMovingForward) movement += forwardVec * moveSpeed;
|
||||||
|
if (inputManager.isMovingBackward) movement -= forwardVec * moveSpeed;
|
||||||
|
|
||||||
|
if (inputManager.isInteracting) {
|
||||||
|
int targetX = (player.x + math.cos(player.angle)).toInt();
|
||||||
|
int targetY = (player.y + math.sin(player.angle)).toInt();
|
||||||
|
|
||||||
|
if (targetX >= 0 && targetX < 64 && targetY >= 0 && targetY < 64) {
|
||||||
|
int wallId = currentLevel[targetY][targetX];
|
||||||
|
if (wallId == MapObject.normalElevatorSwitch) {
|
||||||
|
_onLevelCompleted(isSecretExit: false);
|
||||||
|
return (movement: const Coordinate2D(0, 0), dAngle: 0.0);
|
||||||
|
} else if (wallId == MapObject.secretElevatorSwitch) {
|
||||||
|
_onLevelCompleted(isSecretExit: true);
|
||||||
|
return (movement: const Coordinate2D(0, 0), dAngle: 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int objId = activeLevel.objectGrid[targetY][targetX];
|
||||||
|
if (objId == MapObject.normalExitTrigger) {
|
||||||
|
_onLevelCompleted(isSecretExit: false);
|
||||||
|
return (movement: movement, dAngle: dAngle);
|
||||||
|
} else if (objId == MapObject.secretExitTrigger) {
|
||||||
|
_onLevelCompleted(isSecretExit: true);
|
||||||
|
return (movement: movement, dAngle: dAngle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
doorManager.handleInteraction(player.x, player.y, player.angle);
|
||||||
|
pushwallManager.handleInteraction(
|
||||||
|
player.x,
|
||||||
|
player.y,
|
||||||
|
player.angle,
|
||||||
|
currentLevel,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (movement: movement, dAngle: dAngle);
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinate2D _calculateValidatedPosition(
|
||||||
|
Coordinate2D currentPos,
|
||||||
|
Coordinate2D movement,
|
||||||
|
) {
|
||||||
|
const double margin = 0.3;
|
||||||
|
double newX = currentPos.x;
|
||||||
|
double newY = currentPos.y;
|
||||||
|
|
||||||
|
Coordinate2D target = currentPos + movement;
|
||||||
|
|
||||||
|
if (movement.x != 0) {
|
||||||
|
int checkX = (movement.x > 0)
|
||||||
|
? (target.x + margin).toInt()
|
||||||
|
: (target.x - margin).toInt();
|
||||||
|
if (isWalkable(checkX, currentPos.y.toInt())) newX = target.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (movement.y != 0) {
|
||||||
|
int checkY = (movement.y > 0)
|
||||||
|
? (target.y + margin).toInt()
|
||||||
|
: (target.y - margin).toInt();
|
||||||
|
if (isWalkable(newX.toInt(), checkY)) newY = target.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Coordinate2D(newX, newY);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateEntities(Duration elapsed) {
|
||||||
|
List<Entity> itemsToRemove = [];
|
||||||
|
List<Entity> itemsToAdd = [];
|
||||||
|
|
||||||
|
for (Entity entity in entities) {
|
||||||
|
if (entity is Enemy) {
|
||||||
|
final intent = entity.update(
|
||||||
|
elapsedMs: elapsed.inMilliseconds,
|
||||||
|
playerPosition: player.position,
|
||||||
|
isWalkable: isWalkable,
|
||||||
|
tryOpenDoor: doorManager.tryOpenDoor,
|
||||||
|
onDamagePlayer: (int damage) {
|
||||||
|
player.takeDamage(damage);
|
||||||
|
damageFlashOpacity = 0.5;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
entity.angle = intent.newAngle;
|
||||||
|
entity.x += intent.movement.x;
|
||||||
|
entity.y += intent.movement.y;
|
||||||
|
|
||||||
|
if (entity.state == EntityState.dead &&
|
||||||
|
entity.isDying &&
|
||||||
|
!entity.hasDroppedItem) {
|
||||||
|
entity.hasDroppedItem = true;
|
||||||
|
Entity? droppedAmmo = EntityRegistry.spawn(
|
||||||
|
MapObject.ammoClip,
|
||||||
|
entity.x,
|
||||||
|
entity.y,
|
||||||
|
difficulty,
|
||||||
|
data.sprites.length,
|
||||||
|
);
|
||||||
|
if (droppedAmmo != null) itemsToAdd.add(droppedAmmo);
|
||||||
|
}
|
||||||
|
} else if (entity is Collectible) {
|
||||||
|
if (player.position.distanceTo(entity.position) < 0.5) {
|
||||||
|
if (player.tryPickup(entity)) {
|
||||||
|
itemsToRemove.add(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemsToRemove.isNotEmpty) {
|
||||||
|
entities.removeWhere((e) => itemsToRemove.contains(e));
|
||||||
|
}
|
||||||
|
if (itemsToAdd.isNotEmpty) entities.addAll(itemsToAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isWalkable(int x, int y) {
|
||||||
|
if (currentLevel[y][x] == 0) return true;
|
||||||
|
if (currentLevel[y][x] >= 90) return doorManager.isDoorOpenEnough(x, y);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _bumpPlayerIfStuck() {
|
||||||
|
int pX = player.x.toInt();
|
||||||
|
int pY = player.y.toInt();
|
||||||
|
|
||||||
|
if (pY < 0 ||
|
||||||
|
pY >= currentLevel.length ||
|
||||||
|
pX < 0 ||
|
||||||
|
pX >= currentLevel[0].length ||
|
||||||
|
currentLevel[pY][pX] > 0) {
|
||||||
|
double shortestDist = double.infinity;
|
||||||
|
Coordinate2D nearestSafeSpot = Coordinate2D(1.5, 1.5);
|
||||||
|
|
||||||
|
for (int y = 0; y < currentLevel.length; y++) {
|
||||||
|
for (int x = 0; x < currentLevel[y].length; x++) {
|
||||||
|
if (currentLevel[y][x] == 0) {
|
||||||
|
Coordinate2D safeSpot = Coordinate2D(x + 0.5, y + 0.5);
|
||||||
|
double dist = safeSpot.distanceTo(player.position);
|
||||||
|
|
||||||
|
if (dist < shortestDist) {
|
||||||
|
shortestDist = dist;
|
||||||
|
nearestSafeSpot = safeSpot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
player.x = nearestSafeSpot.x;
|
||||||
|
player.y = nearestSafeSpot.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
packages/wolf_3d_engine/lib/wolf_3d_engine.dart
Normal file
9
packages/wolf_3d_engine/lib/wolf_3d_engine.dart
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
/// Support for doing something awesome.
|
||||||
|
///
|
||||||
|
/// More dartdocs go here.
|
||||||
|
library;
|
||||||
|
|
||||||
|
export 'src/managers/door_manager.dart';
|
||||||
|
export 'src/managers/pushwall_manager.dart';
|
||||||
|
export 'src/player/player.dart';
|
||||||
|
export 'src/wolf_3d_engine_base.dart';
|
||||||
17
packages/wolf_3d_engine/pubspec.yaml
Normal file
17
packages/wolf_3d_engine/pubspec.yaml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
name: wolf_3d_engine
|
||||||
|
description: A starting point for Dart libraries or applications.
|
||||||
|
version: 1.0.0
|
||||||
|
# repository: https://github.com/my_org/my_repo
|
||||||
|
|
||||||
|
environment:
|
||||||
|
sdk: ^3.11.1
|
||||||
|
|
||||||
|
resolution: workspace
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
wolf_3d_data_types: any
|
||||||
|
wolf_3d_entities: any
|
||||||
|
|
||||||
|
dev_dependencies:
|
||||||
|
lints: ^6.0.0
|
||||||
|
test: ^1.25.6
|
||||||
7
packages/wolf_3d_entities/.gitignore
vendored
Normal file
7
packages/wolf_3d_entities/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# https://dart.dev/guides/libraries/private-files
|
||||||
|
# Created by `dart pub`
|
||||||
|
.dart_tool/
|
||||||
|
|
||||||
|
# Avoid committing pubspec.lock for library packages; see
|
||||||
|
# https://dart.dev/guides/libraries/private-files#pubspeclock.
|
||||||
|
pubspec.lock
|
||||||
3
packages/wolf_3d_entities/CHANGELOG.md
Normal file
3
packages/wolf_3d_entities/CHANGELOG.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
## 1.0.0
|
||||||
|
|
||||||
|
- Initial version.
|
||||||
39
packages/wolf_3d_entities/README.md
Normal file
39
packages/wolf_3d_entities/README.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<!--
|
||||||
|
This README describes the package. If you publish this package to pub.dev,
|
||||||
|
this README's contents appear on the landing page for your package.
|
||||||
|
|
||||||
|
For information about how to write a good package README, see the guide for
|
||||||
|
[writing package pages](https://dart.dev/tools/pub/writing-package-pages).
|
||||||
|
|
||||||
|
For general information about developing packages, see the Dart guide for
|
||||||
|
[creating packages](https://dart.dev/guides/libraries/create-packages)
|
||||||
|
and the Flutter guide for
|
||||||
|
[developing packages and plugins](https://flutter.dev/to/develop-packages).
|
||||||
|
-->
|
||||||
|
|
||||||
|
TODO: Put a short description of the package here that helps potential users
|
||||||
|
know whether this package might be useful for them.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
TODO: List what your package can do. Maybe include images, gifs, or videos.
|
||||||
|
|
||||||
|
## Getting started
|
||||||
|
|
||||||
|
TODO: List prerequisites and provide or point to information on how to
|
||||||
|
start using the package.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
TODO: Include short and useful examples for package users. Add longer examples
|
||||||
|
to `/example` folder.
|
||||||
|
|
||||||
|
```dart
|
||||||
|
const like = 'sample';
|
||||||
|
```
|
||||||
|
|
||||||
|
## Additional information
|
||||||
|
|
||||||
|
TODO: Tell users more about the package: where to find more information, how to
|
||||||
|
contribute to the package, how to file issues, what response they can expect
|
||||||
|
from the package authors, and more.
|
||||||
30
packages/wolf_3d_entities/analysis_options.yaml
Normal file
30
packages/wolf_3d_entities/analysis_options.yaml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# This file configures the static analysis results for your project (errors,
|
||||||
|
# warnings, and lints).
|
||||||
|
#
|
||||||
|
# This enables the 'recommended' set of lints from `package:lints`.
|
||||||
|
# This set helps identify many issues that may lead to problems when running
|
||||||
|
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
|
||||||
|
# style and format.
|
||||||
|
#
|
||||||
|
# If you want a smaller set of lints you can change this to specify
|
||||||
|
# 'package:lints/core.yaml'. These are just the most critical lints
|
||||||
|
# (the recommended set includes the core lints).
|
||||||
|
# The core lints are also what is used by pub.dev for scoring packages.
|
||||||
|
|
||||||
|
include: package:lints/recommended.yaml
|
||||||
|
|
||||||
|
# Uncomment the following section to specify additional rules.
|
||||||
|
|
||||||
|
# linter:
|
||||||
|
# rules:
|
||||||
|
# - camel_case_types
|
||||||
|
|
||||||
|
# analyzer:
|
||||||
|
# exclude:
|
||||||
|
# - path/to/excluded/files/**
|
||||||
|
|
||||||
|
# For more information about the core and recommended set of lints, see
|
||||||
|
# https://dart.dev/go/core-lints
|
||||||
|
|
||||||
|
# For additional information about configuring this file, see
|
||||||
|
# https://dart.dev/guides/language/analysis-options
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:wolf_dart/features/difficulty/difficulty.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/entities/entity.dart';
|
import 'package:wolf_3d_entities/src/entity.dart';
|
||||||
|
|
||||||
enum CollectibleType { ammo, health, treasure, weapon, key }
|
enum CollectibleType { ammo, health, treasure, weapon, key }
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:wolf_dart/features/difficulty/difficulty.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/entities/entity.dart';
|
import 'package:wolf_3d_entities/src/entity.dart';
|
||||||
|
|
||||||
class Decorative extends Entity {
|
class Decorative extends Entity {
|
||||||
Decorative({
|
Decorative({
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:wolf_dart/classes/coordinate_2d.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/difficulty/difficulty.dart';
|
import 'package:wolf_3d_entities/src/entities/enemies/enemy.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
|
import 'package:wolf_3d_entities/src/entity.dart';
|
||||||
import 'package:wolf_dart/features/entities/entity.dart';
|
|
||||||
import 'package:wolf_dart/features/entities/map_objects.dart';
|
|
||||||
|
|
||||||
class HansGrosse extends Enemy {
|
class HansGrosse extends Enemy {
|
||||||
static const double speed = 0.04;
|
static const double speed = 0.04;
|
||||||
@@ -17,10 +15,7 @@ class HansGrosse extends Enemy {
|
|||||||
required super.angle,
|
required super.angle,
|
||||||
required super.mapId,
|
required super.mapId,
|
||||||
required Difficulty difficulty,
|
required Difficulty difficulty,
|
||||||
}) : super(
|
}) : super(spriteIndex: _baseSprite, state: EntityState.idle) {
|
||||||
spriteIndex: _baseSprite,
|
|
||||||
state: EntityState.idle,
|
|
||||||
) {
|
|
||||||
// Boss health scales heavily with difficulty
|
// Boss health scales heavily with difficulty
|
||||||
health = switch (difficulty.level) {
|
health = switch (difficulty.level) {
|
||||||
0 => 850,
|
0 => 850,
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:wolf_dart/classes/coordinate_2d.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
|
import 'package:wolf_3d_entities/src/entities/enemies/enemy.dart';
|
||||||
import 'package:wolf_dart/features/entities/entity.dart';
|
import 'package:wolf_3d_entities/src/entity.dart';
|
||||||
|
|
||||||
class Dog extends Enemy {
|
class Dog extends Enemy {
|
||||||
static const double speed = 0.05;
|
static const double speed = 0.05;
|
||||||
@@ -15,10 +15,7 @@ class Dog extends Enemy {
|
|||||||
required super.y,
|
required super.y,
|
||||||
required super.angle,
|
required super.angle,
|
||||||
required super.mapId,
|
required super.mapId,
|
||||||
}) : super(
|
}) : super(spriteIndex: type.spriteBaseIdx, state: EntityState.idle) {
|
||||||
spriteIndex: type.spriteBaseIdx,
|
|
||||||
state: EntityState.idle,
|
|
||||||
) {
|
|
||||||
health = 1;
|
health = 1;
|
||||||
damage = 5;
|
damage = 5;
|
||||||
}
|
}
|
||||||
@@ -1,39 +1,26 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:wolf_dart/classes/coordinate_2d.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/difficulty/difficulty.dart';
|
import 'package:wolf_3d_entities/src/entities/enemies/dog.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/dog.dart';
|
import 'package:wolf_3d_entities/src/entities/enemies/guard.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/guard.dart';
|
import 'package:wolf_3d_entities/src/entities/enemies/mutant.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/mutant.dart';
|
import 'package:wolf_3d_entities/src/entities/enemies/officer.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/officer.dart';
|
import 'package:wolf_3d_entities/src/entities/enemies/ss.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/ss.dart';
|
import 'package:wolf_3d_entities/src/entity.dart';
|
||||||
import 'package:wolf_dart/features/entities/entity.dart';
|
|
||||||
import 'package:wolf_dart/features/entities/map_objects.dart';
|
|
||||||
|
|
||||||
enum EnemyAnimation {
|
enum EnemyAnimation { idle, walking, attacking, pain, dying, dead }
|
||||||
idle,
|
|
||||||
walking,
|
|
||||||
attacking,
|
|
||||||
pain,
|
|
||||||
dying,
|
|
||||||
dead,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum EnemyType {
|
enum EnemyType {
|
||||||
guard(mapBaseId: 108, spriteBaseIdx: 50),
|
guard(mapBaseId: 108, spriteBaseIdx: 50),
|
||||||
dog(mapBaseId: 216, spriteBaseIdx: 99),
|
dog(mapBaseId: 216, spriteBaseIdx: 99),
|
||||||
ss(mapBaseId: 180, spriteBaseIdx: 138),
|
ss(mapBaseId: 180, spriteBaseIdx: 138),
|
||||||
mutant(mapBaseId: 252, spriteBaseIdx: 187),
|
mutant(mapBaseId: 252, spriteBaseIdx: 187),
|
||||||
officer(mapBaseId: 144, spriteBaseIdx: 238),
|
officer(mapBaseId: 144, spriteBaseIdx: 238);
|
||||||
;
|
|
||||||
|
|
||||||
final int mapBaseId;
|
final int mapBaseId;
|
||||||
final int spriteBaseIdx;
|
final int spriteBaseIdx;
|
||||||
|
|
||||||
const EnemyType({
|
const EnemyType({required this.mapBaseId, required this.spriteBaseIdx});
|
||||||
required this.mapBaseId,
|
|
||||||
required this.spriteBaseIdx,
|
|
||||||
});
|
|
||||||
|
|
||||||
/// Helper to check if a specific TED5 Map ID belongs to this enemy
|
/// Helper to check if a specific TED5 Map ID belongs to this enemy
|
||||||
bool claimsMapId(int id) => id >= mapBaseId && id <= mapBaseId + 35;
|
bool claimsMapId(int id) => id >= mapBaseId && id <= mapBaseId + 35;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:wolf_dart/classes/coordinate_2d.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
|
import 'package:wolf_3d_entities/src/entities/enemies/enemy.dart';
|
||||||
import 'package:wolf_dart/features/entities/entity.dart';
|
import 'package:wolf_3d_entities/src/entity.dart';
|
||||||
|
|
||||||
class Guard extends Enemy {
|
class Guard extends Enemy {
|
||||||
static const double speed = 0.03;
|
static const double speed = 0.03;
|
||||||
@@ -15,10 +15,7 @@ class Guard extends Enemy {
|
|||||||
required super.y,
|
required super.y,
|
||||||
required super.angle,
|
required super.angle,
|
||||||
required super.mapId,
|
required super.mapId,
|
||||||
}) : super(
|
}) : super(spriteIndex: type.spriteBaseIdx, state: EntityState.idle);
|
||||||
spriteIndex: type.spriteBaseIdx,
|
|
||||||
state: EntityState.idle,
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
({Coordinate2D movement, double newAngle}) update({
|
({Coordinate2D movement, double newAngle}) update({
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:wolf_dart/classes/coordinate_2d.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
|
import 'package:wolf_3d_entities/src/entities/enemies/enemy.dart';
|
||||||
import 'package:wolf_dart/features/entities/entity.dart';
|
import 'package:wolf_3d_entities/src/entity.dart';
|
||||||
|
|
||||||
class Mutant extends Enemy {
|
class Mutant extends Enemy {
|
||||||
static const double speed = 0.04;
|
static const double speed = 0.04;
|
||||||
@@ -15,10 +15,7 @@ class Mutant extends Enemy {
|
|||||||
required super.y,
|
required super.y,
|
||||||
required super.angle,
|
required super.angle,
|
||||||
required super.mapId,
|
required super.mapId,
|
||||||
}) : super(
|
}) : super(spriteIndex: type.spriteBaseIdx, state: EntityState.idle) {
|
||||||
spriteIndex: type.spriteBaseIdx,
|
|
||||||
state: EntityState.idle,
|
|
||||||
) {
|
|
||||||
health = 45;
|
health = 45;
|
||||||
damage = 10;
|
damage = 10;
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:wolf_dart/classes/coordinate_2d.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
|
import 'package:wolf_3d_entities/src/entities/enemies/enemy.dart';
|
||||||
import 'package:wolf_dart/features/entities/entity.dart';
|
import 'package:wolf_3d_entities/src/entity.dart';
|
||||||
|
|
||||||
class Officer extends Enemy {
|
class Officer extends Enemy {
|
||||||
static const double speed = 0.055;
|
static const double speed = 0.055;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:wolf_dart/classes/coordinate_2d.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
|
import 'package:wolf_3d_entities/src/entities/enemies/enemy.dart';
|
||||||
import 'package:wolf_dart/features/entities/entity.dart';
|
import 'package:wolf_3d_entities/src/entity.dart';
|
||||||
|
|
||||||
class SS extends Enemy {
|
class SS extends Enemy {
|
||||||
static const double speed = 0.04;
|
static const double speed = 0.04;
|
||||||
@@ -13,10 +13,7 @@ class SS extends Enemy {
|
|||||||
required super.y,
|
required super.y,
|
||||||
required super.angle,
|
required super.angle,
|
||||||
required super.mapId,
|
required super.mapId,
|
||||||
}) : super(
|
}) : super(spriteIndex: EnemyType.ss.spriteBaseIdx, state: EntityState.idle) {
|
||||||
spriteIndex: EnemyType.ss.spriteBaseIdx,
|
|
||||||
state: EntityState.idle,
|
|
||||||
) {
|
|
||||||
health = 100;
|
health = 100;
|
||||||
damage = 20;
|
damage = 20;
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:wolf_dart/classes/coordinate_2d.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
|
import 'package:wolf_3d_entities/src/entities/enemies/enemy.dart';
|
||||||
import 'package:wolf_dart/features/entities/entity.dart';
|
import 'package:wolf_3d_entities/src/entity.dart';
|
||||||
|
|
||||||
enum WeaponState { idle, firing }
|
enum WeaponState { idle, firing }
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:wolf_dart/features/weapon/weapon.dart';
|
import 'package:wolf_3d_entities/src/entities/weapon/weapon.dart';
|
||||||
|
|
||||||
class ChainGun extends Weapon {
|
class ChainGun extends Weapon {
|
||||||
ChainGun()
|
ChainGun()
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:wolf_dart/features/weapon/weapon.dart';
|
import 'package:wolf_3d_entities/src/entities/weapon/weapon.dart';
|
||||||
|
|
||||||
class Knife extends Weapon {
|
class Knife extends Weapon {
|
||||||
Knife()
|
Knife()
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:wolf_dart/features/weapon/weapon.dart';
|
import 'package:wolf_3d_entities/src/entities/weapon/weapon.dart';
|
||||||
|
|
||||||
class MachineGun extends Weapon {
|
class MachineGun extends Weapon {
|
||||||
MachineGun()
|
MachineGun()
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:wolf_dart/features/weapon/weapon.dart';
|
import 'package:wolf_3d_entities/src/entities/weapon/weapon.dart';
|
||||||
|
|
||||||
class Pistol extends Weapon {
|
class Pistol extends Weapon {
|
||||||
Pistol()
|
Pistol()
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:wolf_dart/classes/coordinate_2d.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
|
|
||||||
enum EntityState { staticObj, idle, patrolling, attacking, pain, dead }
|
enum EntityState { staticObj, idle, patrolling, attacking, pain, dead }
|
||||||
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
import 'package:wolf_dart/features/difficulty/difficulty.dart';
|
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||||
import 'package:wolf_dart/features/entities/collectible.dart';
|
import 'package:wolf_3d_entities/src/entities/collectible.dart';
|
||||||
import 'package:wolf_dart/features/entities/decorative.dart';
|
import 'package:wolf_3d_entities/src/entities/decorative.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/bosses/hans_grosse.dart';
|
import 'package:wolf_3d_entities/src/entities/enemies/bosses/hans_grosse.dart';
|
||||||
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
|
import 'package:wolf_3d_entities/src/entities/enemies/enemy.dart';
|
||||||
import 'package:wolf_dart/features/entities/entity.dart';
|
import 'package:wolf_3d_entities/src/entity.dart';
|
||||||
import 'package:wolf_dart/features/entities/map_objects.dart';
|
|
||||||
|
|
||||||
typedef EntitySpawner =
|
typedef EntitySpawner =
|
||||||
Entity? Function(
|
Entity? Function(
|
||||||
22
packages/wolf_3d_entities/lib/wolf_3d_entities.dart
Normal file
22
packages/wolf_3d_entities/lib/wolf_3d_entities.dart
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/// Support for doing something awesome.
|
||||||
|
///
|
||||||
|
/// More dartdocs go here.
|
||||||
|
library;
|
||||||
|
|
||||||
|
export 'src/entities/collectible.dart';
|
||||||
|
export 'src/entities/decorative.dart';
|
||||||
|
export 'src/entities/door.dart';
|
||||||
|
export 'src/entities/enemies/bosses/hans_grosse.dart';
|
||||||
|
export 'src/entities/enemies/dog.dart';
|
||||||
|
export 'src/entities/enemies/enemy.dart';
|
||||||
|
export 'src/entities/enemies/guard.dart';
|
||||||
|
export 'src/entities/enemies/mutant.dart';
|
||||||
|
export 'src/entities/enemies/officer.dart';
|
||||||
|
export 'src/entities/enemies/ss.dart';
|
||||||
|
export 'src/entities/weapon/weapon.dart';
|
||||||
|
export 'src/entities/weapon/weapons/chain_gun.dart';
|
||||||
|
export 'src/entities/weapon/weapons/knife.dart';
|
||||||
|
export 'src/entities/weapon/weapons/machine_gun.dart';
|
||||||
|
export 'src/entities/weapon/weapons/pistol.dart';
|
||||||
|
export 'src/entity.dart';
|
||||||
|
export 'src/entity_registry.dart';
|
||||||
16
packages/wolf_3d_entities/pubspec.yaml
Normal file
16
packages/wolf_3d_entities/pubspec.yaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
name: wolf_3d_entities
|
||||||
|
description: A starting point for Dart libraries or applications.
|
||||||
|
version: 1.0.0
|
||||||
|
# repository: https://github.com/my_org/my_repo
|
||||||
|
|
||||||
|
environment:
|
||||||
|
sdk: ^3.11.1
|
||||||
|
|
||||||
|
resolution: workspace
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
wolf_3d_data_types: any
|
||||||
|
|
||||||
|
dev_dependencies:
|
||||||
|
lints: ^6.0.0
|
||||||
|
test: ^1.25.6
|
||||||
@@ -10,6 +10,8 @@ dependencies:
|
|||||||
wolf_3d_data: any
|
wolf_3d_data: any
|
||||||
wolf_3d_data_types: any
|
wolf_3d_data_types: any
|
||||||
wolf_3d_synth: any
|
wolf_3d_synth: any
|
||||||
|
wolf_3d_engine: any
|
||||||
|
wolf_3d_entities: any
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
@@ -28,3 +30,5 @@ workspace:
|
|||||||
- packages/wolf_3d_data/
|
- packages/wolf_3d_data/
|
||||||
- packages/wolf_3d_data_types/
|
- packages/wolf_3d_data_types/
|
||||||
- packages/wolf_3d_synth/
|
- packages/wolf_3d_synth/
|
||||||
|
- packages/wolf_3d_engine/
|
||||||
|
- packages/wolf_3d_entities/
|
||||||
|
|||||||
Reference in New Issue
Block a user