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> {
int marks = 0;
int i = 1;
int x = 0;
int timer = 60;
String showtimer = "60";
int hangState = 0;
Map<String, Color> btncolor = {
"a": Colors.indigoAccent,
......@@ -109,6 +111,8 @@ class _quizpageState extends State<quizpage> {
colortoshow = right;
} else {
colortoshow = wrong;
x = x + 1;
showHangman(x);
}
setState(() {
btncolor[k] = colortoshow;
......@@ -118,6 +122,20 @@ class _quizpageState extends State<quizpage> {
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) {
return Padding(
padding: EdgeInsets.symmetric(
......@@ -173,6 +191,31 @@ class _quizpageState extends State<quizpage> {
child: Scaffold(
body: Column(
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(
flex: 2,
child: Container(
......
......@@ -77,6 +77,14 @@ flutter:
- lib/assets/images/socialDistance.png
- lib/assets/images/symptoms.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:
# 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