diff --git a/lib/features/screens/difficulty_screen.dart b/lib/features/screens/difficulty_screen.dart index ff54bf5..c57b8a2 100644 --- a/lib/features/screens/difficulty_screen.dart +++ b/lib/features/screens/difficulty_screen.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:wolf_3d_data_types/wolf_3d_data_types.dart'; -import 'package:wolf_dart/features/renderer/renderer.dart'; -import 'package:wolf_dart/wolf_3d.dart'; +import 'package:wolf_3d_flutter/wolf_3d.dart'; +import 'package:wolf_3d_renderer/wolf_3d_renderer.dart'; class DifficultyScreen extends StatefulWidget { const DifficultyScreen({ diff --git a/lib/features/screens/episode_screen.dart b/lib/features/screens/episode_screen.dart index 128b95f..afb26db 100644 --- a/lib/features/screens/episode_screen.dart +++ b/lib/features/screens/episode_screen.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:wolf_3d_data_types/wolf_3d_data_types.dart'; +import 'package:wolf_3d_flutter/wolf_3d.dart'; import 'package:wolf_dart/features/screens/difficulty_screen.dart'; -import 'package:wolf_dart/wolf_3d.dart'; class EpisodeScreen extends StatefulWidget { const EpisodeScreen({super.key}); diff --git a/lib/game_select_screen.dart b/lib/game_select_screen.dart index 661885c..cab90f3 100644 --- a/lib/game_select_screen.dart +++ b/lib/game_select_screen.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:wolf_3d_data_types/wolf_3d_data_types.dart'; +import 'package:wolf_3d_flutter/wolf_3d.dart'; import 'package:wolf_dart/features/screens/episode_screen.dart'; -import 'package:wolf_dart/wolf_3d.dart'; class GameSelectScreen extends StatelessWidget { const GameSelectScreen({super.key}); diff --git a/lib/main.dart b/lib/main.dart index 6c857da..40ee010 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:wolf_3d_flutter/wolf_3d.dart'; import 'package:wolf_dart/game_select_screen.dart'; -import 'package:wolf_dart/wolf_3d.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); diff --git a/lib/sprite_gallery.dart b/lib/sprite_gallery.dart index 5c4f3e4..251a265 100644 --- a/lib/sprite_gallery.dart +++ b/lib/sprite_gallery.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:wolf_3d_data_types/wolf_3d_data_types.dart'; import 'package:wolf_3d_entities/wolf_3d_entities.dart'; -import 'package:wolf_dart/features/renderer/color_palette.dart'; +import 'package:wolf_3d_renderer/color_palette.dart'; class SpriteGallery extends StatelessWidget { final List sprites; diff --git a/packages/wolf_3d_engine/lib/src/engine_audio.dart b/packages/wolf_3d_engine/lib/src/engine_audio.dart new file mode 100644 index 0000000..518982f --- /dev/null +++ b/packages/wolf_3d_engine/lib/src/engine_audio.dart @@ -0,0 +1,7 @@ +import 'package:wolf_3d_data_types/wolf_3d_data_types.dart'; + +abstract class EngineAudio { + void playLevelMusic(WolfLevel level); + void stopMusic(); + // You can easily add things like void playSoundEffect(SoundId id); later! +} diff --git a/packages/wolf_3d_engine/lib/src/engine_input.dart b/packages/wolf_3d_engine/lib/src/engine_input.dart new file mode 100644 index 0000000..333b170 --- /dev/null +++ b/packages/wolf_3d_engine/lib/src/engine_input.dart @@ -0,0 +1,11 @@ +import 'package:wolf_3d_entities/wolf_3d_entities.dart'; + +class EngineInput { + bool isMovingForward = false; + bool isMovingBackward = false; + bool isTurningLeft = false; + bool isTurningRight = false; + bool isInteracting = false; + bool isFiring = false; + WeaponType? requestedWeapon; +} diff --git a/packages/wolf_3d_engine/lib/src/wolf_3d_engine_base.dart b/packages/wolf_3d_engine/lib/src/wolf_3d_engine_base.dart index 9d6dc14..b0e1398 100644 --- a/packages/wolf_3d_engine/lib/src/wolf_3d_engine_base.dart +++ b/packages/wolf_3d_engine/lib/src/wolf_3d_engine_base.dart @@ -1,4 +1,3 @@ -// No flutter imports allowed! import 'dart:math' as math; import 'package:wolf_3d_data_types/wolf_3d_data_types.dart'; @@ -11,17 +10,19 @@ class WolfEngine { required this.difficulty, required this.startingEpisode, required this.onGameWon, + required this.audio, }); final WolfensteinData data; final Difficulty difficulty; final int startingEpisode; + final EngineAudio audio; + // 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(); @@ -46,10 +47,10 @@ class WolfEngine { } // Expect standard Dart Duration. The host app is responsible for the loop. - void tick(Duration elapsed) { + void tick(Duration elapsed, EngineInput input) { if (!isInitialized) return; - final inputResult = _processInputs(elapsed); + final inputResult = _processInputs(elapsed, input); doorManager.update(elapsed); pushwallManager.update(elapsed, currentLevel); @@ -94,8 +95,7 @@ class WolfEngine { 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); + audio.playLevelMusic(activeLevel); for (int y = 0; y < 64; y++) { for (int x = 0; x < 64; x++) { @@ -144,7 +144,7 @@ class WolfEngine { } void _onLevelCompleted({bool isSecretExit = false}) { - Wolf3d.I.audio.stopMusic(); + audio.stopMusic(); final currentEpisode = data.episodes[_currentEpisodeIndex]; @@ -169,37 +169,39 @@ class WolfEngine { } } - ({Coordinate2D movement, double dAngle}) _processInputs(Duration elapsed) { - inputManager.update(); - + ({Coordinate2D movement, double dAngle}) _processInputs( + Duration elapsed, + EngineInput input, + ) { 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!); + // Read directly from the passed-in EngineInput object + if (input.requestedWeapon != null) { + player.requestWeaponSwitch(input.requestedWeapon!); } - if (inputManager.isFiring) { + if (input.isFiring) { player.fire(elapsed.inMilliseconds); } else { player.releaseTrigger(); } - if (inputManager.isTurningLeft) dAngle -= turnSpeed; - if (inputManager.isTurningRight) dAngle += turnSpeed; + if (input.isTurningLeft) dAngle -= turnSpeed; + if (input.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 (input.isMovingForward) movement += forwardVec * moveSpeed; + if (input.isMovingBackward) movement -= forwardVec * moveSpeed; - if (inputManager.isInteracting) { + if (input.isInteracting) { int targetX = (player.x + math.cos(player.angle)).toInt(); int targetY = (player.y + math.sin(player.angle)).toInt(); diff --git a/packages/wolf_3d_engine/lib/wolf_3d_engine.dart b/packages/wolf_3d_engine/lib/wolf_3d_engine.dart index 2b48325..4a68f17 100644 --- a/packages/wolf_3d_engine/lib/wolf_3d_engine.dart +++ b/packages/wolf_3d_engine/lib/wolf_3d_engine.dart @@ -3,6 +3,8 @@ /// More dartdocs go here. library; +export 'src/engine_audio.dart'; +export 'src/engine_input.dart'; export 'src/managers/door_manager.dart'; export 'src/managers/pushwall_manager.dart'; export 'src/player/player.dart'; diff --git a/packages/wolf_3d_engine/pubspec.yaml b/packages/wolf_3d_engine/pubspec.yaml index 2c3c689..888c0de 100644 --- a/packages/wolf_3d_engine/pubspec.yaml +++ b/packages/wolf_3d_engine/pubspec.yaml @@ -11,6 +11,7 @@ resolution: workspace dependencies: wolf_3d_data_types: any wolf_3d_entities: any + wolf_3d_input: any dev_dependencies: lints: ^6.0.0 diff --git a/packages/wolf_3d_flutter/.gitignore b/packages/wolf_3d_flutter/.gitignore new file mode 100644 index 0000000..dd5eb98 --- /dev/null +++ b/packages/wolf_3d_flutter/.gitignore @@ -0,0 +1,31 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.flutter-plugins-dependencies +/build/ +/coverage/ diff --git a/packages/wolf_3d_flutter/.metadata b/packages/wolf_3d_flutter/.metadata new file mode 100644 index 0000000..37c1556 --- /dev/null +++ b/packages/wolf_3d_flutter/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "ff37bef603469fb030f2b72995ab929ccfc227f0" + channel: "stable" + +project_type: package diff --git a/packages/wolf_3d_flutter/CHANGELOG.md b/packages/wolf_3d_flutter/CHANGELOG.md new file mode 100644 index 0000000..41cc7d8 --- /dev/null +++ b/packages/wolf_3d_flutter/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/packages/wolf_3d_flutter/LICENSE b/packages/wolf_3d_flutter/LICENSE new file mode 100644 index 0000000..ba75c69 --- /dev/null +++ b/packages/wolf_3d_flutter/LICENSE @@ -0,0 +1 @@ +TODO: Add your license here. diff --git a/packages/wolf_3d_flutter/README.md b/packages/wolf_3d_flutter/README.md new file mode 100644 index 0000000..4a260d8 --- /dev/null +++ b/packages/wolf_3d_flutter/README.md @@ -0,0 +1,39 @@ + + +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. diff --git a/packages/wolf_3d_flutter/analysis_options.yaml b/packages/wolf_3d_flutter/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/packages/wolf_3d_flutter/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/packages/wolf_3d_flutter/lib/audio/audio_adaptor.dart b/packages/wolf_3d_flutter/lib/audio/audio_adaptor.dart new file mode 100644 index 0000000..c4578b2 --- /dev/null +++ b/packages/wolf_3d_flutter/lib/audio/audio_adaptor.dart @@ -0,0 +1,15 @@ +import 'package:wolf_3d_data_types/wolf_3d_data_types.dart'; +import 'package:wolf_3d_engine/wolf_3d_engine.dart'; +import 'package:wolf_3d_flutter/wolf_3d.dart'; + +class FlutterAudioAdapter implements EngineAudio { + @override + void playLevelMusic(WolfLevel level) { + Wolf3d.I.audio.playLevelMusic(level); + } + + @override + void stopMusic() { + Wolf3d.I.audio.stopMusic(); + } +} diff --git a/lib/wolf_3d.dart b/packages/wolf_3d_flutter/lib/wolf_3d.dart similarity index 100% rename from lib/wolf_3d.dart rename to packages/wolf_3d_flutter/lib/wolf_3d.dart diff --git a/packages/wolf_3d_flutter/lib/wolf_3d_flutter.dart b/packages/wolf_3d_flutter/lib/wolf_3d_flutter.dart new file mode 100644 index 0000000..298576d --- /dev/null +++ b/packages/wolf_3d_flutter/lib/wolf_3d_flutter.dart @@ -0,0 +1,5 @@ +/// A Calculator. +class Calculator { + /// Returns [value] plus 1. + int addOne(int value) => value + 1; +} diff --git a/packages/wolf_3d_flutter/pubspec.yaml b/packages/wolf_3d_flutter/pubspec.yaml new file mode 100644 index 0000000..885f362 --- /dev/null +++ b/packages/wolf_3d_flutter/pubspec.yaml @@ -0,0 +1,60 @@ +name: wolf_3d_flutter +description: "A new Flutter package project." +version: 0.0.1 +homepage: + +environment: + sdk: ^3.11.1 + flutter: ">=1.17.0" + +resolution: workspace + +dependencies: + flutter: + sdk: flutter + wolf_3d_data: any + wolf_3d_data_types: any + wolf_3d_synth: any + wolf_3d_engine: any + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^6.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # To add assets to your package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/to/asset-from-package + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/to/resolution-aware-images + + # To add custom fonts to your package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/to/font-from-package diff --git a/packages/wolf_3d_input/.gitignore b/packages/wolf_3d_input/.gitignore new file mode 100644 index 0000000..dd5eb98 --- /dev/null +++ b/packages/wolf_3d_input/.gitignore @@ -0,0 +1,31 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.flutter-plugins-dependencies +/build/ +/coverage/ diff --git a/packages/wolf_3d_input/.metadata b/packages/wolf_3d_input/.metadata new file mode 100644 index 0000000..37c1556 --- /dev/null +++ b/packages/wolf_3d_input/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "ff37bef603469fb030f2b72995ab929ccfc227f0" + channel: "stable" + +project_type: package diff --git a/packages/wolf_3d_input/CHANGELOG.md b/packages/wolf_3d_input/CHANGELOG.md new file mode 100644 index 0000000..41cc7d8 --- /dev/null +++ b/packages/wolf_3d_input/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/packages/wolf_3d_input/LICENSE b/packages/wolf_3d_input/LICENSE new file mode 100644 index 0000000..ba75c69 --- /dev/null +++ b/packages/wolf_3d_input/LICENSE @@ -0,0 +1 @@ +TODO: Add your license here. diff --git a/packages/wolf_3d_input/README.md b/packages/wolf_3d_input/README.md new file mode 100644 index 0000000..4a260d8 --- /dev/null +++ b/packages/wolf_3d_input/README.md @@ -0,0 +1,39 @@ + + +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. diff --git a/packages/wolf_3d_input/analysis_options.yaml b/packages/wolf_3d_input/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/packages/wolf_3d_input/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/packages/wolf_3d_engine/lib/src/input/input_manager.dart b/packages/wolf_3d_input/lib/wolf_3d_input.dart similarity index 100% rename from packages/wolf_3d_engine/lib/src/input/input_manager.dart rename to packages/wolf_3d_input/lib/wolf_3d_input.dart diff --git a/packages/wolf_3d_input/pubspec.yaml b/packages/wolf_3d_input/pubspec.yaml new file mode 100644 index 0000000..ff7ab18 --- /dev/null +++ b/packages/wolf_3d_input/pubspec.yaml @@ -0,0 +1,57 @@ +name: wolf_3d_input +description: "A new Flutter package project." +version: 0.0.1 +homepage: + +environment: + sdk: ^3.11.1 + flutter: ">=1.17.0" + +resolution: workspace + +dependencies: + flutter: + sdk: flutter + wolf_3d_entities: any + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^6.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # To add assets to your package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/to/asset-from-package + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/to/resolution-aware-images + + # To add custom fonts to your package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/to/font-from-package diff --git a/packages/wolf_3d_renderer/.gitignore b/packages/wolf_3d_renderer/.gitignore new file mode 100644 index 0000000..dd5eb98 --- /dev/null +++ b/packages/wolf_3d_renderer/.gitignore @@ -0,0 +1,31 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.flutter-plugins-dependencies +/build/ +/coverage/ diff --git a/packages/wolf_3d_renderer/.metadata b/packages/wolf_3d_renderer/.metadata new file mode 100644 index 0000000..37c1556 --- /dev/null +++ b/packages/wolf_3d_renderer/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "ff37bef603469fb030f2b72995ab929ccfc227f0" + channel: "stable" + +project_type: package diff --git a/packages/wolf_3d_renderer/CHANGELOG.md b/packages/wolf_3d_renderer/CHANGELOG.md new file mode 100644 index 0000000..41cc7d8 --- /dev/null +++ b/packages/wolf_3d_renderer/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/packages/wolf_3d_renderer/LICENSE b/packages/wolf_3d_renderer/LICENSE new file mode 100644 index 0000000..ba75c69 --- /dev/null +++ b/packages/wolf_3d_renderer/LICENSE @@ -0,0 +1 @@ +TODO: Add your license here. diff --git a/packages/wolf_3d_renderer/README.md b/packages/wolf_3d_renderer/README.md new file mode 100644 index 0000000..4a260d8 --- /dev/null +++ b/packages/wolf_3d_renderer/README.md @@ -0,0 +1,39 @@ + + +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. diff --git a/packages/wolf_3d_renderer/analysis_options.yaml b/packages/wolf_3d_renderer/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/packages/wolf_3d_renderer/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/lib/features/renderer/color_palette.dart b/packages/wolf_3d_renderer/lib/color_palette.dart similarity index 100% rename from lib/features/renderer/color_palette.dart rename to packages/wolf_3d_renderer/lib/color_palette.dart diff --git a/lib/features/ui/hud.dart b/packages/wolf_3d_renderer/lib/hud.dart similarity index 100% rename from lib/features/ui/hud.dart rename to packages/wolf_3d_renderer/lib/hud.dart diff --git a/lib/features/renderer/raycast_painter.dart b/packages/wolf_3d_renderer/lib/raycast_painter.dart similarity index 98% rename from lib/features/renderer/raycast_painter.dart rename to packages/wolf_3d_renderer/lib/raycast_painter.dart index 910baf1..0a427eb 100644 --- a/lib/features/renderer/raycast_painter.dart +++ b/packages/wolf_3d_renderer/lib/raycast_painter.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; 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'; -import 'package:wolf_dart/features/renderer/color_palette.dart'; +import 'package:wolf_3d_renderer/color_palette.dart'; class RaycasterPainter extends CustomPainter { final Level map; @@ -358,11 +358,7 @@ class RaycasterPainter extends CustomPainter { double endY = startY + stepY + 0.5; if (endY > 0 && startY < size.height) { - canvas.drawLine( - Offset(drawX, startY), - Offset(drawX, endY), - paint, - ); + canvas.drawLine(Offset(drawX, startY), Offset(drawX, endY), paint); } startY += stepY; } diff --git a/lib/features/renderer/weapon_painter.dart b/packages/wolf_3d_renderer/lib/weapon_painter.dart similarity index 95% rename from lib/features/renderer/weapon_painter.dart rename to packages/wolf_3d_renderer/lib/weapon_painter.dart index 4e61ea7..6bf0b92 100644 --- a/lib/features/renderer/weapon_painter.dart +++ b/packages/wolf_3d_renderer/lib/weapon_painter.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:wolf_3d_data_types/wolf_3d_data_types.dart'; -import 'package:wolf_dart/features/renderer/color_palette.dart'; +import 'package:wolf_3d_renderer/color_palette.dart'; class WeaponPainter extends CustomPainter { final Sprite? sprite; diff --git a/lib/features/renderer/renderer.dart b/packages/wolf_3d_renderer/lib/wolf_3d_renderer.dart similarity index 97% rename from lib/features/renderer/renderer.dart rename to packages/wolf_3d_renderer/lib/wolf_3d_renderer.dart index 63202f8..061936e 100644 --- a/lib/features/renderer/renderer.dart +++ b/packages/wolf_3d_renderer/lib/wolf_3d_renderer.dart @@ -5,10 +5,10 @@ import 'package:flutter/scheduler.dart'; 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'; -import 'package:wolf_dart/features/renderer/raycast_painter.dart'; -import 'package:wolf_dart/features/renderer/weapon_painter.dart'; -import 'package:wolf_dart/features/ui/hud.dart'; -import 'package:wolf_dart/wolf_3d.dart'; +import 'package:wolf_3d_input/wolf_3d_input.dart'; +import 'package:wolf_3d_renderer/hud.dart'; +import 'package:wolf_3d_renderer/raycast_painter.dart'; +import 'package:wolf_3d_renderer/weapon_painter.dart'; class WolfRenderer extends StatefulWidget { const WolfRenderer( @@ -84,19 +84,13 @@ class _WolfRendererState extends State // 3. DEEP COPY the wall grid! If we don't do this, destroying walls/doors // will permanently corrupt the map data in the Wolf3d singleton. - currentLevel = List.generate( - 64, - (y) => List.from(activeLevel.wallGrid[y]), - ); + currentLevel = List.generate(64, (y) => List.from(activeLevel.wallGrid[y])); final Level objectLevel = activeLevel.objectGrid; // 4. Initialize Managers doorManager.initDoors(currentLevel); pushwallManager.initPushwalls(currentLevel, objectLevel); - // 5. Play Music - Wolf3d.I.audio.playLevelMusic(activeLevel); - // 6. Spawn Player and Entities for (int y = 0; y < 64; y++) { for (int x = 0; x < 64; x++) { @@ -146,8 +140,6 @@ class _WolfRendererState extends State } void _onLevelCompleted({bool isSecretExit = false}) { - Wolf3d.I.audio.stopMusic(); - setState(() { final currentEpisode = widget.data.episodes[_currentEpisodeIndex]; diff --git a/packages/wolf_3d_renderer/pubspec.yaml b/packages/wolf_3d_renderer/pubspec.yaml new file mode 100644 index 0000000..ae93d5d --- /dev/null +++ b/packages/wolf_3d_renderer/pubspec.yaml @@ -0,0 +1,60 @@ +name: wolf_3d_renderer +description: "A new Flutter package project." +version: 0.0.1 +homepage: + +environment: + sdk: ^3.11.1 + flutter: ">=1.17.0" + +resolution: workspace + +dependencies: + flutter: + sdk: flutter + wolf_3d_data_types: any + wolf_3d_engine: any + wolf_3d_entities: any + wolf_3d_input: any + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^6.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # To add assets to your package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/to/asset-from-package + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/to/resolution-aware-images + + # To add custom fonts to your package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/to/font-from-package diff --git a/pubspec.yaml b/pubspec.yaml index 2f7e690..39e11be 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,6 +12,9 @@ dependencies: wolf_3d_synth: any wolf_3d_engine: any wolf_3d_entities: any + wolf_3d_renderer: any + wolf_3d_input: any + wolf_3d_flutter: any flutter: sdk: flutter @@ -32,3 +35,6 @@ workspace: - packages/wolf_3d_synth/ - packages/wolf_3d_engine/ - packages/wolf_3d_entities/ + - packages/wolf_3d_renderer/ + - packages/wolf_3d_input/ + - packages/wolf_3d_flutter/