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

Commit

Permalink
feat: add handdrawn stars (#317)
Browse files Browse the repository at this point in the history
* feat: add handdrawn stars

* chore: new assets

* chore: ignores

---------

Co-authored-by: Ollie Pugh <[email protected]>
  • Loading branch information
alestiago and OlliePugh authored Mar 11, 2024
1 parent ec02e4f commit e5c60b3
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 21 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 26 additions & 10 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.

22 changes: 16 additions & 6 deletions packages/trashy_road/lib/src/maps/widgets/game_map_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,21 @@ class _Stars extends StatelessWidget {

final int value;

static final _random = Random();
static final _filledIimages = [
Assets.images.display.starFilledGolden1,
Assets.images.display.starFilledGolden2,
];
static final _emptyIimages = [
Assets.images.display.starEmpty1,
Assets.images.display.starEmpty2,
];

@override
Widget build(BuildContext context) {
SvgGenImage star({required bool filled}) => filled
? Assets.images.display.starFilled
: Assets.images.display.starEmpty;
AssetGenImage star({required bool filled}) => filled
? _filledIimages[_random.nextInt(_filledIimages.length)]
: _emptyIimages[_random.nextInt(_emptyIimages.length)];

return LayoutBuilder(
builder: (context, constraints) {
Expand All @@ -110,12 +120,12 @@ class _Stars extends StatelessWidget {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
star(filled: value >= 1).svg(width: starWidth),
star(filled: value >= 1).image(width: starWidth),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 5),
child: star(filled: value >= 2).svg(width: starWidth),
child: star(filled: value >= 2).image(width: starWidth),
),
star(filled: value >= 3).svg(width: starWidth),
star(filled: value >= 3).image(width: starWidth),
],
);
},
Expand Down
13 changes: 8 additions & 5 deletions packages/trashy_road/web/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html>

<head>
<!--
If you are serving your web app in a path other than the root, change the
Expand Down Expand Up @@ -27,7 +28,7 @@
<link rel="apple-touch-icon" href="icons/Icon-192.png">

<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/>
<link rel="icon" type="image/png" href="favicon.png" />

<title>trashy_road</title>
<link rel="manifest" href="manifest.json">
Expand All @@ -39,21 +40,23 @@
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>
</head>

<body>
<script>
window.addEventListener('load', function(ev) {
window.addEventListener('load', function (ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
},
onEntrypointLoaded: function(engineInitializer) {
engineInitializer.initializeEngine().then(function(appRunner) {
onEntrypointLoaded: function (engineInitializer) {
engineInitializer.initializeEngine().then(function (appRunner) {
appRunner.runApp();
});
}
});
});
</script>
</body>
</html>

</html>

0 comments on commit e5c60b3

Please sign in to comment.