245 Commits

Author SHA1 Message Date
b401c5485c docs: fix broken link for Keyboard Input Component (#1854) 2022-08-20 21:32:42 +00:00
ed452dd172 feat!: Raycasting and raytracing (#1785)
This PR implements raytracing and raycasting for the built-in hitboxes.

If you pass in your own collision detection system to the HasCollisionDetection mixin you have to change the signature of that to: CollisionDetection<ShapeHitbox>instead of CollisionDetection<Hitbox>.
2022-08-19 22:44:18 +02:00
bfdc3a291b feat: Structured text and text styles (#1830)
This PR introduces the notions of structured text, and text styles, to support rendering of rich text bodies.

Specifically, we recognize that sometimes in games one needs to render pieces of text that are larger than a single word or even a single paragraph. These pieces may include: books, quest descriptions, mission objectives, tutorials, in-game help system, dialogues, etc. Rendering such a piece of text is non-trivial, however. In order to tackle this problem, I break into the following parts:

Text structure, represented as a tree of Nodes. The nodes describe the logical structure of the text, for example the document may contain a header, and then several paragraphs, and a list, where the list contains some list items, some of which having possibly several paragraphs, etc. This structure is similar to how in HTML the text is marked up with HTML tags.

Text styles are struct-like classes that contain properties describing how the text is to be styled: font size, font renderer, borders, backgrounds, margins, padding, etc. This representation is also tree-like, so that for example text inside paragraphs can have different style than text within headers, and paragraphs within lists can have different margins. A text style is similar to a stylesheet in HTML.

Text elements are the result of applying the document style to a document node: they are the "prepared" and laid out pieces, ready to be rendered. Elements are a bit like mini-components, or perhaps text "particles" in a particle system.
2022-08-10 08:13:27 +00:00
8384a51d65 docs: Simplify draggable example (#1754)
The draggable example was overly complicated so I simplified it.
2022-06-27 14:57:58 -03:00
5225a4ebd5 refactor: Game is now a class, not a mixin (#1751)
This simple refactor allows us to write class MyGame extends Game, instead of a more awkward class MyGame with Game. However, using ... with Game still continues to work, so no changes necessary for the users.
2022-06-25 21:32:32 +00:00
72e317f898 fix: Fix broken link for example games code (#1747) 2022-06-22 17:46:47 +00:00
d6bf920d28 feat!: Update flame_audio to AP 1.0.0 (#1724) 2022-06-14 00:12:47 -04:00
2a41d0d683 feat: Move to Flutter 3.0.0 and Dart 2.17.0 (#1713)
This upgrades all packages to Flutter 3.0.0 and fixes all analyze issues that came from that.
2022-06-08 06:04:40 +00:00
49252f8ef2 feat: Add more lint rules (#1703)
Adds some more lint rules and fixes the issues those rules pointed out.
2022-06-06 19:23:25 +00:00
2711ba60c2 feat: Implement tap events based on componentsAtPoint (#1661)
This PR adds a new event system based on the componentsAtPoint delivery mechanism. These events allow for a proper support of components that implement renderTree() method. The CameraComponent is one such component, with more planned in the future.

Additionally, the following improvements compared to the current tap events added:

    - the same component can be tapped with multiple fingers simultaneously;
    - a component that received onTapDown is guaranteed to receive onTapUp or onTapCancel later;
    - a component that moves away from the point of touch will receive onTapCancel instead of onTapUp (even though the game widget receives onTapUp from Flutter).

Due to the fact that the switch from the current event system to the new event system is potentially a significant breaking change, the new event system is introduced as parallel to the existing one. This way we have more time to test the new system before recommending the switch and deprecating the old one; and the switch itself should feel more gradual.
2022-06-06 15:37:01 +00:00
f55b2e0dc0 feat: Callbacks in HudButtonComponent constructor and ViewportMargin mixin to avoid code duplication (#1685)
Created a mixin to handle the margin to the viewport, mostly to remove the code duplication in ButtonComponent and HudButtonComponent, but it can also be useful in other cases when you don't want to wrap your component in HudMarginComponent.

Once the new camera system is in place this will of course have to be replaced.
2022-06-04 17:00:12 +02:00
c64aedaeb3 feat: Aligned text in the TextBoxComponent (#1620)
- Added option align in the TextBoxComponent which controls the alignment of text.
 - Added option for the TextBoxComponent to have a fixed size (before the only mode was for the textbox to automatically expand/shrink to fit the text).
2022-06-03 23:21:40 +02:00
db336c03b6 feat: Children as argument to FlameGame (#1680)
Since we have already added children as an argument to Component, this adds it to the FlameGame.
2022-06-01 22:58:59 +02:00
1b40de094f feat: Add non_constant_identifier_names rule (#1656) 2022-05-26 20:07:37 +02:00
5f346fc51a docs: Add Padracing game to the examples (#1651) 2022-05-26 19:32:52 +02:00
489204ec68 chore: Move T-Rex to its own package (#1652) 2022-05-24 23:26:56 +02:00
c887c3616e feat: adding KeyboardListenerComponent (#1594) 2022-05-23 06:32:10 +00:00
821d01c3fa fix!: Game.mouseCursor and Game.overlays can now be safely set during onLoad (#1498) 2022-05-20 21:49:29 +02:00
e239896624 feat: Method componentsAtPoint now reports the "stacktrace" of points (#1615) 2022-05-17 20:52:43 +02:00
a448ec7dab fix: Broken links for flame_forge2d examples (#1631) 2022-05-16 16:12:56 +02:00
843ddc3624 refactor: Move to package imports (#1625)
* refactor: Move to package imports

* Fix local imports

* Removed unused imports
2022-05-15 15:04:35 +00:00
beac901313 feat: Bump to Flutter 2.10.0 (#1617) 2022-05-13 12:50:08 +02:00
c3bb14b7ca feat!: Added anchor for the Viewport (#1611) 2022-05-11 17:56:41 +00:00
4c68c2b0a2 feat: Add FpsComponent and FpsTextComponent (#1595) 2022-05-11 19:49:14 +02:00
f88200a1bf docs: Added the T-Rex example (#1602) 2022-05-08 20:07:33 +00:00
abb497abe4 feat: World bounds for a CameraComponent (#1605) 2022-05-08 18:36:56 +00:00
6dd0a970e6 docs: Move flame_forge2d examples to main examples (#1588) 2022-05-01 13:00:48 +00:00
666a2b199f feat: Adding classes for raw geometric shapes (#1528) 2022-04-27 17:39:50 +00:00
1bfed57132 feat!: Size effects will now work only on components implementing SizeProvider (#1571) 2022-04-27 19:10:01 +02:00
b99e35120d feat: Added componentsAtPoint() iterable (#1518) 2022-04-25 19:52:21 +02:00
295468f03c feat: Add Transform2D.setFrom and Transform2D.clone (#1495) 2022-03-27 21:48:26 +00:00
6891eaaa24 feat: adding ParticleSystemComponent (#1489) 2022-03-26 12:20:31 -03:00
4c3960c341 feat: Possibility to mark gesture events as handled (#1465) 2022-03-19 18:07:06 +01:00
e894d20133 fix: debugMode should be inherited from parent when mounted (#1469) 2022-03-19 16:13:50 +01:00
d51dc5e132 feat: Added .anchor property to CameraComponent.Viewfinder (#1458) 2022-03-18 09:08:51 +01:00
dfeafdd6f3 fix: Fix collision detection comments and typo (#1422)
* Fix collision detection comments and typo

* Update packages/flame/lib/src/collisions/collision_callbacks.dart

Co-authored-by: Pasha Stetsenko <stpasha@google.com>

* Update doc/flame/collision_detection.md

Co-authored-by: Pasha Stetsenko <stpasha@google.com>

Co-authored-by: Pasha Stetsenko <stpasha@google.com>
2022-03-08 14:38:21 +01:00
29dd09ca92 feat(collision detection)!: Use a broadphase to make collision detection more efficient (#1252) 2022-03-07 09:08:32 +01:00
c61a1c18b5 feat: Camera as a component (#1355) 2022-03-07 08:12:17 +01:00
c753fc4636 feat: Components are now always added in the correct order (#1337)
* wip o lifecycle

* Component.add() is no longer async

* fix a test

* game.ready

* fix analyze issues

* FcsRoot

* fix tests

* fix game-in-game example

* Merge _addImpl with add()

* Move some of the functionality from prepare() into add()

* Moved FcsRoot into component.dart and renamed

* more doc-comments

* dartdocs

* Remove addLater in ComponentSet

* format

* temporarily switch to path dependency in flame_test

* restore a test

* format

* get rid of prepare() in Collidable

* eliminate prepare() in Draggable

* eradicate prepare() in Hoverable

* remove prepare() from Tappable

* remove prepare() method and isPrepared flag

* remove prepareComponent() from HasCollidables

* remove prepareComponent

* make flame_bloc depend on latest flame

* try to solve flame_bloc dependency graph

* fix game resize issue

* fix gameresize for zoomed game

* do not allow zero size in onGameResize

* move onMount() call into add()

* use loadingBuilder when size is 0

* ComponentTreeRoot is now in its own file

* addToParent()

* switch to mount queue

* rename isReadyToMount -> isPrepared

* make isMounted and isPrepared readonly

* minor

* print error stacktrace

* Component.add() is now async

* fix tests

* unused import
;

* undo irrelevant changes in Component

* update tests

* tests cleanup

* format

* expand doc for ComponentTreeRoot

* fix analysis error

* added tests

* update docs

* resolve version conflict in pubspec

* Apply suggestions from code review

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>

* late final

* remount() function

* remove mountQueue

* simplify ready()

* run mount during children queue processing

* simplify mounting

* rename childrenQueue->childreQueues

* merge tryMounting() with remount()

* avoid statics in components lifecycle

* remove ComponentTreeRoot

* remove dead code

* added a todo

* added docs for SingleGameInstance

* Added tests for SingleGameInstance

* added SingleGameInstance to the main doc site

* Added test for multi-widget games

* cleanup

* use state variable in Component

* remove test as dependency

* upgrade mocktail version

* upgrade dartdoc version

* fix analyzer warnings

* mark staticgameinstance as internal

* remove ComponentSet.addChild

* use log() from dart:developer

* undo changes in flame_bloc/pubspec.yaml

* redo changes in flame_bloc/pubspec.yaml

* fix dependency in flame_test

* remove test dependencies

* update pubspec files

* remove dart_code_metrics from pubspec

* fix a test

* Added GameTester.makeReady

* omit type on class variable when it can be inferred

Co-authored-by: Erick <erickzanardoo@gmail.com>

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
Co-authored-by: Erick <erickzanardoo@gmail.com>
2022-02-14 23:22:44 +01:00
c92432895d feat: adding svg example (#1352) 2022-02-11 10:13:30 -03:00
fad9d1d54f feat: Added NoiseEffectController (#1356) 2022-02-06 13:43:12 +01:00
05f7a4c3d6 refactor: Remove Loadable, optional onLoads (#1333) 2022-01-24 23:23:12 +01:00
20776e8659 refactor: Loadable no longer declares onGameResize (#1329) 2022-01-22 10:58:43 +00:00
70b96b071a feat(gestures): Update scale events to contain pan info (#1327)
Since the ScaleDetector is a superset of the PanDetector we need to include pan info in the scale events too
2022-01-22 11:45:42 +01:00
27adda17b7 fix!: Remove pointerId from Draggable callbacks (#1313)
Since pointerId is already handled by the handle* methods we don't have to expose it in the onDrag* methods, this conforms with the standard set in Tappable.
2022-01-18 23:22:10 +01:00
d77e5efee5 refactor: Use canvas.drawImageNine in NineTileBox (#1314)
`canvas.drawImageNine` is built-in now a lot of logic was removed from NineTileBox.
2022-01-17 00:22:51 +01:00
2fbfd3d605 feat: Dual Effect & Its separate removals (#1289) 2022-01-07 17:39:50 +01:00
c888703d6e feat(effects): Added SineEffectController (#1262)
An effect controller that represents a single period of the sine function. Use this to create
natural-looking harmonic oscillations. Two perpendicular move effects governed by
SineEffectControllers with different periods, will create a [Lissajous curve].
2021-12-28 00:12:39 +01:00
7c6ae6def3 feat(effects)!: Added SequenceEffect (#1218)
Added SequenceEffect, which performs a series of other effects.

The biggest challenge in implementing this feature came from the need to run the sequence in reverse, due to the alternate flag. This required that every effect and every controller supported running "back in time", which is not as simple as it sounds.

The following breaking changes were introduced:

    The Effect class no longer supports .reverse() method and .isReversed flag.

    This flag was added only 2 weeks ago (

Effect controllers restructuring #1134), with the idea that it will be necessary for the SequenceEffect. However, as it turned out, this flag is not as helpful as I thought it would be. In fact, given the user's ability to change it any point, it makes the implementation very error-prone.

To be clear, the ability for each effect to run in reverse remains -- only now it can no longer be triggered by the user manually. Instead, SequenceEffect triggers that ability itself at the alternation point. If there is demand in the future to manually force any effect to run backwards, we could restore this flag, but this would require thorough testing to make it work correctly.

Infinite effects now return duration = double.infinity instead of null, which seems more appropriate.
2021-12-27 21:57:48 +01:00
59adc5f34c feat(effects): Added ZigzagEffectController (#1261)
Simple alternating effect controller. Over the course of one period, this controller will proceed
linearly from 0 to 1, then to -1, and then back to 0. Use this for oscillating effects where the
starting position should be the center of the oscillations, rather than the extreme (as provided
by the standard alternating EffectController).
2021-12-27 17:19:18 +00:00