Commit d3dfbea7 authored by Piyumi Dayarathna's avatar Piyumi Dayarathna 💬

STracker - Added hangman part to the game

parent b5fc977c
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
\ No newline at end of file
File added
...@@ -49,8 +49,10 @@ class _quizpageState extends State<quizpage> { ...@@ -49,8 +49,10 @@ class _quizpageState extends State<quizpage> {
int marks = 0; int marks = 0;
int i = 1; int i = 1;
int x = 0;
int timer = 60; int timer = 60;
String showtimer = "60"; String showtimer = "60";
int hangState = 0;
Map<String, Color> btncolor = { Map<String, Color> btncolor = {
"a": Colors.indigoAccent, "a": Colors.indigoAccent,
...@@ -109,6 +111,8 @@ class _quizpageState extends State<quizpage> { ...@@ -109,6 +111,8 @@ class _quizpageState extends State<quizpage> {
colortoshow = right; colortoshow = right;
} else { } else {
colortoshow = wrong; colortoshow = wrong;
x = x + 1;
showHangman(x);
} }
setState(() { setState(() {
btncolor[k] = colortoshow; btncolor[k] = colortoshow;
...@@ -118,6 +122,20 @@ class _quizpageState extends State<quizpage> { ...@@ -118,6 +122,20 @@ class _quizpageState extends State<quizpage> {
Timer(Duration(seconds: 2), nextquestion); Timer(Duration(seconds: 2), nextquestion);
} }
void showHangman(x) {
if (x == 1) {
hangState = 1;
} else if (x == 2) {
hangState = 2;
} else if (x == 3) {
hangState = 3;
} else if (x == 4) {
hangState = 4;
} else {
hangState = 5;
}
}
Widget choicebutton(String k) { Widget choicebutton(String k) {
return Padding( return Padding(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
...@@ -173,6 +191,31 @@ class _quizpageState extends State<quizpage> { ...@@ -173,6 +191,31 @@ class _quizpageState extends State<quizpage> {
child: Scaffold( child: Scaffold(
body: Column( body: Column(
children: <Widget>[ children: <Widget>[
Expanded(
flex: 5,
child: Material(
elevation: 20.0,
child: Container(
width: 200.0,
height: 150.0,
child: Column(
children: <Widget>[
Material(
child: Container(
width: 200.0,
height: 200.0,
child: ClipRRect(
child: Image(
image: AssetImage(
"lib/assets/images/$hangState.png"),
),
),
),
),
],
)),
),
),
Expanded( Expanded(
flex: 2, flex: 2,
child: Container( child: Container(
......
...@@ -77,6 +77,14 @@ flutter: ...@@ -77,6 +77,14 @@ flutter:
- lib/assets/images/socialDistance.png - lib/assets/images/socialDistance.png
- lib/assets/images/symptoms.png - lib/assets/images/symptoms.png
- lib/assets/images/startQuiz.png - lib/assets/images/startQuiz.png
- lib/assets/images/0.png
- lib/assets/images/1.png
- lib/assets/images/2.png
- lib/assets/images/3.png
- lib/assets/images/4.png
- lib/assets/images/5.png
- lib/assets/images/6.png
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
# assets: # assets:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment