Skip to content

Commit

Permalink
Migrate flame_forge2d to monorepo (flame-engine#852)
Browse files Browse the repository at this point in the history
* Migrate flame_forge2d to monorepo

* Put in the temporary publish to none

* Update docs

* Add dart_code_metrics

* Add analysis options

* Fix analyze issues

* Fix formatting

* Add dart_code_metrics to flame_forge2d example
  • Loading branch information
spydon authored Jun 21, 2021
1 parent d9b2398 commit 20e5dd9
Show file tree
Hide file tree
Showing 40 changed files with 1,766 additions and 7 deletions.
13 changes: 7 additions & 6 deletions doc/forge2d.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ We (the Flame organization) maintain a ported version of the Box2D physics engin
is called Forge2D.

If you want to use Forge2D specifically for Flame you should use our bridge library
[flame_forge2d](https://github.com/flame-engine/flame_forge2d) and if you just want to use it
in a Dart project you can use the [forge2d](https://github.com/flame-engine/forge2d) library
directly.
[flame_forge2d](https://github.com/flame-engine/flame/tree/main/packages/flame_forge2d) and if you
just want to use it in a Dart project you can use the
[forge2d](https://github.com/flame-engine/forge2d) library directly.

To use it in your game you just need to add `flame_forge2d` to your pubspec.yaml, as can be seen
in the [Forge2D example](https://github.com/flame-engine/flame_forge2d/tree/main/example) and in the
pub.dev [installation instructions](https://pub.dev/packages/flame_forge2d).
in the
[Forge2D example](https://github.com/flame-engine/flame/tree/main/packages/flame_forge2d/example)
and in the pub.dev [installation instructions](https://pub.dev/packages/flame_forge2d).

## Forge2DGame (BaseGame extension)

Expand Down Expand Up @@ -107,7 +108,7 @@ An implementation example can be seen in the
## Viewport and Camera

`Forge2DGame` is using an implementation of the normal Flame `Viewport` and `Camera`, which can be
read more about [here](//TODO: Link to viewport and camera docs).
read more about [here](camera_and_viewport.md).

If you see your screen as a window and the outside as the Forge2D world, then the `Viewport` is the
part of the world outside that you can see through the window, so the parts that you can see on
Expand Down
2 changes: 1 addition & 1 deletion packages/flame/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
dart_code_metrics: ^2.4.0
dart_code_metrics: ^3.2.2
19 changes: 19 additions & 0 deletions packages/flame_forge2d/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.DS_Store
.atom/
.idea
*.iml
.packages
.dart_tool/
.pub/
packages
pubspec.lock
doc/api/
.flutter-plugins
.vscode/
**/.flutter-plugins
**/.flutter-plugins-dependencies

android/
ios/
desktop/
build/
43 changes: 43 additions & 0 deletions packages/flame_forge2d/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# CHANGELOG

## [0.7.2-releasecandidate.12]
- Update to Forge2D 0.7.2
- Update to Flame 1.0.0-releasecandidate.12
- Use `Camera` from Flame instead of the old internal viewport module

## [0.7.1-rc8]
- Take viewport yFlip into consideration on `cameraFollow`
- Update to forge2d 0.7.1
- Update to flame 1.0.0-rc8
- Integrate Flame viewport and camera to replace own viewport

## [0.6.4-rc4]
- Add PositionBodyComponent, keeps a PositionComponent on top of a BodyComponent
- Update to forge2d 0.6.4

## [0.6.3-rc4]
- Renamed the `prepare` method to `add` to be more inline with Flame Game naming.

## [0.6.3-rc3]
- Added an example for MouseJoint
- Update to forge2d 0.6.3

## [0.6.2-rc3]
- BodyComponent should follow Forge2D game debug mode
- Fix generics for BodyComponent
- Align with Flame 1.0.0-rc6
- Update to forge2d 0.6.2

## [0.6.0-rc2]
- Align with Flame 1.0.0-rc5

## [0.6.0-rc1]
- Align with Flame 1.0.0-rc4
- Align with Forge2D 0.6.0

## [0.5.0-rc1]
- Initial move of box2d related files
- Move over to refactored box2d

## [0.0.1-rc1]
- Empty release; in the future all flame box2d related code will live here.
22 changes: 22 additions & 0 deletions packages/flame_forge2d/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2020 Flame Org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

31 changes: 31 additions & 0 deletions packages/flame_forge2d/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<p align="center">
<a href="https://flame-engine.org">
<img alt="flame" width="300px" src="https://raw.githubusercontent.com/flame-engine/forge2d/main/design/with-text.png">
</a>
</p>

<p align="center">
Flame Forge2D - The bridge between Flame and Forge2D
</p>

<p align="center">
<a title="Pub" href="https://pub.dartlang.org/packages/flame_forge2d" ><img src="https://img.shields.io/pub/v/flame_forge2d.svg?style=popout" /></a> <img src="https://github.com/flame-engine/flame_forge2d/workflows/Test/badge.svg?branch=main&event=push" alt="Test" /> <a title="Discord" href="https://discord.gg/pxrBmy4" ><img src="https://img.shields.io/discord/509714518008528896.svg" /></a>
</p>

This library acts as a bridge between [Forge2D](https://github.com/flame-engine/forge2d) (our port of Box2D) and the Flame game engine.

# Installation
Add the following to the dependencies section of your `pubspec.yaml` file:

```
dependencies:
flame: ^1.0.0-releasecandidate.12
flame_forge2d: ^0.7.2-releasecandidate.12
```

## Examples
In the example folder of this directory you can find some [examples](https://github.com/flame-engine/flame/tree/main/packages/flame_forge2d/example), and you can also find some examples in the [Forge2D repository](https://github.com/flame-engine/forge2d/tree/main/example).

## Documentation
Some more documentation can be found on https://flame-engine.org/docs/#/forge2d

148 changes: 148 additions & 0 deletions packages/flame_forge2d/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Source of linter options:
# http://dart-lang.github.io/linter/lints/options/options.html

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false

plugins:
- dart_code_metrics

linter:
rules:
- always_declare_return_types
- always_put_control_body_on_new_line
- always_require_non_null_named_parameters
- annotate_overrides
- avoid_double_and_int_checks
- avoid_dynamic_calls
- avoid_empty_else
- avoid_equals_and_hash_code_on_mutable_classes
- avoid_escaping_inner_quotes
- avoid_field_initializers_in_const_classes
- avoid_init_to_null
- avoid_js_rounded_ints
- avoid_null_checks_in_equality_operators
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_relative_lib_imports
- avoid_return_types_on_setters
- avoid_shadowing_type_parameters
- avoid_slow_async_io
- avoid_type_to_string
- avoid_types_as_parameter_names
- avoid_unused_constructor_parameters
- await_only_futures
- camel_case_extensions
- camel_case_types
- cancel_subscriptions
- cast_nullable_to_non_nullable
- close_sinks
- comment_references
- constant_identifier_names
- control_flow_in_finally
- curly_braces_in_flow_control_structures
- directives_ordering
- do_not_use_environment
- empty_catches
- empty_constructor_bodies
- empty_statements
- exhaustive_cases
- file_names
- hash_and_equals
- implementation_imports
- invariant_booleans
- iterable_contains_unrelated_type
- join_return_with_assignment
- library_names
- library_prefixes
- list_remove_unrelated_type
- literal_only_boolean_expressions
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_duplicate_case_values
- no_runtimeType_toString
- omit_local_variable_types
- package_api_docs
- package_names
- package_prefixed_library_names
- parameter_assignments
- prefer_adjacent_string_concatenation
- prefer_asserts_in_initializer_lists
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- prefer_contains
- prefer_equal_for_default_values
- prefer_final_fields
- prefer_final_in_for_each
- prefer_final_locals
- prefer_for_elements_to_map_fromIterable
- prefer_foreach
- prefer_function_declarations_over_variables
- prefer_generic_function_type_aliases
- prefer_if_elements_to_conditional_expressions
- prefer_if_null_operators
- prefer_initializing_formals
- prefer_inlined_adds
- prefer_interpolation_to_compose_strings
- prefer_is_empty
- prefer_is_not_empty
- prefer_is_not_operator
- prefer_iterable_whereType
- prefer_mixin
- prefer_null_aware_operators
- prefer_single_quotes
- prefer_spread_collections
- prefer_relative_imports
- prefer_typing_uninitialized_variables
- prefer_void_to_null
- provide_deprecation_message
- recursive_getters
- slash_for_doc_comments
- sort_unnamed_constructors_first
- test_types_in_equals
- throw_in_finally
- type_annotate_public_apis
- type_init_formals
- unnecessary_await_in_return
- unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_getters_setters
- unnecessary_lambdas
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_raw_strings
- unnecessary_statements
- unnecessary_string_escapes
- unnecessary_string_interpolations
- unnecessary_this
- use_full_hex_values_for_flutter_colors
- use_function_type_syntax_for_parameters
- use_is_even_rather_than_modulo
- use_rethrow_when_possible
- unrelated_type_equality_checks
- unsafe_html
- void_checks

dart_code_metrics:
rules:
- prefer-trailing-comma
- prefer-trailing-comma-for-collection
- no-equal-then-else
- no-object-declaration
- potential-null-dereference
metrics-exclude:
- test/**
metrics:
number-of-parameters: 10
number-of-methods: 32
source-lines-of-code: 200
cyclomatic-complexity: 36
44 changes: 44 additions & 0 deletions packages/flame_forge2d/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# 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
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
10 changes: 10 additions & 0 deletions packages/flame_forge2d/example/.metadata
Original file line number Diff line number Diff line change
@@ -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: bbfbf1770cca2da7c82e887e4e4af910034800b6
channel: stable

project_type: app
3 changes: 3 additions & 0 deletions packages/flame_forge2d/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Forge2D Samples

A dashbook showcasing some samples of how to use Forge2D (box2d) together with Flame.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 20e5dd9

Please sign in to comment.