-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/jcasanoval/flame-game-jam-2024
- Loading branch information
Showing
6 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export 'log/log.dart'; | ||
export 'fireplace/fireplace.dart'; | ||
export 'log/log.dart'; | ||
export 'tree/tree.dart'; | ||
export 'unicorn/unicorn.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flame/collisions.dart'; | ||
import 'package:flame/components.dart'; | ||
import 'package:flame_behaviors/flame_behaviors.dart'; | ||
import 'package:game_jam_2024/game/game.dart'; | ||
import 'package:game_jam_2024/gen/assets.gen.dart'; | ||
|
||
class Tree extends PositionedEntity with HasGameRef<VeryGoodFlameGame> { | ||
Tree({ | ||
required super.position, | ||
}) : super( | ||
anchor: Anchor.center, | ||
size: Vector2(60, 60), | ||
behaviors: [], | ||
priority: 11, | ||
); | ||
|
||
/// Wether the log is near the player or not. | ||
/// | ||
/// The log is considered to be near the player if the player is colliding with | ||
/// it. | ||
bool nearPlayer = false; | ||
|
||
late SpriteComponent _spriteComponent; | ||
|
||
@override | ||
FutureOr<void> onLoad() async { | ||
final sprite = await gameRef.loadSprite( | ||
Assets.images.tree.path, | ||
srcSize: Vector2(96, 96), | ||
); | ||
|
||
await addAll([ | ||
_spriteComponent = SpriteComponent( | ||
sprite: sprite, | ||
size: super.size, | ||
anchor: Anchor.center, | ||
), | ||
RectangleHitbox() | ||
..anchor = Anchor.center | ||
..isSolid = true, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.