Skip to content

Commit c3ad8ff

Browse files
committed
added difficulty screen
1 parent 99eb499 commit c3ad8ff

5 files changed

Lines changed: 145 additions & 6 deletions

File tree

.idea/androidTestResultsUserPreferences.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
<activity
5656
android:name=".AnalysisActivity"
5757
android:exported="true" />
58+
59+
<!-- Select Difficulty Activity -->
60+
<activity
61+
android:name=".SelectDifficultyActivity"
62+
android:exported="true" />
5863

5964

6065
</application>

app/src/main/java/com/example/chaiss/GameMode.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.os.Bundle;
55
import android.view.View;
66
import android.widget.Button;
7+
import android.widget.ImageButton;
78
import androidx.appcompat.app.AppCompatActivity;
89

910
public class GameMode extends AppCompatActivity {
@@ -18,7 +19,7 @@ protected void onCreate(Bundle savedInstanceState) {
1819
button2D.setOnClickListener(new View.OnClickListener() {
1920
@Override
2021
public void onClick(View v) {
21-
Intent intent = new Intent(GameMode.this, PlayActivity.class);
22+
Intent intent = new Intent(GameMode.this, SelectDifficultyActivity.class);
2223
startActivity(intent);
2324
}
2425
});
@@ -47,11 +48,9 @@ public void onClick(View v) {
4748
});
4849

4950
// Back Button
50-
findViewById(R.id.imageButtonBack).setOnClickListener(new View.OnClickListener() {
51-
@Override
52-
public void onClick(View v) {
53-
finish();
54-
}
51+
ImageButton backArrow = findViewById(R.id.imageButtonBack);
52+
backArrow.setOnClickListener(v -> {
53+
getOnBackPressedDispatcher().onBackPressed();
5554
});
5655
}
5756
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.example.chaiss;
2+
import androidx.appcompat.app.AppCompatActivity;
3+
import android.content.Intent;
4+
import android.os.Bundle;
5+
import android.view.View;
6+
import android.widget.Button;
7+
import android.widget.ImageButton;
8+
public class SelectDifficultyActivity extends AppCompatActivity{
9+
private Button btnEasy, btnMedium, btnHard;
10+
private ImageButton btnBack;
11+
@Override
12+
protected void onCreate(Bundle savedInstanceState) {
13+
super.onCreate(savedInstanceState);
14+
setContentView(R.layout.activity_select_difficulty);
15+
btnEasy = findViewById(R.id.btn_easy);
16+
btnMedium = findViewById(R.id.btn_medium);
17+
btnHard = findViewById(R.id.btn_hard);
18+
btnBack = findViewById(R.id.imageButtonBack);
19+
20+
btnEasy.setOnClickListener(new View.OnClickListener() {
21+
@Override
22+
public void onClick(View view) {
23+
openChessBoard("easy");
24+
}
25+
});
26+
27+
btnMedium.setOnClickListener(new View.OnClickListener() {
28+
@Override
29+
public void onClick(View view) {
30+
openChessBoard("medium");
31+
}
32+
});
33+
34+
btnHard.setOnClickListener(new View.OnClickListener() {
35+
@Override
36+
public void onClick(View view) { openChessBoard("hard"); }
37+
});
38+
39+
btnBack.setOnClickListener(new View.OnClickListener() {
40+
@Override
41+
public void onClick(View view) { finish(); }
42+
});
43+
}
44+
private void openChessBoard(String difficulty) {
45+
Intent intent = new Intent(SelectDifficultyActivity.this, PlayActivity.class);
46+
intent.putExtra("DIFFICULTY_LEVEL", difficulty);
47+
startActivity(intent);
48+
}
49+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:background="#852221"
8+
tools:context=".GameMode">
9+
10+
<!-- Title Text -->
11+
<TextView
12+
android:id="@+id/textViewTitle"
13+
android:layout_width="wrap_content"
14+
android:layout_height="wrap_content"
15+
android:layout_marginTop="28dp"
16+
android:fontFamily="@font/joti_one"
17+
android:text="Difficulty"
18+
android:textColor="#FFFFFF"
19+
android:textSize="34sp"
20+
app:layout_constraintTop_toTopOf="parent"
21+
app:layout_constraintStart_toStartOf="parent"
22+
app:layout_constraintEnd_toEndOf="parent"
23+
app:layout_constraintHorizontal_bias="0.5" />
24+
25+
<!-- Easy Button -->
26+
<Button
27+
android:id="@+id/btn_easy"
28+
android:layout_width="205dp"
29+
android:layout_height="77dp"
30+
android:layout_marginTop="40dp"
31+
android:background="#090808"
32+
android:fontFamily="@font/joti_one"
33+
android:text="Easy"
34+
android:textColor="#FFFFFF"
35+
android:textSize="20sp"
36+
app:layout_constraintTop_toBottomOf="@id/textViewTitle"
37+
app:layout_constraintStart_toStartOf="parent"
38+
app:layout_constraintEnd_toEndOf="parent"
39+
app:layout_constraintHorizontal_bias="0.5" />
40+
41+
<!-- Medium Button -->
42+
<Button
43+
android:id="@+id/btn_medium"
44+
android:layout_width="205dp"
45+
android:layout_height="77dp"
46+
android:layout_marginTop="40dp"
47+
android:background="#090808"
48+
android:fontFamily="@font/joti_one"
49+
android:text="Medium"
50+
android:textColor="#FFFFFF"
51+
android:textSize="20sp"
52+
app:layout_constraintTop_toBottomOf="@id/btn_easy"
53+
app:layout_constraintStart_toStartOf="parent"
54+
app:layout_constraintEnd_toEndOf="parent"
55+
app:layout_constraintHorizontal_bias="0.5" />
56+
57+
<!-- Hard Button -->
58+
<Button
59+
android:id="@+id/btn_hard"
60+
android:layout_width="205dp"
61+
android:layout_height="77dp"
62+
android:layout_marginTop="40dp"
63+
android:background="#090808"
64+
android:fontFamily="@font/joti_one"
65+
android:text="Hard"
66+
android:textColor="#FFFFFF"
67+
android:textSize="20sp"
68+
app:layout_constraintTop_toBottomOf="@id/btn_medium"
69+
app:layout_constraintStart_toStartOf="parent"
70+
app:layout_constraintEnd_toEndOf="parent"
71+
app:layout_constraintHorizontal_bias="0.5" />
72+
73+
<!-- Back Arrow Image Button -->
74+
<ImageButton
75+
android:id="@+id/imageButtonBack"
76+
android:layout_width="68dp"
77+
android:layout_height="49dp"
78+
android:layout_marginStart="16dp"
79+
android:layout_marginTop="16dp"
80+
android:background="#852221"
81+
app:srcCompat="@drawable/ic_back_arrow"
82+
app:layout_constraintTop_toTopOf="parent"
83+
app:layout_constraintStart_toStartOf="parent" />
84+
85+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)