├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── themes.xml │ │ │ ├── font │ │ │ │ └── pac_font.TTF │ │ │ ├── drawable │ │ │ │ ├── ghost_orange.png │ │ │ │ ├── arrow_up.xml │ │ │ │ ├── arrow_down.xml │ │ │ │ ├── arrow_right.xml │ │ │ │ ├── arrow_left.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── drawable-v24 │ │ │ │ ├── ghost_red.png │ │ │ │ ├── ghost_reverse.png │ │ │ │ ├── pacman_open.png │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ └── values-night │ │ │ │ └── themes.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── dbtechprojects │ │ │ │ └── pacmancompose │ │ │ │ ├── models │ │ │ │ ├── DialogState.kt │ │ │ │ ├── GameStatsModel.kt │ │ │ │ ├── EnemyMovementModel.kt │ │ │ │ └── PacFood.kt │ │ │ │ ├── utils │ │ │ │ └── GameConstants.kt │ │ │ │ ├── ui │ │ │ │ ├── theme │ │ │ │ │ ├── Color.kt │ │ │ │ │ ├── Type.kt │ │ │ │ │ ├── Theme.kt │ │ │ │ │ └── Shape.kt │ │ │ │ └── GameComposables.kt │ │ │ │ ├── GameViewModel.kt │ │ │ │ └── MainActivity.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── dbtechprojects │ │ │ └── pacmancompose │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── dbtechprojects │ │ └── pacmancompose │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── .idea ├── .gitignore ├── compiler.xml ├── vcs.xml ├── misc.xml ├── deploymentTargetDropDown.xml └── gradle.xml ├── resources ├── demo1.gif └── demo2.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle ├── README.md ├── gradle.properties ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /resources/demo1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/resources/demo1.gif -------------------------------------------------------------------------------- /resources/demo2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/resources/demo2.gif -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | pacmanCompose 3 | -------------------------------------------------------------------------------- /app/src/main/res/font/pac_font.TTF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/font/pac_font.TTF -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/ghost_orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/drawable/ghost_orange.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ghost_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/drawable-v24/ghost_red.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ghost_reverse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/drawable-v24/ghost_reverse.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/pacman_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/drawable-v24/pacman_open.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielmbutler/Pacman_Compose/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Jun 19 21:23:03 BST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/dbtechprojects/pacmancompose/models/DialogState.kt: -------------------------------------------------------------------------------- 1 | package com.dbtechprojects.pacmancompose.models 2 | 3 | import androidx.compose.runtime.MutableState 4 | 5 | data class DialogState ( 6 | val shouldShow: MutableState, 7 | val message: MutableState, 8 | ) -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 3 | repositories { 4 | google() 5 | mavenCentral() 6 | jcenter() // Warning: this repository is going to shut down soon 7 | } 8 | } 9 | rootProject.name = "pacmanCompose" 10 | include ':app' 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/dbtechprojects/pacmancompose/utils/GameConstants.kt: -------------------------------------------------------------------------------- 1 | package com.dbtechprojects.pacmancompose.utils 2 | 3 | object GameConstants { 4 | const val FOOD_COUNTER = 100 // amount of food 5 | var incrementValue = 75f // amount to move the character 6 | const val RED_ENEMY_SPEED = 3000 7 | const val ORANGE_ENEMY_SPEED = 2500 8 | 9 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/arrow_up.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/arrow_down.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/arrow_right.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/arrow_left.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/dbtechprojects/pacmancompose/models/GameStatsModel.kt: -------------------------------------------------------------------------------- 1 | package com.dbtechprojects.pacmancompose.models 2 | 3 | import androidx.compose.runtime.MutableState 4 | 5 | data class GameStatsModel( 6 | val CharacterXOffset: MutableState, 7 | val CharacterYOffset: MutableState, 8 | val isGameStarted: MutableState, 9 | val isReverseMode: MutableState 10 | 11 | ) 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/dbtechprojects/pacmancompose/models/EnemyMovementModel.kt: -------------------------------------------------------------------------------- 1 | package com.dbtechprojects.pacmancompose.models 2 | 3 | import androidx.compose.runtime.MutableState 4 | import androidx.compose.runtime.mutableStateOf 5 | import androidx.compose.ui.geometry.Offset 6 | 7 | data class EnemyMovementModel ( 8 | val redEnemyMovement: MutableState = mutableStateOf(Offset(0F, 0F)), 9 | val orangeEnemyMovement: MutableState = mutableStateOf(Offset(0F, 0F)) 10 | ) -------------------------------------------------------------------------------- /app/src/test/java/com/dbtechprojects/pacmancompose/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.dbtechprojects.pacmancompose 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/java/com/dbtechprojects/pacmancompose/ui/theme/Color.kt: -------------------------------------------------------------------------------- 1 | package com.dbtechprojects.pacmancompose.ui.theme 2 | 3 | 4 | import androidx.compose.ui.graphics.Color 5 | 6 | val PacmanYellow = Color(0xFFFFFF00) 7 | val PacmanRed = Color(0xFFFD0000) 8 | val PacmanPink = Color(0xFFdea185) 9 | val PacmanGreen = Color(0xFF00ff00) 10 | val PacmanWhite = Color(0xFFFFFFFF) 11 | val PacmanBackground = Color(0xFF000000) 12 | val PacmanMazeColor = Color(0xFF0051ff) 13 | val PacmanOrange = Color(0xFFffa500) -------------------------------------------------------------------------------- /.idea/deploymentTargetDropDown.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/dbtechprojects/pacmancompose/ui/theme/Type.kt: -------------------------------------------------------------------------------- 1 | package com.dbtechprojects.pacmancompose.ui.theme 2 | 3 | import androidx.compose.material.Typography 4 | import androidx.compose.ui.text.TextStyle 5 | import androidx.compose.ui.text.font.Font 6 | import androidx.compose.ui.text.font.FontFamily 7 | import androidx.compose.ui.text.font.FontWeight 8 | import androidx.compose.ui.unit.sp 9 | import com.dbtechprojects.pacmancompose.R 10 | 11 | 12 | // Set of Material typography styles to start with 13 | val Typography = Typography( 14 | body1 = TextStyle( 15 | fontFamily = FontFamily.Default, 16 | fontWeight = FontWeight.Normal, 17 | fontSize = 16.sp 18 | ) 19 | ) 20 | 21 | val HeaderFont = FontFamily(listOf(Font(R.font.pac_font))) 22 | 23 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/dbtechprojects/pacmancompose/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.dbtechprojects.pacmancompose 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.dbtechprojects.pacmancompose", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pacman Compose 2 | This Pacman style game is entirely created using Jetpack Compose, still currently a work-in progress. 3 | 4 |

5 | 6 |

7 | 8 | 9 | ## Demo 10 | 11 |

12 | 13 | 14 |

15 | 16 | 17 | 18 | ## Technology used 19 | * All UI created using Jetpack Compose, 20 | * Kotlin 21 | * Animations - used AnimateFloatAsState, and InfiniteTransition 22 | * Canvas API 23 | 24 | ## Article on Hashnode 25 | https://dbtechprojects.hashnode.dev/my-first-attempt-at-creating-a-game-with-jetpack-compose 26 | 27 | Featured in Android Weekly: https://androidweekly.net/issues/issue-475 28 | 29 | ## Resources 30 | https://developer.android.com/jetpack/compose/animation#overview 31 | https://developer.android.com/jetpack/compose/graphics 32 | https://jeffreyrajan.medium.com/canvas-made-easy-in-jetpack-compose-2c632518f8bf 33 | 34 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 21 | 22 |