Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
add postbox
Browse files Browse the repository at this point in the history
  • Loading branch information
OlliePugh committed Mar 11, 2024
1 parent 35fe201 commit 3c1bd5c
Show file tree
Hide file tree
Showing 10 changed files with 592 additions and 556 deletions.
Binary file modified packages/trashy_road/assets/images/sprites/bus_stop-shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/trashy_road/assets/images/sprites/post_box-shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions packages/trashy_road/assets/tiles/Tiles.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.9" tiledversion="1.10.2" name="Tiles" tilewidth="768" tileheight="1024" tilecount="33" columns="0">
<tileset version="1.9" tiledversion="1.10.2" name="Tiles" tilewidth="768" tileheight="1024" tilecount="34" columns="0">
<grid orientation="orthogonal" width="1" height="1"/>
<tile id="2">
<image width="128" height="128" source="../images/sprites/apple_core_1.png"/>
Expand Down Expand Up @@ -32,7 +32,7 @@
<image width="512" height="768" source="../images/sprites/building_2.png"/>
</tile>
<tile id="18">
<image width="256" height="384" source="../images/sprites/building_4.png"/>
<image width="768" height="1024" source="../images/sprites/building_4.png"/>
</tile>
<tile id="19">
<image width="512" height="256" source="../images/sprites/bench.png"/>
Expand Down Expand Up @@ -100,4 +100,7 @@
<tile id="41">
<image width="256" height="256" source="../images/sprites/bus_stop.png"/>
</tile>
<tile id="48">
<image width="128" height="128" source="../images/sprites/post_box.png"/>
</tile>
</tileset>
318 changes: 176 additions & 142 deletions packages/trashy_road/assets/tiles/map1.tmx

Large diffs are not rendered by default.

254 changes: 114 additions & 140 deletions packages/trashy_road/assets/tiles/map3.tmx

Large diffs are not rendered by default.

517 changes: 246 additions & 271 deletions packages/trashy_road/assets/tiles/map4.tmx

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions packages/trashy_road/assets/tiles/post_box.tx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<tileset firstgid="1" source="Tiles.tsx"/>
<object class="post_box" gid="49" width="128" height="128"/>
</template>
10 changes: 10 additions & 0 deletions packages/trashy_road/lib/gen/assets.gen.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions packages/trashy_road/lib/src/game/entities/obstacle/obstacle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@ class Obstacle extends PositionedEntity with Untraversable, ZIndex {
children: [_BusStopSpriteGroup()],
);

// A Obstacle that is an post box.
//
// The postbox takes up 1x2 tile space
Obstacle._postBox({required Vector2 position})
: this._(
position: position,
hitbox: RectangleHitbox(
position: Vector2(0.2, -0.1)..toGameSize(),
size: Vector2(0.6, 0.6)..toGameSize(),
),
children: [_PostBoxSpriteGroup()],
);

factory Obstacle.fromTiledObject(TiledObject tiledObject) {
final type = tiledObject.type;
final position = Vector2(tiledObject.x, tiledObject.y);
Expand Down Expand Up @@ -195,6 +208,8 @@ class Obstacle extends PositionedEntity with Untraversable, ZIndex {
return Obstacle._lampPost(position: position);
case 'bus_stop':
return Obstacle._busStop(position: position);
case 'post_box':
return Obstacle._postBox(position: position);
default:
throw ArgumentError('Unknown obstacle type: $type');
}
Expand Down Expand Up @@ -493,3 +508,23 @@ class _BusStopSpriteGroup extends PositionComponent {
],
);
}

class _PostBoxSpriteGroup extends PositionComponent {
_PostBoxSpriteGroup()
: super(
// The `size`, `position` and `scale` have been eye-balled to fit with
// the tile size.
position: Vector2(0.15, -0.1)..toGameSize(),
scale: Vector2.all(0.6),
children: [
GameSpriteComponent.fromPath(
anchor: Anchor.bottomLeft,
spritePath: Assets.images.sprites.postBoxShadow.path,
),
GameSpriteComponent.fromPath(
anchor: Anchor.bottomLeft,
spritePath: Assets.images.sprites.postBox.path,
),
],
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Player extends PositionedEntity with ZIndex {
PropagatingCollisionBehavior(
RectangleHitbox(
isSolid: true,
size: Vector2(0.5, 0.8)..toGameSize(),
size: Vector2(0.3, 0.6)..toGameSize(),
anchor: Anchor.center,
),
),
Expand Down

0 comments on commit 3c1bd5c

Please sign in to comment.