Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.9.6 #533

Merged
merged 11 commits into from
Jun 20, 2024
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# 3.9.5
# 3.9.6
- Fix jump animation showing instead of run/idle animation on slanting floors
- Fix above layer bug [#532](https://github.com/RafaelBarbosatec/bonfire/issues/532)
- Fix tile rotation bug. [#531](https://github.com/RafaelBarbosatec/bonfire/issues/531) [#530](https://github.com/RafaelBarbosatec/bonfire/issues/530)

# 3.9.5
- Fix Joystick bug when viewport is fixed resolution. [#526](https://github.com/RafaelBarbosatec/bonfire/issues/526)
- Add guard in `FlyingAttackGameObject` to prevent calling `onDestroy` after component has been destroyed.

# 3.9.4
- Fix bug in `FollowerWidget`.
Expand Down
14 changes: 7 additions & 7 deletions example/assets/images/tiled/tiled_example.tmj
Original file line number Diff line number Diff line change
Expand Up @@ -56,55 +56,55 @@
"name":"objects",
"objects":[
{
"class":"",
"height":16,
"id":2,
"name":"spikes",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":32.5,
"y":156.5
},
{
"class":"",
"height":16,
"id":6,
"name":"spikes",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":44.5,
"y":64
},
{
"class":"",
"height":16,
"id":7,
"name":"spikes",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":114.5,
"y":109.5
},
{
"class":"",
"height":16,
"id":8,
"name":"torch",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":48.1666666666667,
"y":15.8333333333333
},
{
"class":"",
"height":16,
"id":9,
"name":"torch",
"rotation":0,
"type":"",
"visible":true,
"width":16,
"x":95.3333333333333,
Expand All @@ -120,7 +120,7 @@
"nextobjectid":10,
"orientation":"orthogonal",
"renderorder":"right-down",
"tiledversion":"1.9.0",
"tiledversion":"1.10.2",
"tileheight":16,
"tilesets":[
{
Expand All @@ -129,6 +129,6 @@
}],
"tilewidth":16,
"type":"map",
"version":"1.9",
"version":"1.10",
"width":10
}
4 changes: 2 additions & 2 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.9.0"
version: "3.9.5"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -560,5 +560,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.3.0-0 <4.0.0"
dart: ">=3.4.0 <4.0.0"
flutter: ">=3.19.0"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: none
version: 1.0.0+1

environment:
sdk: ">=2.12.0-0 <3.0.0"
sdk: ">=3.4.0 <4.0.0"

dependencies:
flutter:
Expand Down
9 changes: 9 additions & 0 deletions lib/map/base/tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,15 @@ class Tile {
tile.id = id;
tile.angle = angle;
tile.opacity = opacity;

if (angle != 0) {
tile.anchor = Anchor.center;
tile.position = tile.position +
Vector2(
width / 2,
height / 2,
);
}
if (isFlipHorizontal) {
tile.flipHorizontallyAroundCenter();
}
Expand Down
1 change: 1 addition & 0 deletions lib/map/base/tile_layer_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class TileLayerComponent extends PositionComponent with HasPaint {
}

void initLayer(Vector2 gameSize, Vector2 screenSize) {
if (gameSize.isZero()) return;
_createQuadTree(gameSize, screenSize);
}

Expand Down
3 changes: 1 addition & 2 deletions lib/map/tiled/builder/tiled_world_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class TiledWorldBuilder {
return Future.value(
WorldBuildData(
map: WorldMap(
_layers,
_layers.where((e) => e.tiles.isNotEmpty).toList(),
tileSizeToUpdate: sizeToUpdate,
),
components: _components,
Expand Down Expand Up @@ -341,7 +341,6 @@ class TiledWorldBuilder {
tileSetContain,
(index - tilesetFirsTgId),
);

return TiledItemTileSet(
type: object.type,
collisions: object.collisions,
Expand Down
32 changes: 29 additions & 3 deletions lib/mixins/jumper.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:bonfire/bonfire.dart';
import 'package:bonfire/util/collision_game_component.dart';

enum JumpingStateEnum {
up,
Expand All @@ -20,6 +21,9 @@ mixin Jumper on Movement, BlockMovementCollision {
int _maxJump = 1;
int _currentJumps = 0;
JumpingStateEnum? _lastDirectionJump = JumpingStateEnum.idle;
int _tileCollisionCount = 0;

static const _tileCollisionCountKey = 'tileCollisionCount';

void onJump(JumpingStateEnum state) {
jumpingState = state;
Expand All @@ -42,22 +46,44 @@ mixin Jumper on Movement, BlockMovementCollision {
PositionComponent other,
CollisionData collisionData,
) {
super.onBlockedMovement(other, collisionData);
if (isJumping &&
lastDirectionVertical.isDownSide &&
collisionData.direction.isDownSide) {
_currentJumps = 0;
isJumping = false;
}
super.onBlockedMovement(other, collisionData);
}

@override
void onCollisionStart(
Set<Vector2> intersectionPoints, PositionComponent other) {
if (other is CollisionMapComponent || other is TileWithCollision) {
++_tileCollisionCount;
resetInterval(_tileCollisionCountKey);
}
super.onCollisionStart(intersectionPoints, other);
}

@override
void onCollisionEnd(PositionComponent other) {
if (other is CollisionMapComponent || other is TileWithCollision) {
if (--_tileCollisionCount == 0) resetInterval(_tileCollisionCountKey);
}
super.onCollisionEnd(other);
}

@override
void update(double dt) {
super.update(dt);
if (!isJumping && displacement.y.abs() > 0.2) {
if (checkInterval(_tileCollisionCountKey, 100, dt,
firstCheckIsTrue: false) &&
!isJumping &&
_tileCollisionCount == 0 &&
displacement.y.abs() > 0.2) {
isJumping = true;
}
_notifyJump();
super.update(dt);
}

void _notifyJump() {
Expand Down
21 changes: 8 additions & 13 deletions lib/objects/flying_attack_game_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,14 @@ class FlyingAttackGameObject extends AnimatedGameObject
}

void _destroyObject(GameComponent component) {
if (isRemoving) return;
if (isRemoving || isRemoved) return;
removeFromParent();
if (animationDestroy != null) {
if (direction != null) {
_destroyByDirection(direction!, dtUpdate, component);
final currentDirection = direction;
if (currentDirection != null) {
_destroyByDirection(currentDirection);
} else {
_destroyByAngle(component);
_destroyByAngle();
}
}
removeAll(children);
Expand All @@ -149,11 +150,7 @@ class FlyingAttackGameObject extends AnimatedGameObject
return gameRef.map.toRect().contains(center.toOffset());
}

void _destroyByDirection(
Direction direction,
double dt,
GameComponent component,
) {
void _destroyByDirection(Direction direction) {
Vector2 positionDestroy;

double biggerSide = max(width, height);
Expand Down Expand Up @@ -236,12 +233,11 @@ class FlyingAttackGameObject extends AnimatedGameObject
innerSize.x,
innerSize.y,
),
component,
);
}
}

void _destroyByAngle(GameComponent component) {
void _destroyByAngle() {
double nextX = (width / 2) * _cosAngle;
double nextY = (height / 2) * _senAngle;

Expand Down Expand Up @@ -277,12 +273,11 @@ class FlyingAttackGameObject extends AnimatedGameObject
innerSize.x,
innerSize.y,
),
component,
);
}
}

void _applyDestroyDamage(Rect rectPosition, GameComponent component) {
void _applyDestroyDamage(Rect rectPosition) {
gameRef.add(
DamageHitbox(
id: id,
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.9.5
version: 3.9.6
homepage: https://bonfire-engine.github.io
repository: https://github.com/RafaelBarbosatec/bonfire
issue_tracker: https://github.com/RafaelBarbosatec/bonfire/issues
Expand Down
Loading