154 Commits

Author SHA1 Message Date
6b78b10fb3 feat: Add optional maxDistance to raycast (#2012)
This PR adds an optional parameter to raycast API called maxDistance. Using this parameter users can control the limit within which raycast scans for hits.
2022-10-07 14:13:42 +02:00
475b226911 docs: Fixed broken example links (#2030) 2022-10-06 10:15:32 +02:00
e33d5410a3 feat: quad tree broadphase support (#1894)
Quad tree broadphase support.
2022-09-27 13:53:27 +02:00
6410dc753c feat: Animated tile support! (#1930)
Tiled supports animated tiles, and now Flame does as well...
2022-09-23 16:55:15 +02:00
deccb4349d feat: Add avoid_final_parameters, depend_on_referenced_packages, unnecessary_to_list_in_spreads (#1927)
Adds these three sensible rules:

avoid_final_parameters

depend_on_referenced_package

unnecessary_to_list_in_spreads
2022-09-20 21:23:43 +02:00
720c3566b0 feat: Add lookAt method for PositionComponent (#1891)
This PR adds a new method called lookAt for PositionComponent. It is a convenience method which rotates the component to make it point towards/look at the given target position.

Additionally, this PR also adds a angleTo method which can be used to get the calculated angle for lookAt. It will be useful if someone want to smoothly rotate towards target using effects or manual lerping.
2022-09-18 20:57:07 +02:00
5bdb2a1ec8 docs: Improve keyboard input examples (#1907)
This PR updates the live keyboard examples to correctly handle multiple key inputs. This was discovered in #847.
2022-09-15 08:13:05 +02:00
f34d86db1e feat: Adding ClipComponent (#1769)
Adds a new component called ClipComponent that clips the canvas area based on its size and shape.
2022-09-13 12:52:11 +00:00
b1a6dd18f2 docs: Added bouncing ball example in collision_detection examples and updated flame_forge2d to latest (#1868)
This PR adds two updates.

It updates the flame_forge2d to latest version i.e on pub.dev in examples and padracing projects.

Adds a bouncing ball example in the collision detection examples demonstrating a simple example of collision and bouncing of a ball from the walls around it.
2022-08-29 09:34:33 +00:00
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