Skip to content

Commit

Permalink
added level intro
Browse files Browse the repository at this point in the history
  • Loading branch information
aruhant committed Feb 6, 2024
1 parent cccb29f commit 8018935
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 34 deletions.
1 change: 1 addition & 0 deletions app/assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"next_level": "Next Level",
"coming_soon": "Coming Soon!",
"close": "Close",
"lanka_dahan_intro": "As the sun dipped below the horizon, casting an amber glow over the ancient city of Lanka, you, Fearless Hanuman, found yourself ensnared. Ravana, the ten-headed demon king, had captured you—the mighty ape warrior. His eyes gleamed with malice as he spoke:\n\n“कपीनां किल लाङ्गूलमिष्टं भवति भूषणम्।\nतदस्य दीप्यतां शीघ्रं तेन दग्धेन गच्छतु।।5.53.3।।”\n\nTranslation: “The tail of a monkey is dear to them. It is like an ornament to them. Set it blaze swiftly with fire, and let him go.”\n\nBut you are Hanuman—the wind-swift, the leaper of oceans, the loyal servant of Lord Rama. You have the blessings of Maa Sita. \nThe flames would dance upon your fur, but it is as cold as ice.\nAs your heart beats with courage, and mischief twinkled in your eyes. \nYou would turn Lanka into an inferno, a beacon of defiance.\nCross the sprawling city, avoid detection, and unleash the flames of retribution. \n\nRemember, Fearless Hanuman, you have but one chance. If captured, the level resets. The city awaits your wrath, and Lanka trembles in anticipation.\n\nNote: Inspired by the epic Ramayana, this game level is a fictional adaptation.",
"win_message": "You have successfully destroyed Lanka!"
}
1 change: 1 addition & 0 deletions app/assets/translations/hi-IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"next_level": "अगला अध्याय",
"coming_soon": "जल्द ही आ रहा है",
"close": "ठीक है",
"lanka_dahan_intro": "As the sun dipped below the horizon, casting an amber glow over the ancient city of Lanka, you, Fearless Hanuman, found yourself ensnared. Ravana, the ten-headed demon king, had captured you—the mighty ape warrior. His eyes gleamed with malice as he spoke:\n\n“कपीनां किल लाङ्गूलमिष्टं भवति भूषणम्।\nतदस्य दीप्यतां शीघ्रं तेन दग्धेन गच्छतु।।5.53.3।।”\n\nTranslation: “The tail of a monkey is dear to them. It is like an ornament to them. Set it blaze swiftly with fire, and let him go.”\n\nBut you are Hanuman—the wind-swift, the leaper of oceans, the loyal servant of Lord Rama. You have the blessings of Maa Sita. \nThe flames would dance upon your fur, but it is as cold as ice.\nAs your heart beats with courage, and mischief twinkled in your eyes. \nYou would turn Lanka into an inferno, a beacon of defiance.\nCross the sprawling city, avoid detection, and unleash the flames of retribution. \n\nRemember, Fearless Hanuman, you have but one chance. If captured, the level resets. The city awaits your wrath, and Lanka trembles in anticipation.\n\nNote: Inspired by the epic Ramayana, this game level is a fictional adaptation.",
"win_message": "आपने लंका को सफलतापूर्वक दहन कर दिया है!"
}
37 changes: 19 additions & 18 deletions app/lib/game/game_engine.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
/*
This file is responsible for creating the game engine and setting up the game.
It uses the Bonfire library to create the game engine and the game world.
It also sets up the player and the enemies in the game. It also sets up the
joystick and the camera for the game. It also sets up the background music for
the game. It also sets up the reset function for the game. The reset function is
hsed to reset the game when the player dies. The game engine is used in the game
screen to create the game world and the game engine.
*/
/*MOVED IMPRESSIVE CODE SNIPPET to rakshasa.dart*/
import 'package:bonfire/bonfire.dart';
import 'package:flutter/foundation.dart';
import 'package:ramayana/user_prefs/audioController.dart';
Expand All @@ -20,15 +10,26 @@ import 'package:flutter/services.dart';
import 'dart:math';
import 'dart:ui' as ui;

// This implementation is based on the following chapter of the book "The Nature of Code" by Daniel Shiffman:
// https://natureofcode.com/autonomous-agents/
// Also refer to Craig Reynolds' "Boids" algorithm, which simulates the flocking behavior of birds.
// In the context of the game, the boids are used to simulate the behavior of the enemies.
// For example, the Rakshasa enemies in the game can use this to simulate their flocking behavior.
// In general this is a better approach than using a simple pathfinding algorithm which directly calculates the path to the player.
// This gives a more natural and realistic behavior to the enemies.
// Also, avoids the enemies from getting stuck in obstacles or against each other.
/*
This file is responsible for creating the game engine and setting up the game.
It uses the Bonfire library to create the game engine and the game world.
It also sets up the player and the enemies in the game. It also sets up the
joystick and the camera for the game. It also sets up the background music for
the game. It also sets up the reset function for the game. The reset function is
hsed to reset the game when the player dies. The game engine is used in the game
screen to create the game world and the game engine.
I think, the boids algorithm below is pretty cool.
This implementation is based on the following chapter of the book "The Nature of Code" by Daniel Shiffman:
https://natureofcode.com/autonomous-agents/
Also refer to Craig Reynolds' "Boids" algorithm, which simulates the flocking behavior of birds.
In the context of the game, the boids are used to simulate the behavior of the enemies.
For example, the Rakshasa enemies in the game can use this to simulate their flocking behavior.
In general this is a better approach than using a simple pathfinding algorithm which directly calculates the path to the player.
This gives a more natural and realistic behavior to the enemies.
Also, avoids the enemies from getting stuck in obstacles or against each other.
*/
class Boid {
static final Random r = Random();
static final Vec migrate = Vec(0.02, 0);
Expand Down
15 changes: 1 addition & 14 deletions app/lib/level_picker/world_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class _WorldMapWidgetState extends State<WorldMapWidget> {
double scale = side / 1000;
print(scale);
return Material(
color: Colors.red,
color: Colors.black,
child: SingleChildScrollView(
child: Container(
width: side,
Expand All @@ -59,19 +59,6 @@ class _WorldMapWidgetState extends State<WorldMapWidget> {
child: Stack(
alignment: Alignment.center,
children: [
// Container(
// width: side,
// height: side,
// decoration: BoxDecoration(
// color: Colors.green.withOpacity(0.3),
// image: DecorationImage(
// image: AssetImage('assets/worlds/world_map.png'),
// opacity: 0.3,
// fit: BoxFit.cover,
// alignment: Alignment.topLeft,
// ),
// ),
// ),
...worlds.map((e) => WorldTile(
world: e,
scale: scale,
Expand Down
4 changes: 4 additions & 0 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:bonfire/bonfire.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:ramayana/level_picker/world_selector.dart';
import 'package:ramayana/title_screen/level_intro.dart';
import 'package:ramayana/title_screen/title_screen.dart';
import 'user_prefs/audioController.dart';
import 'game/game_engine.dart';
Expand Down Expand Up @@ -35,7 +37,9 @@ class RamayanRPGApp extends StatelessWidget {
supportedLocales: context.supportedLocales,
locale: context.locale,
debugShowCheckedModeBanner: false,
// home: WorldMapWidget(locale: context.locale));
// home: GameEngine(level: 'lanka_dahan'));
home: TitleScreen());
// home: LevelIntro(level: 'lanka_dahan'));
}
}
47 changes: 47 additions & 0 deletions app/lib/title_screen/level_intro.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:ramayana/game/game_engine.dart';

class LevelIntro extends StatelessWidget {
const LevelIntro({Key? key, required String level}) : super(key: key);

@override
Widget build(BuildContext context) {
return Material(
color: Colors.black,
child: SafeArea(
child: Stack(
children: [
SingleChildScrollView(
child: Container(
padding: const EdgeInsets.all(20),
child: AnimatedTextKit(
isRepeatingAnimation: false,
animatedTexts: [
TypewriterAnimatedText('lanka_dahan_intro'.tr(),
textStyle: const TextStyle(
fontSize: 14,
color: Colors.white,
fontWeight: FontWeight.bold)),
])),
),
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.only(bottom: 20),
child: ElevatedButton(
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
GameEngine(level: 'lanka_dahan'))),
child: Text('start_game'.tr())),
),
),
],
),
),
);
}
}
4 changes: 3 additions & 1 deletion app/lib/title_screen/title_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:ramayana/game/game_engine.dart';
import 'package:ramayana/level_picker/world_selector.dart';
import 'package:ramayana/title_screen/language_picker.dart';
import 'package:ramayana/title_screen/level_intro.dart';
import 'package:ramayana/user_prefs/audioController.dart';
import 'package:video_player/video_player.dart';

Expand Down Expand Up @@ -82,7 +83,8 @@ class _TitleScreenState extends State<TitleScreen> {
context,
MaterialPageRoute(
builder: (context) =>
const GameEngine(level: 'lanka_dahan'))),
LevelIntro(level: 'lanka_dahan'))),
// const GameEngine(level: 'lanka_dahan'))),
child: Text('start_game'.tr())),
],
),
Expand Down
2 changes: 1 addition & 1 deletion app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.34+34
version: 1.0.45+45

environment:
sdk: ">=3.2.3 <4.0.0"
Expand Down

0 comments on commit 8018935

Please sign in to comment.