-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding a "menu" map to start in for the example game and doors …
…to move between (#29)
- Loading branch information
Showing
11 changed files
with
429 additions
and
84 deletions.
There are no files selected for viewing
Binary file modified
BIN
-7.59 KB
(76%)
examples/standard_platformer/assets/images/level_ice_tileset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 34 additions & 7 deletions
41
.../standard_platformer/assets/tiles/map.tmx → ...latformer/assets/tiles/map_everything.tmx
Large diffs are not rendered by default.
Oops, something went wrong.
152 changes: 84 additions & 68 deletions
152
...tandard_platformer/assets/tiles/map_2.tmx → ...d_platformer/assets/tiles/map_ladders.tmx
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,41 @@ | ||
import 'package:flame/components.dart'; | ||
import 'package:leap/leap.dart'; | ||
import 'package:leap_standard_platformer/main.dart'; | ||
import 'package:tiled/tiled.dart'; | ||
|
||
class Door extends PhysicalEntity<ExamplePlatformerLeapGame> { | ||
Door(TiledObject object, ObjectGroup layer) | ||
: super( | ||
position: Vector2(object.x, object.y), | ||
size: Vector2(object.width, object.height), | ||
collisionType: CollisionType.standard, | ||
) { | ||
destinationMap = object.properties.getValue<String>('DestinationMap'); | ||
final destinationObjectId = | ||
object.properties.getValue<int>('DestinationObject'); | ||
if (destinationObjectId != null) { | ||
destinationObject = | ||
layer.objects.firstWhere((obj) => obj.id == destinationObjectId); | ||
} | ||
} | ||
|
||
late final String? destinationMap; | ||
late final TiledObject? destinationObject; | ||
|
||
void enter(PhysicalEntity other) { | ||
if (destinationMap != null) { | ||
game.goToLevel(destinationMap!); | ||
} else if (destinationObject != null) { | ||
other.x = destinationObject!.x; | ||
other.y = destinationObject!.y; | ||
} | ||
} | ||
} | ||
|
||
class DoorFactory implements TiledObjectHandler { | ||
@override | ||
void handleObject(TiledObject object, Layer layer, LeapMap map) { | ||
final component = Door(object, layer as ObjectGroup); | ||
map.add(component); | ||
} | ||
} |
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,59 @@ | ||
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> { | ||
InfoText(TiledObject object) | ||
: super( | ||
position: Vector2(object.x, object.y), | ||
size: Vector2(object.width, object.height), | ||
collisionType: CollisionType.standard, | ||
) { | ||
text = object.properties.getValue<String>('Text') ?? | ||
'Lorem ipsum mising text.'; | ||
} | ||
|
||
late final String text; | ||
TextBoxComponent? textBoxComponent; | ||
|
||
TextBoxComponent _buildTextBox() { | ||
return TextBoxComponent( | ||
text: text, | ||
// size: Vector2(160, 32), | ||
position: Vector2(-16, -48), | ||
boxConfig: | ||
TextBoxConfig(dismissDelay: 3, margins: const EdgeInsets.all(4)), | ||
textRenderer: TextPaint( | ||
style: TextStyle( | ||
fontSize: 8, | ||
backgroundColor: Colors.black.withOpacity(0.4), | ||
), | ||
), | ||
); | ||
} | ||
|
||
void activateText() { | ||
if (textBoxComponent == null) { | ||
textBoxComponent = _buildTextBox(); | ||
add(textBoxComponent!); | ||
} | ||
} | ||
|
||
@override | ||
void update(double dt) { | ||
if (textBoxComponent?.finished ?? false) { | ||
textBoxComponent!.removeFromParent(); | ||
textBoxComponent = null; | ||
} | ||
} | ||
} | ||
|
||
class InfoTextFactory implements TiledObjectHandler { | ||
@override | ||
void handleObject(TiledObject object, Layer layer, LeapMap map) { | ||
final component = InfoText(object); | ||
map.add(component); | ||
} | ||
} |
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
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