Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 9 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,26 @@

Welcome to the GDG Chennai Hackathon GitHub repo. Follow these steps to add your project.

## How to Submit Your Project

1. **Create a Folder:**
- Name the folder with your project name (e.g., `awesome-chat-app`).

2. **Add Your Files:**
- Put all your project files inside the folder.
- Include code, assets, etc.

3. **Project README:**
- Inside your project folder, include a README file.
- Follow this structure:
- **Project Title:** Your project name.
- **Description:** A short summary of what your project does.
- **Tech Stack:** List of tools and libraries used.
- **Team Members:** Names of your teammates.
- **Social Profiles:** Links to each member's LinkedIn or GitHub.
- **Installation & Run:** Simple steps to run your project.
- **Screenshots/Demo:** (Optional) Add images or demo links.

4. **Raise a Pull Request:**
- Create a branch and add your folder with files.
- Raise a PR to merge your work.
- We will review and merge if it meets our guidelines.

## Submission Rules

- Teams can have up to 4 members.
- Every project must have a clear README.
- Include your social media links for networking.

---

## Sample Project README

Copy and paste the following as your project README, then update it with your details:

````markdown
# Project Title
# We See Red- A reaction time testing game

## Description

A brief description of what your project does.
A grid based game that tests reaction time by maximising number of clicks of red boxes and measuring response time

## Tech Stack

- Jetpack Compose
- Android SDK
- [Other tools or libraries]

## Team Members

- **Name 1** – [LinkedIn](https://www.linkedin.com/in/yourprofile) | [GitHub](https://github.com/yourprofile)
- **Name 2** – [LinkedIn](https://www.linkedin.com/in/yourprofile) | [GitHub](https://github.com/yourprofile)
- **Name 3** – [LinkedIn](https://www.linkedin.com/in/yourprofile) | [GitHub](https://github.com/yourprofile)
- **Name 4** – [LinkedIn](https://www.linkedin.com/in/yourprofile) | [GitHub](https://github.com/yourprofile)
- Samyuktha S– [LinkedIn](https://www.linkedin.com/in/samyuktha24) | [GitHub](https://github.com/samyuktha2004)
- Ismail – [LinkedIn](https://www.linkedin.com/in/ismail-fareed)
- Pavani – [LinkedIn](https://www.linkedin.com/in/pavani-kankanampati) | [GitHub](https://github.com/pavani-2003)
- Balaji Dhanasekar– [LinkedIn](https://www.linkedin.com/in/balaji-dhanasekar-36948025) | [GitHub](https://github.com/jicse)
- Kathir Sanjay K– [LinkedIn](https://www.linkedin.com/in/) | [GitHub](https://github.com/kathirsanjay)
- Abijith L J– [LinkedIn](https://www.linkedin.com/in/abijith-lj) | [GitHub](https://github.com/abijithlj)


## Installation & Run

Expand Down
59 changes: 59 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
}

android {
namespace = "com.tl.game"
compileSdk = 35

defaultConfig {
applicationId = "com.tl.game"
minSdk = 30
targetSdk = 35
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
buildFeatures {
compose = true
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
}
21 changes: 21 additions & 0 deletions proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
24 changes: 24 additions & 0 deletions src/androidTest/java/com/tl/game/ExampleInstrumentedTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.tl.game

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.tl.game", appContext.packageName)
}
}
28 changes: 28 additions & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Game"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Game">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
173 changes: 173 additions & 0 deletions src/main/java/com/tl/game/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
@file:OptIn(ExperimentalMaterial3Api::class)

package com.tl.game

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.BasicAlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
import com.tl.game.ui.theme.GameTheme
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

class MainActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
val configuration = LocalConfiguration.current
val screenWidth = configuration.screenWidthDp.dp
val columnSize = 8
val rowSize = 10
val boxWidth = screenWidth / columnSize
val timeInSeconds = 30
val otherColors = listOf(Color.Magenta, Color.Gray, Color.Yellow, Color.Blue, Color.Green)
GameTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
var lastClickedTime by remember { mutableStateOf(System.currentTimeMillis()) }
var score by remember { mutableStateOf(0) }
var fastestReactionTime by remember { mutableStateOf(60000000L) }
var gameNumber by remember { mutableStateOf(0) }
var maxScore by remember { mutableStateOf(0) }
var timeLeft by remember { mutableStateOf(timeInSeconds) }
var redRowNum by remember { mutableStateOf(3) }
var redColNum by remember { mutableStateOf(2) }
var otherRowNum by remember { mutableStateOf(3) }
var otherColNum by remember { mutableStateOf(2) }
var showScore by remember { mutableStateOf(false) }
var otherColor by remember { mutableStateOf(otherColors.random()) }
val scope = rememberCoroutineScope()
LaunchedEffect(gameNumber) {
scope.launch {
while (timeLeft > 0) {
delay(1000)
timeLeft--
}
}
}
LaunchedEffect(timeLeft) {
if(timeLeft == 0) {
showScore = true
if (score > maxScore) {
maxScore = score
}
}
}
Column (Modifier.padding(innerPadding)) {
Spacer(Modifier.height(20.dp))
Text("We See Red", fontSize = 32.sp, modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp), textAlign = TextAlign.Center)
Spacer(Modifier.height(20.dp))
Text("Max Score: $maxScore", fontSize = 24.sp, modifier = Modifier.padding(horizontal = 16.dp))
Text("Score: $score", fontSize = 24.sp, modifier = Modifier.padding(horizontal = 16.dp))
Text("Time Left: $timeLeft", fontSize = 24.sp, modifier = Modifier.padding(horizontal = 16.dp))
val fastestReactionTimeInText = if(fastestReactionTime < 60000000L) fastestReactionTime else ""
Text("Fastest Reaction Time: $fastestReactionTimeInText", fontSize = 24.sp, modifier = Modifier.padding(horizontal = 16.dp))
Spacer(Modifier.height(40.dp))
Column {
for (rowNum in 0 until rowSize) {
Row {
for (columnNum in 0 until columnSize) {
Box(
Modifier
.size(boxWidth)
.background(
if (rowNum == redRowNum && columnNum == redColNum) Color.Red else {
if(rowNum == otherRowNum && columnNum == otherColNum) {
otherColor
} else {
Color.White
}
}
).clickable(
onClick = {
if (rowNum == redRowNum && columnNum == redColNum && timeLeft > 0){
redRowNum = (0..rowSize-1).random()
redColNum = (0..columnSize-1).random()
otherRowNum = (0..rowSize-1).random()
otherColNum = (0..columnSize-1).random()
score++
otherColor = otherColors.random()
val reactionTime = System.currentTimeMillis() - lastClickedTime
if(reactionTime < fastestReactionTime) {
fastestReactionTime = reactionTime
}
lastClickedTime = System.currentTimeMillis()
}

},
indication = null,
interactionSource = remember { MutableInteractionSource() }
)
) {

}
}
}

}
}
}
if(showScore) {
AlertDialog({}) {
Card {
Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
Text(
"Your Score is $score",
modifier = Modifier.padding(20.dp),
fontSize = 30.sp
)
}

Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
Button({
showScore = false
timeLeft = timeInSeconds
score = 0
gameNumber++
}, modifier = Modifier.padding(bottom = 20.dp)) {
Text("Let's Play Again!", fontSize = 24.sp)
}
}

}
}
}
}
}
}
}
}
11 changes: 11 additions & 0 deletions src/main/java/com/tl/game/ui/theme/Color.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.tl.game.ui.theme

import androidx.compose.ui.graphics.Color

val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
val Pink80 = Color(0xFFEFB8C8)

val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
Loading