Skip to content

Commit

Permalink
increment version
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelBarbosatec committed Nov 24, 2023
1 parent e5be5b8 commit d7543d0
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 14 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Next
## 3.0.10
- Create mixin `MovePerCell`.
- Create mixin `CanNotSeen`. Use it to turn your component not detectable from `Vision` mixin.
- Update `showDamage` method.`initVelocityUp` renamed to `initVelocityVertical` and adds param `initVelocityHorizontal`.
- Fix issue [#455](https://github.com/RafaelBarbosatec/bonfire/issues/455)
- Fix bug [#474](https://github.com/RafaelBarbosatec/bonfire/issues/474)

## 3.0.9
- adds new Pushable configurations. (`pushableFrom`,`pushPerCellEnabled`,`cellSize`,`pushPerCellDuration`,`pushPerCellCurve`)
Expand Down
2 changes: 1 addition & 1 deletion example/lib/shared/decoration/potion_life.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PotionLife extends GameDecoration with Sensor<Player>, Movement {

@override
void onMount() {
generateValues(
gameRef.generateValues(
const Duration(seconds: 1),
onChange: (value) {
spriteOffset = Vector2(0, 5 * -value);
Expand Down
28 changes: 28 additions & 0 deletions lib/base/bonfire_game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,34 @@ class BonfireGame extends BaseGame implements BonfireGameInterface {
);
}

/// Used to generate numbers to create your animations or anythings
@override
ValueGeneratorComponent generateValues(
Duration duration, {
double begin = 0.0,
double end = 1.0,
Curve curve = Curves.linear,
Curve? reverseCurve,
bool autoStart = true,
bool infinite = false,
VoidCallback? onFinish,
ValueChanged<double>? onChange,
}) {
final valueGenerator = ValueGeneratorComponent(
duration,
end: end,
begin: begin,
curve: curve,
reverseCurve: reverseCurve,
onFinish: onFinish,
onChange: onChange,
autoStart: autoStart,
infinite: infinite,
);
add(valueGenerator);
return valueGenerator;
}

void _optimizeCollisionTree() {
scheduleMicrotask(
() => collisionDetection.broadphase.tree.optimize(),
Expand Down
13 changes: 13 additions & 0 deletions lib/base/bonfire_game_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ abstract class BonfireGameInterface {
List<RaycastResult<ShapeHitbox>>? out,
});

/// Used to generate numbers to create your animations or anythings
ValueGeneratorComponent generateValues(
Duration duration, {
double begin = 0.0,
double end = 1.0,
Curve curve = Curves.linear,
Curve? reverseCurve,
bool autoStart = true,
bool infinite = false,
VoidCallback? onFinish,
ValueChanged<double>? onChange,
});

void startScene(List<SceneAction> actions, {void Function()? onComplete});
void stopScene();

Expand Down
13 changes: 12 additions & 1 deletion lib/mixins/vision.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ mixin Vision on GameComponent {
GameComponent component,
double radiusVision,
) {
if (component.isRemoving) {
if (component.isRemoving || component is CanNotSeen) {
return false;
}

Expand All @@ -82,6 +82,7 @@ mixin Vision on GameComponent {
direction,
maxDistance: radiusVision,
origin: myCenter,
ignoreHitboxes: _getCanNotSeenHitbox(),
);
return result?.hitbox?.parent == component;
}
Expand Down Expand Up @@ -209,4 +210,14 @@ mixin Vision on GameComponent {
}
return shape;
}

List<ShapeHitbox> _getCanNotSeenHitbox() {
var sensorHitBox = <ShapeHitbox>[];
gameRef.query<CanNotSeen>(onlyVisible: true).forEach((e) {
sensorHitBox.addAll(e.children.query<ShapeHitbox>());
});
return sensorHitBox;
}
}

mixin CanNotSeen on GameComponent {}
2 changes: 1 addition & 1 deletion lib/objects/flying_attack_game_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter/widgets.dart';

/// Animated component used like range attack.
class FlyingAttackGameObject extends AnimatedGameObject
with Movement, BlockMovementCollision {
with Movement, BlockMovementCollision, CanNotSeen {
final dynamic id;
Future<SpriteAnimation>? animationDestroy;
final Direction? direction;
Expand Down
6 changes: 4 additions & 2 deletions lib/util/extensions/game_component_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ extension GameComponentExtensions on GameComponent {
void showDamage(
double damage, {
TextStyle? config,
double initVelocityUp = -5,
double initVelocityVertical = -5,
double initVelocityHorizontal = 1,
double gravity = 0.5,
double maxDownSize = 20,
DirectionTextDamage direction = DirectionTextDamage.RANDOM,
Expand All @@ -24,7 +25,8 @@ extension GameComponentExtensions on GameComponent {
fontSize: 14,
color: Color(0xFFFFFFFF),
),
initVelocityUp: initVelocityUp,
initVelocityVertical: initVelocityVertical,
initVelocityHorizontal: initVelocityHorizontal,
gravity: gravity,
direction: direction,
onlyUp: onlyUp,
Expand Down
23 changes: 16 additions & 7 deletions lib/util/text_damage_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class TextDamageComponent extends TextComponent with BonfireHasGameRef {
Vector2 position, {
this.onlyUp = false,
TextStyle? config,
double initVelocityUp = -4,
double initVelocityVertical = -4,
double initVelocityHorizontal = 1,
this.maxDownSize = 20,
this.gravity = 0.5,
this.direction = DirectionTextDamage.RANDOM,
Expand All @@ -37,16 +38,17 @@ class TextDamageComponent extends TextComponent with BonfireHasGameRef {
position: position,
) {
_initialY = position.y;
_velocity = initVelocityUp;
_velocity = initVelocityVertical;
switch (direction) {
case DirectionTextDamage.LEFT:
_moveAxisX = 1;
_moveAxisX = initVelocityHorizontal;
break;
case DirectionTextDamage.RIGHT:
_moveAxisX = -1;
_moveAxisX = initVelocityHorizontal * -1;
break;
case DirectionTextDamage.RANDOM:
_moveAxisX = Random().nextInt(100) % 2 == 0 ? -1 : 1;
_moveAxisX =
initVelocityHorizontal * Random().nextInt(100) % 2 == 0 ? -1 : 1;
break;
case DirectionTextDamage.NONE:
break;
Expand All @@ -70,8 +72,15 @@ class TextDamageComponent extends TextComponent with BonfireHasGameRef {
if (onlyUp && _velocity >= 0) {
removeFromParent();
}
if (position.y > _initialY + maxDownSize) {
removeFromParent();

if (gravity > 0) {
if (position.y > _initialY + maxDownSize) {
removeFromParent();
}
} else if (gravity < 0) {
if (position.y < _initialY - maxDownSize) {
removeFromParent();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: bonfire
description: (RPG maker) Create RPG-style or similar games more simply with Flame.
version: 3.0.9
version: 3.0.10
homepage: https://bonfire-engine.github.io
repository: https://github.com/RafaelBarbosatec/bonfire
issue_tracker: https://github.com/RafaelBarbosatec/bonfire/issues
Expand Down

0 comments on commit d7543d0

Please sign in to comment.