Skip to content

Commit

Permalink
Merge pull request #30 from hib4/development
Browse files Browse the repository at this point in the history
feat: game introduction
  • Loading branch information
hib4 authored Mar 5, 2024
2 parents 1560c1b + 98fd016 commit 812493f
Show file tree
Hide file tree
Showing 33 changed files with 462 additions and 128 deletions.
29 changes: 17 additions & 12 deletions .firebase/hosting.YnVpbGRcd2Vi.cache
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
favicon.png,1709208642649,26f1c1828d36e27872324b5ccaea22889a40c618366d1b2833a71aa878195c4d
flutter.js,1709168971096,f5a14edb95c81962fa23eaaae56e126c490103fa2f18b3ad825460cbdc0f9e4e
main.dart.js,1709215181428,716432a1ceea8ee1585d4c4e9cf72f92d5bb5cf9e691bfd2ed80a12f365f3620
manifest.json,1709208642652,214a53d67d983a2383d26576150c42067cca32fe6cf018a759b7e2cb238ce0b5
assets/assets/fonts/PressStart2P-Regular.ttf,1708441460425,aad3cbca70e10e800969e0669ca3aebb78bc48247c36688ac3600dff7f2a3fef
assets/assets/images/background_menu_desktop.png,1708441460428,07abcb1e0360fd81d00285b6e5c43a08e3885158ef58d948a35bc0028033bdef
Expand All @@ -20,7 +19,7 @@ assets/assets/sfx/collect.wav,1708441460580,d58397933088080cf0e97a1a9074563380ca
assets/assets/sfx/hit.wav,1708999258792,625dea313113faeeab006856697649f3da4cb905eabd7e5d69db9caed964e57b
assets/assets/sfx/hurt.wav,1709107293987,add216579f21be900b83176a2c628900895eacbb5fc791e95beec0ffb68b5dac
assets/assets/sfx/jump.wav,1708441460582,883a43ef6a45b33c25a2744c99b75d9543bcfa91c7a4a0b1401dfd95a6d135da
assets/assets/tiles/level_1.tmx,1709191674370,37c0c2700b82bc3a48eab9d6c38aaaef62d3d4c5c09b4414f268dc7229a8fc3f
assets/assets/tiles/level_1.tmx,1709220533322,863c0aad620729d09df69e58dbd7330b0541afe91e7aa8721595837f9055322f
assets/assets/tiles/level_2.tmx,1709191674371,b9ffc5fe479b263aefaf6775556d77cc501b6d3d7428921184002895697fc77e
assets/assets/tiles/level_3.tmx,1709191674372,f2ce52358824d5343c68fdb4afb079e045729fb7378e5020f57e7c7d14da9ad8
assets/assets/trivia/trivia_en.json,1708441460585,ed3506f63cde913b4afb4e0c7a3d753d7bc15536366a757d6994fd4357587631
Expand Down Expand Up @@ -51,13 +50,19 @@ splash/img/light-1x.png,1709214035727,3e4554940ea49d4c1679fd1c42677182f19b4720fc
splash/img/light-2x.png,1709214035727,8b58c0baf5568be586fa3944b503aed6e720902b0996816f5231f0befceded59
splash/img/light-3x.png,1709214035728,faee9f7b8e4811f19ca4adfe19f1ed129dad94decd757aad57dfb2a3bb77333e
splash/img/light-4x.png,1709214035729,47c440b6b1d986394763ab121812455cb7433cdbbe3cc2398221f599569b9b32
version.json,1709216373909,5739517e956238b275c3f8508287a3f94f0305474803728e58bf9fa1af596a83
assets/AssetManifest.bin.json,1709216374093,3ab4b7f2d3375f84fc2cd16a3d2ec28e0d1e3005bffb09d4fe00c7abe4145345
flutter_service_worker.js,1709216376110,9ce79981e085b8922cf331e10968ed946b0d53207b00c9c163c5259a1a7ff318
index.html,1709216375576,54fe99aee554bb366af052286883a1d53bfa595427b8931a6410b635a1e6705e
assets/AssetManifest.bin,1709216374093,fd600ed8cdf3cab564481d0132a7a1ed2ff80493bf6a57c5a2756d98a8d3c782
assets/AssetManifest.json,1709216374093,2765184555a05b11074f4a1bb994dac2353d70ad674ade4712374d9bc62b7c38
assets/FontManifest.json,1709216374093,179eeab032efc6f507747d28f95f3868ac04cb1d06c7d92eeee048da9eaba116
assets/fonts/MaterialIcons-Regular.otf,1709216375562,ad24a3dd211aa3a9b14d0270b4fe6be13d97595d63df38ff5efe7c3c9df9e1b8
assets/shaders/ink_sparkle.frag,1709216374206,591c7517d5cb43eb91ea451e0d3f9f585cbf8298cf6c46a9144b77cb0775a406
assets/NOTICES,1709216374094,98cacea33da8b04bfb9ea862b168c67dcb4e29b29194484f660f9ad63f2521a9
index.html,1709520427874,f6c2d865946da9c91d8475f5cbff02a3ad114ae1bd713f599ef4bcbce26e6569
flutter_service_worker.js,1709520429088,0815007bd19d667aafc5cce84a365e8167297160654147db573e3cb811560d39
version.json,1709520425220,5739517e956238b275c3f8508287a3f94f0305474803728e58bf9fa1af596a83
assets/AssetManifest.bin,1709520426063,efe12612d721109ef76579e904df1dc39b5129738526c81e12cc9e72596a187d
assets/AssetManifest.bin.json,1709520426063,cd319060b33a2e4d367724e7628bab68c01c26590446bb53f98cfd5afd696d20
assets/AssetManifest.json,1709520426063,be756400c45b3ee5e805abc5fbcacbe62bdb4e62bb74a39d33941af28cbfc356
assets/FontManifest.json,1709520426063,179eeab032efc6f507747d28f95f3868ac04cb1d06c7d92eeee048da9eaba116
assets/assets/waste/lila.png,1709364826016,a166c2ba7b548a4481302631bb4bbb871a9c4ea9bba37272ac350b2ab4050fde
assets/assets/waste/plastic_bag.png,1709364826016,092c37d1ce09f56cf6f19804b6c4b59eed005ed35190e882719dff7662387fd9
assets/assets/waste/plastic_cup.png,1709364826017,7d3ccfca4854e4ba69da381b64a06b75c3202260799dcf127e18aed4a1258c6d
assets/assets/waste/star.png,1709364826017,b97b7b3179203f6927b9223c2806af089383409d0c9f0da6e35dba0d8f3fb846
assets/assets/waste/trash_pile.png,1709364826018,f71812791bf5d74fac0b9f24bbc9c546d6df039b53869e65c68657ae9d85df2b
assets/shaders/ink_sparkle.frag,1709520426221,591c7517d5cb43eb91ea451e0d3f9f585cbf8298cf6c46a9144b77cb0775a406
assets/fonts/MaterialIcons-Regular.otf,1709520427851,ad24a3dd211aa3a9b14d0270b4fe6be13d97595d63df38ff5efe7c3c9df9e1b8
assets/NOTICES,1709520426065,5515aa7b70bf9447f0ea456350d0ff8225511e634f7244e34b02789f7629f9aa
main.dart.js,1709520424015,a5b740feae2f1ccd43fcafa22263f4c896c6943fb3476f5b3e9061db5d4c5ab4
Binary file modified android/app/src/production/res/drawable-night-v21/background.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 android/app/src/production/res/drawable-night/background.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 android/app/src/production/res/drawable-v21/background.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 android/app/src/production/res/drawable/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion android/app/src/production/res/values-night-v31/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<item name="android:windowFullscreen">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:windowSplashScreenBackground">#ffffff</item>
<item name="android:windowSplashScreenBackground">#fdfdf5</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/production/res/values-v31/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<item name="android:windowFullscreen">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:windowSplashScreenBackground">#ffffff</item>
<item name="android:windowSplashScreenBackground">#fdfdf5</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
Expand Down
Binary file added assets/waste/lila.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 added assets/waste/plastic_bag.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 added assets/waste/plastic_cup.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 added assets/waste/star.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 added assets/waste/trash_pile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions flutter_native_splash-production.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# To run: flutter pub run flutter_native_splash:create --flavor production

flutter_native_splash:
color: "#ffffff"
color: "#fdfdf5"
image: assets/images/splash_screen.png
color_dark: "#ffffff"
color_dark: "#fdfdf5"
image_dark: assets/images/splash_screen.png

android_12:
color: "#ffffff"
color: "#fdfdf5"
image: assets/images/splash_screen.png
color_dark: "#ffffff"
color_dark: "#fdfdf5"
image_dark: assets/images/splash_screen.png

ios: true
Expand Down
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.
7 changes: 6 additions & 1 deletion lib/app/view/app.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:garda_green/app_lifecycle/app_lifecycle.dart';
Expand All @@ -9,6 +10,7 @@ import 'package:garda_green/leaderboard/leaderboard.dart';
import 'package:garda_green/settings/settings.dart';
import 'package:garda_green/theme/app_colors.dart';
import 'package:garda_green/trivia/trivia.dart';
import 'package:garda_green/utils/utils.dart';
import 'package:nes_ui/nes_ui.dart';

class App extends StatelessWidget {
Expand All @@ -29,6 +31,7 @@ class App extends StatelessWidget {

@override
Widget build(BuildContext context) {
final isShowIntroduction = !context.isSmall && !kIsWeb;
return AppLifecycleObserver(
child: MultiRepositoryProvider(
providers: [
Expand Down Expand Up @@ -61,7 +64,9 @@ class App extends StatelessWidget {
title: 'Garda Green',
supportedLocales: AppLocalizations.supportedLocales,
localizationsDelegates: AppLocalizations.localizationsDelegates,
home: const MenuPage(),
home: MenuPage(
isShowIntroduction: !isShowIntroduction,
),
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/game/components/hud.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Hud extends PositionComponent
scale: Vector2.all(game.isOffTrail ? 0.6 : 1.0),
);

final top = game.top < 10.0 ? 10.0 : game.top / 2;
final top = game.top <= 10.0 ? 10.0 : game.top / 2;

_player.position.setValues(
16,
Expand Down
2 changes: 1 addition & 1 deletion lib/game/entities/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Player extends PositionComponent
position: position,
particle: Particle.generate(
count: 2,
lifespan: 2,
lifespan: 1.5,
generator: (index) => TranslatedParticle(
child: CircleParticle(
paint: _trailParticlePaint,
Expand Down
2 changes: 2 additions & 0 deletions lib/game/garda_green_game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class GardaGreenGame extends FlameGame
map = await TiledComponent.load(
_sections[_currentSection],
Vector2.all(16),
useAtlas: false,
);

final tiles = images.fromCache('../images/garda_green_tilemap.png');
Expand Down Expand Up @@ -420,6 +421,7 @@ class GardaGreenGame extends FlameGame
map = await TiledComponent.load(
_sections[_currentSection],
Vector2.all(16),
useAtlas: false,
);

input.hAxis = 0;
Expand Down
41 changes: 35 additions & 6 deletions lib/game/menu/view/menu_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ import 'package:garda_green/game/leaderboard/leaderboard.dart';
import 'package:garda_green/game/view/game_view.dart';
import 'package:garda_green/gen/assets.gen.dart';
import 'package:garda_green/l10n/l10n.dart';
import 'package:garda_green/settings/settings.dart';
import 'package:garda_green/utils/components/introduction_dialog.dart';
import 'package:garda_green/utils/utils.dart';
import 'package:nes_ui/nes_ui.dart';
import 'package:url_launcher/url_launcher.dart';

class MenuPage extends StatefulWidget {
const MenuPage({super.key});
const MenuPage({super.key, this.isShowIntroduction = false});

final bool isShowIntroduction;

static const id = 'menu';

Expand All @@ -22,9 +26,11 @@ class MenuPage extends StatefulWidget {
);
}

static PageRoute<void> route() {
static PageRoute<void> route({bool isShowIntroduction = false}) {
return PageRouteBuilder(
pageBuilder: (_, __, ___) => const MenuPage(),
pageBuilder: (_, __, ___) => MenuPage(
isShowIntroduction: isShowIntroduction,
),
);
}

Expand All @@ -37,6 +43,19 @@ class _MenuPageState extends State<MenuPage> {
void initState() {
context.read<AudioController>().musicPlayer.setVolume(0.5);
context.read<AudioController>().changeMusic(Song.background);

if (widget.isShowIntroduction) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
final settings = context.read<SettingsController>();
if (settings.initialIntroduction.value) {
await showDialog(
context: context,
builder: (context) => const IntroductionDialog(),
);
settings.saveInitialIntroduction();
}
});
}
super.initState();
}

Expand All @@ -61,12 +80,12 @@ class _MenuPageState extends State<MenuPage> {
Assets.images.gameLogo.image(
width: context.isSmall ? 282 : 380,
),
Spacer(flex: context.isSmall ? 6 : 8),
const Spacer(flex: 10),
if (isSmall && kIsWeb)
const _MobileWebNotAvailablePage()
else
const _MenuButtons(),
const Spacer(flex: 2),
const Spacer(),
],
),
),
Expand Down Expand Up @@ -117,7 +136,7 @@ class _MenuButtons extends StatelessWidget {
onPressed: () async {
await showDialog(
context: context,
builder: (context) => const GureeDialog(),
builder: (context) => const SettingsDialog(),
);
},
child: Text(
Expand All @@ -126,6 +145,16 @@ class _MenuButtons extends StatelessWidget {
),
),
),
const SizedBox(height: 24),
NesIconButton(
icon: NesIcons.questionMarkBlock,
onPress: () async {
await showDialog(
context: context,
builder: (context) => const IntroductionDialog(),
);
},
),
],
);
}
Expand Down
15 changes: 15 additions & 0 deletions lib/game/score/bloc/score_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class ScoreBloc extends Bloc<ScoreEvent, ScoreState> {
const _blacklist = [
'FUK',
'FUC',
'FCK',
'COK',
'DIK',
'KKK',
Expand All @@ -88,4 +89,18 @@ const _blacklist = [
'WTF',
'XXX',
'RIP',
'ASU',
'MMK',
'KTL',
'LER',
'AJG',
'DIE',
'KIL',
'MUR',
'HOT',
'DAM',
'NUT',
'NIP',
'NIG',
'NUD',
];
8 changes: 6 additions & 2 deletions lib/game/score/input_initials/view/input_initials_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:garda_green/game/score/bloc/score_bloc.dart';
import 'package:garda_green/game/score/input_initials/input_initials.dart';
import 'package:garda_green/l10n/l10n.dart';
import 'package:garda_green/leaderboard/leaderboard.dart';
import 'package:garda_green/utils/utils.dart';

class InputInitialsPage extends StatefulWidget {
const InputInitialsPage({required this.score, super.key});
Expand Down Expand Up @@ -65,13 +66,16 @@ class _InputInitialsPageState extends State<InputInitialsPage> {
const Spacer(flex: 3),
Text(
l10n.enterInitialsLabel,
style: TextStyle(
fontSize: context.isSmall ? 16 : 22,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
Text(
l10n.enterInitialsMessage,
style: const TextStyle(
fontSize: 8,
style: TextStyle(
fontSize: context.isSmall ? 10 : 12,
),
textAlign: TextAlign.center,
),
Expand Down
34 changes: 33 additions & 1 deletion lib/gen/assets.gen.dart

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

1 change: 1 addition & 0 deletions lib/main_production.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void main() async {
final settings = SettingsController(
persistence: LocalStorageSettingsPersistence(),
);
await settings.loadStateFromPersistence();

final audio = AudioController()..attachSettings(settings);
await audio.initialize();
Expand Down
12 changes: 12 additions & 0 deletions lib/settings/persistence/local_storage_settings_persistence.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ class LocalStorageSettingsPersistence extends SettingsPersistence {
return prefs.getBool('sfxMuted') ?? defaultValue;
}

@override
Future<bool> getInitialIntroduction() async {
final prefs = await instanceFuture;
return prefs.getBool('initialIntroduction') ?? true;
}

@override
Future<void> saveMusicMuted({required bool active}) async {
final prefs = await instanceFuture;
Expand All @@ -34,4 +40,10 @@ class LocalStorageSettingsPersistence extends SettingsPersistence {
final prefs = await instanceFuture;
await prefs.setBool('sfxMuted', active);
}

@override
Future<void> saveInitialIntroduction() async {
final prefs = await instanceFuture;
await prefs.setBool('initialIntroduction', false);
}
}
Loading

0 comments on commit 812493f

Please sign in to comment.