Skip to content

Commit

Permalink
feat!: Refactor everything to use behaviors, and simplify base classes (
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtome authored Aug 18, 2024
1 parent 8715700 commit b5eef12
Show file tree
Hide file tree
Showing 40 changed files with 534 additions and 449 deletions.
3 changes: 1 addition & 2 deletions examples/standard_platformer/lib/basic_ladder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import 'package:flame/components.dart';
import 'package:flame/flame.dart';
import 'package:flame/image_composition.dart';
import 'package:leap/leap.dart';
import 'package:leap_standard_platformer/main.dart';
import 'package:tiled/tiled.dart';

class BasicLadder extends Ladder<ExamplePlatformerLeapGame> {
class BasicLadder extends Ladder {
BasicLadder(Image tileset, {required super.tiledObject})
: super.fromTiledObject(topExtraHitbox: 4) {
width = 16 * 2; // this is the width of our ladder sprite
Expand Down
2 changes: 1 addition & 1 deletion examples/standard_platformer/lib/door.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:leap/leap.dart';
import 'package:leap_standard_platformer/main.dart';
import 'package:tiled/tiled.dart';

class Door extends PhysicalEntity<ExamplePlatformerLeapGame> {
class Door extends PhysicalEntity with HasGameRef<ExamplePlatformerLeapGame> {
Door(TiledObject object, ObjectGroup layer)
: super(
position: Vector2(object.x, object.y),
Expand Down
3 changes: 1 addition & 2 deletions examples/standard_platformer/lib/info_text.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'package:flame/components.dart';
import 'package:flutter/material.dart';
import 'package:leap/leap.dart';
import 'package:leap_standard_platformer/main.dart';
import 'package:tiled/tiled.dart';

class InfoText extends PhysicalEntity<ExamplePlatformerLeapGame> {
class InfoText extends PhysicalEntity {
InfoText(TiledObject object)
: super(
position: Vector2(object.x, object.y),
Expand Down
8 changes: 6 additions & 2 deletions examples/standard_platformer/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void main() {
}

class ExamplePlatformerLeapGame extends LeapGame
with TapCallbacks, HasKeyboardHandlerComponents {
with SingleGameInstance, TapCallbacks, HasKeyboardHandlerComponents {
ExamplePlatformerLeapGame({
required super.tileSize,
}) : super(world: LeapWorld());
Expand Down Expand Up @@ -53,7 +53,7 @@ class ExamplePlatformerLeapGame extends LeapGame

@override
Future<void> onLoad() async {
await super.onLoad();
super.onLoad();

tiledObjectHandlers = {
'Coin': await CoinFactory.createFactory(),
Expand All @@ -76,7 +76,11 @@ class ExamplePlatformerLeapGame extends LeapGame

input = ThreeButtonInput();
add(input);
}

@override
Future<void> onMount() async {
super.onMount();
await _loadLevel();

// Don't let the camera move outside the bounds of the map, inset
Expand Down
Loading

0 comments on commit b5eef12

Please sign in to comment.