De-coupled remaining aspects of game into packages
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
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/renderer/renderer.dart';
|
import 'package:wolf_3d_flutter/wolf_3d.dart';
|
||||||
import 'package:wolf_dart/wolf_3d.dart';
|
import 'package:wolf_3d_renderer/wolf_3d_renderer.dart';
|
||||||
|
|
||||||
class DifficultyScreen extends StatefulWidget {
|
class DifficultyScreen extends StatefulWidget {
|
||||||
const DifficultyScreen({
|
const DifficultyScreen({
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
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_3d_flutter/wolf_3d.dart';
|
||||||
import 'package:wolf_dart/features/screens/difficulty_screen.dart';
|
import 'package:wolf_dart/features/screens/difficulty_screen.dart';
|
||||||
import 'package:wolf_dart/wolf_3d.dart';
|
|
||||||
|
|
||||||
class EpisodeScreen extends StatefulWidget {
|
class EpisodeScreen extends StatefulWidget {
|
||||||
const EpisodeScreen({super.key});
|
const EpisodeScreen({super.key});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
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_3d_flutter/wolf_3d.dart';
|
||||||
import 'package:wolf_dart/features/screens/episode_screen.dart';
|
import 'package:wolf_dart/features/screens/episode_screen.dart';
|
||||||
import 'package:wolf_dart/wolf_3d.dart';
|
|
||||||
|
|
||||||
class GameSelectScreen extends StatelessWidget {
|
class GameSelectScreen extends StatelessWidget {
|
||||||
const GameSelectScreen({super.key});
|
const GameSelectScreen({super.key});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
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/game_select_screen.dart';
|
||||||
import 'package:wolf_dart/wolf_3d.dart';
|
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
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_3d_entities/wolf_3d_entities.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 {
|
class SpriteGallery extends StatelessWidget {
|
||||||
final List<Sprite> sprites;
|
final List<Sprite> sprites;
|
||||||
|
|||||||
7
packages/wolf_3d_engine/lib/src/engine_audio.dart
Normal file
7
packages/wolf_3d_engine/lib/src/engine_audio.dart
Normal file
@@ -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!
|
||||||
|
}
|
||||||
11
packages/wolf_3d_engine/lib/src/engine_input.dart
Normal file
11
packages/wolf_3d_engine/lib/src/engine_input.dart
Normal file
@@ -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;
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
// No flutter imports allowed!
|
|
||||||
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';
|
||||||
@@ -11,17 +10,19 @@ class WolfEngine {
|
|||||||
required this.difficulty,
|
required this.difficulty,
|
||||||
required this.startingEpisode,
|
required this.startingEpisode,
|
||||||
required this.onGameWon,
|
required this.onGameWon,
|
||||||
|
required this.audio,
|
||||||
});
|
});
|
||||||
|
|
||||||
final WolfensteinData data;
|
final WolfensteinData data;
|
||||||
final Difficulty difficulty;
|
final Difficulty difficulty;
|
||||||
final int startingEpisode;
|
final int startingEpisode;
|
||||||
|
|
||||||
|
final EngineAudio audio;
|
||||||
|
|
||||||
// Standard Dart function instead of Flutter's VoidCallback
|
// Standard Dart function instead of Flutter's VoidCallback
|
||||||
final void Function() onGameWon;
|
final void Function() onGameWon;
|
||||||
|
|
||||||
// Managers
|
// Managers
|
||||||
final InputManager inputManager = InputManager();
|
|
||||||
final DoorManager doorManager = DoorManager();
|
final DoorManager doorManager = DoorManager();
|
||||||
final PushwallManager pushwallManager = PushwallManager();
|
final PushwallManager pushwallManager = PushwallManager();
|
||||||
|
|
||||||
@@ -46,10 +47,10 @@ class WolfEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Expect standard Dart Duration. The host app is responsible for the loop.
|
// 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;
|
if (!isInitialized) return;
|
||||||
|
|
||||||
final inputResult = _processInputs(elapsed);
|
final inputResult = _processInputs(elapsed, input);
|
||||||
|
|
||||||
doorManager.update(elapsed);
|
doorManager.update(elapsed);
|
||||||
pushwallManager.update(elapsed, currentLevel);
|
pushwallManager.update(elapsed, currentLevel);
|
||||||
@@ -94,8 +95,7 @@ class WolfEngine {
|
|||||||
doorManager.initDoors(currentLevel);
|
doorManager.initDoors(currentLevel);
|
||||||
pushwallManager.initPushwalls(currentLevel, objectLevel);
|
pushwallManager.initPushwalls(currentLevel, objectLevel);
|
||||||
|
|
||||||
// TODO: Consider abstracting audio so the engine doesn't depend on Wolf3d singleton
|
audio.playLevelMusic(activeLevel);
|
||||||
Wolf3d.I.audio.playLevelMusic(activeLevel);
|
|
||||||
|
|
||||||
for (int y = 0; y < 64; y++) {
|
for (int y = 0; y < 64; y++) {
|
||||||
for (int x = 0; x < 64; x++) {
|
for (int x = 0; x < 64; x++) {
|
||||||
@@ -144,7 +144,7 @@ class WolfEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onLevelCompleted({bool isSecretExit = false}) {
|
void _onLevelCompleted({bool isSecretExit = false}) {
|
||||||
Wolf3d.I.audio.stopMusic();
|
audio.stopMusic();
|
||||||
|
|
||||||
final currentEpisode = data.episodes[_currentEpisodeIndex];
|
final currentEpisode = data.episodes[_currentEpisodeIndex];
|
||||||
|
|
||||||
@@ -169,37 +169,39 @@ class WolfEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
({Coordinate2D movement, double dAngle}) _processInputs(Duration elapsed) {
|
({Coordinate2D movement, double dAngle}) _processInputs(
|
||||||
inputManager.update();
|
Duration elapsed,
|
||||||
|
EngineInput input,
|
||||||
|
) {
|
||||||
const double moveSpeed = 0.14;
|
const double moveSpeed = 0.14;
|
||||||
const double turnSpeed = 0.10;
|
const double turnSpeed = 0.10;
|
||||||
|
|
||||||
Coordinate2D movement = const Coordinate2D(0, 0);
|
Coordinate2D movement = const Coordinate2D(0, 0);
|
||||||
double dAngle = 0.0;
|
double dAngle = 0.0;
|
||||||
|
|
||||||
if (inputManager.requestedWeapon != null) {
|
// Read directly from the passed-in EngineInput object
|
||||||
player.requestWeaponSwitch(inputManager.requestedWeapon!);
|
if (input.requestedWeapon != null) {
|
||||||
|
player.requestWeaponSwitch(input.requestedWeapon!);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputManager.isFiring) {
|
if (input.isFiring) {
|
||||||
player.fire(elapsed.inMilliseconds);
|
player.fire(elapsed.inMilliseconds);
|
||||||
} else {
|
} else {
|
||||||
player.releaseTrigger();
|
player.releaseTrigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputManager.isTurningLeft) dAngle -= turnSpeed;
|
if (input.isTurningLeft) dAngle -= turnSpeed;
|
||||||
if (inputManager.isTurningRight) dAngle += turnSpeed;
|
if (input.isTurningRight) dAngle += turnSpeed;
|
||||||
|
|
||||||
Coordinate2D forwardVec = Coordinate2D(
|
Coordinate2D forwardVec = Coordinate2D(
|
||||||
math.cos(player.angle),
|
math.cos(player.angle),
|
||||||
math.sin(player.angle),
|
math.sin(player.angle),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (inputManager.isMovingForward) movement += forwardVec * moveSpeed;
|
if (input.isMovingForward) movement += forwardVec * moveSpeed;
|
||||||
if (inputManager.isMovingBackward) 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 targetX = (player.x + math.cos(player.angle)).toInt();
|
||||||
int targetY = (player.y + math.sin(player.angle)).toInt();
|
int targetY = (player.y + math.sin(player.angle)).toInt();
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
/// More dartdocs go here.
|
/// More dartdocs go here.
|
||||||
library;
|
library;
|
||||||
|
|
||||||
|
export 'src/engine_audio.dart';
|
||||||
|
export 'src/engine_input.dart';
|
||||||
export 'src/managers/door_manager.dart';
|
export 'src/managers/door_manager.dart';
|
||||||
export 'src/managers/pushwall_manager.dart';
|
export 'src/managers/pushwall_manager.dart';
|
||||||
export 'src/player/player.dart';
|
export 'src/player/player.dart';
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ resolution: workspace
|
|||||||
dependencies:
|
dependencies:
|
||||||
wolf_3d_data_types: any
|
wolf_3d_data_types: any
|
||||||
wolf_3d_entities: any
|
wolf_3d_entities: any
|
||||||
|
wolf_3d_input: any
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
lints: ^6.0.0
|
lints: ^6.0.0
|
||||||
|
|||||||
31
packages/wolf_3d_flutter/.gitignore
vendored
Normal file
31
packages/wolf_3d_flutter/.gitignore
vendored
Normal file
@@ -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/
|
||||||
10
packages/wolf_3d_flutter/.metadata
Normal file
10
packages/wolf_3d_flutter/.metadata
Normal file
@@ -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
|
||||||
3
packages/wolf_3d_flutter/CHANGELOG.md
Normal file
3
packages/wolf_3d_flutter/CHANGELOG.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
## 0.0.1
|
||||||
|
|
||||||
|
* TODO: Describe initial release.
|
||||||
1
packages/wolf_3d_flutter/LICENSE
Normal file
1
packages/wolf_3d_flutter/LICENSE
Normal file
@@ -0,0 +1 @@
|
|||||||
|
TODO: Add your license here.
|
||||||
39
packages/wolf_3d_flutter/README.md
Normal file
39
packages/wolf_3d_flutter/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.
|
||||||
4
packages/wolf_3d_flutter/analysis_options.yaml
Normal file
4
packages/wolf_3d_flutter/analysis_options.yaml
Normal file
@@ -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
|
||||||
15
packages/wolf_3d_flutter/lib/audio/audio_adaptor.dart
Normal file
15
packages/wolf_3d_flutter/lib/audio/audio_adaptor.dart
Normal file
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
5
packages/wolf_3d_flutter/lib/wolf_3d_flutter.dart
Normal file
5
packages/wolf_3d_flutter/lib/wolf_3d_flutter.dart
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
/// A Calculator.
|
||||||
|
class Calculator {
|
||||||
|
/// Returns [value] plus 1.
|
||||||
|
int addOne(int value) => value + 1;
|
||||||
|
}
|
||||||
60
packages/wolf_3d_flutter/pubspec.yaml
Normal file
60
packages/wolf_3d_flutter/pubspec.yaml
Normal file
@@ -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
|
||||||
31
packages/wolf_3d_input/.gitignore
vendored
Normal file
31
packages/wolf_3d_input/.gitignore
vendored
Normal file
@@ -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/
|
||||||
10
packages/wolf_3d_input/.metadata
Normal file
10
packages/wolf_3d_input/.metadata
Normal file
@@ -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
|
||||||
3
packages/wolf_3d_input/CHANGELOG.md
Normal file
3
packages/wolf_3d_input/CHANGELOG.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
## 0.0.1
|
||||||
|
|
||||||
|
* TODO: Describe initial release.
|
||||||
1
packages/wolf_3d_input/LICENSE
Normal file
1
packages/wolf_3d_input/LICENSE
Normal file
@@ -0,0 +1 @@
|
|||||||
|
TODO: Add your license here.
|
||||||
39
packages/wolf_3d_input/README.md
Normal file
39
packages/wolf_3d_input/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.
|
||||||
4
packages/wolf_3d_input/analysis_options.yaml
Normal file
4
packages/wolf_3d_input/analysis_options.yaml
Normal file
@@ -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
|
||||||
57
packages/wolf_3d_input/pubspec.yaml
Normal file
57
packages/wolf_3d_input/pubspec.yaml
Normal file
@@ -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
|
||||||
31
packages/wolf_3d_renderer/.gitignore
vendored
Normal file
31
packages/wolf_3d_renderer/.gitignore
vendored
Normal file
@@ -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/
|
||||||
10
packages/wolf_3d_renderer/.metadata
Normal file
10
packages/wolf_3d_renderer/.metadata
Normal file
@@ -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
|
||||||
3
packages/wolf_3d_renderer/CHANGELOG.md
Normal file
3
packages/wolf_3d_renderer/CHANGELOG.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
## 0.0.1
|
||||||
|
|
||||||
|
* TODO: Describe initial release.
|
||||||
1
packages/wolf_3d_renderer/LICENSE
Normal file
1
packages/wolf_3d_renderer/LICENSE
Normal file
@@ -0,0 +1 @@
|
|||||||
|
TODO: Add your license here.
|
||||||
39
packages/wolf_3d_renderer/README.md
Normal file
39
packages/wolf_3d_renderer/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.
|
||||||
4
packages/wolf_3d_renderer/analysis_options.yaml
Normal file
4
packages/wolf_3d_renderer/analysis_options.yaml
Normal file
@@ -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
|
||||||
@@ -4,7 +4,7 @@ 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_3d_engine/wolf_3d_engine.dart';
|
import 'package:wolf_3d_engine/wolf_3d_engine.dart';
|
||||||
import 'package:wolf_3d_entities/wolf_3d_entities.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 {
|
class RaycasterPainter extends CustomPainter {
|
||||||
final Level map;
|
final Level map;
|
||||||
@@ -358,11 +358,7 @@ class RaycasterPainter extends CustomPainter {
|
|||||||
double endY = startY + stepY + 0.5;
|
double endY = startY + stepY + 0.5;
|
||||||
|
|
||||||
if (endY > 0 && startY < size.height) {
|
if (endY > 0 && startY < size.height) {
|
||||||
canvas.drawLine(
|
canvas.drawLine(Offset(drawX, startY), Offset(drawX, endY), paint);
|
||||||
Offset(drawX, startY),
|
|
||||||
Offset(drawX, endY),
|
|
||||||
paint,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
startY += stepY;
|
startY += stepY;
|
||||||
}
|
}
|
||||||
@@ -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/renderer/color_palette.dart';
|
import 'package:wolf_3d_renderer/color_palette.dart';
|
||||||
|
|
||||||
class WeaponPainter extends CustomPainter {
|
class WeaponPainter extends CustomPainter {
|
||||||
final Sprite? sprite;
|
final Sprite? sprite;
|
||||||
@@ -5,10 +5,10 @@ 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_3d_engine/wolf_3d_engine.dart';
|
import 'package:wolf_3d_engine/wolf_3d_engine.dart';
|
||||||
import 'package:wolf_3d_entities/wolf_3d_entities.dart';
|
import 'package:wolf_3d_entities/wolf_3d_entities.dart';
|
||||||
import 'package:wolf_dart/features/renderer/raycast_painter.dart';
|
import 'package:wolf_3d_input/wolf_3d_input.dart';
|
||||||
import 'package:wolf_dart/features/renderer/weapon_painter.dart';
|
import 'package:wolf_3d_renderer/hud.dart';
|
||||||
import 'package:wolf_dart/features/ui/hud.dart';
|
import 'package:wolf_3d_renderer/raycast_painter.dart';
|
||||||
import 'package:wolf_dart/wolf_3d.dart';
|
import 'package:wolf_3d_renderer/weapon_painter.dart';
|
||||||
|
|
||||||
class WolfRenderer extends StatefulWidget {
|
class WolfRenderer extends StatefulWidget {
|
||||||
const WolfRenderer(
|
const WolfRenderer(
|
||||||
@@ -84,19 +84,13 @@ class _WolfRendererState extends State<WolfRenderer>
|
|||||||
|
|
||||||
// 3. DEEP COPY the wall grid! If we don't do this, destroying walls/doors
|
// 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.
|
// will permanently corrupt the map data in the Wolf3d singleton.
|
||||||
currentLevel = List.generate(
|
currentLevel = List.generate(64, (y) => List.from(activeLevel.wallGrid[y]));
|
||||||
64,
|
|
||||||
(y) => List.from(activeLevel.wallGrid[y]),
|
|
||||||
);
|
|
||||||
final Level objectLevel = activeLevel.objectGrid;
|
final Level objectLevel = activeLevel.objectGrid;
|
||||||
|
|
||||||
// 4. Initialize Managers
|
// 4. Initialize Managers
|
||||||
doorManager.initDoors(currentLevel);
|
doorManager.initDoors(currentLevel);
|
||||||
pushwallManager.initPushwalls(currentLevel, objectLevel);
|
pushwallManager.initPushwalls(currentLevel, objectLevel);
|
||||||
|
|
||||||
// 5. Play Music
|
|
||||||
Wolf3d.I.audio.playLevelMusic(activeLevel);
|
|
||||||
|
|
||||||
// 6. Spawn Player and Entities
|
// 6. Spawn Player and Entities
|
||||||
for (int y = 0; y < 64; y++) {
|
for (int y = 0; y < 64; y++) {
|
||||||
for (int x = 0; x < 64; x++) {
|
for (int x = 0; x < 64; x++) {
|
||||||
@@ -146,8 +140,6 @@ class _WolfRendererState extends State<WolfRenderer>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onLevelCompleted({bool isSecretExit = false}) {
|
void _onLevelCompleted({bool isSecretExit = false}) {
|
||||||
Wolf3d.I.audio.stopMusic();
|
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
final currentEpisode = widget.data.episodes[_currentEpisodeIndex];
|
final currentEpisode = widget.data.episodes[_currentEpisodeIndex];
|
||||||
|
|
||||||
60
packages/wolf_3d_renderer/pubspec.yaml
Normal file
60
packages/wolf_3d_renderer/pubspec.yaml
Normal file
@@ -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
|
||||||
@@ -12,6 +12,9 @@ dependencies:
|
|||||||
wolf_3d_synth: any
|
wolf_3d_synth: any
|
||||||
wolf_3d_engine: any
|
wolf_3d_engine: any
|
||||||
wolf_3d_entities: any
|
wolf_3d_entities: any
|
||||||
|
wolf_3d_renderer: any
|
||||||
|
wolf_3d_input: any
|
||||||
|
wolf_3d_flutter: any
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
@@ -32,3 +35,6 @@ workspace:
|
|||||||
- packages/wolf_3d_synth/
|
- packages/wolf_3d_synth/
|
||||||
- packages/wolf_3d_engine/
|
- packages/wolf_3d_engine/
|
||||||
- packages/wolf_3d_entities/
|
- packages/wolf_3d_entities/
|
||||||
|
- packages/wolf_3d_renderer/
|
||||||
|
- packages/wolf_3d_input/
|
||||||
|
- packages/wolf_3d_flutter/
|
||||||
|
|||||||
Reference in New Issue
Block a user