-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 335bbb3
Showing
60 changed files
with
1,737 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
plugins { | ||
id 'com.android.application' | ||
} | ||
|
||
android { | ||
namespace 'com.salazarisaiahnoel.pacmanandroid' | ||
compileSdk 34 | ||
|
||
defaultConfig { | ||
applicationId "com.salazarisaiahnoel.pacmanandroid" | ||
minSdk 19 | ||
targetSdk 34 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.appcompat:appcompat:1.6.1' | ||
implementation 'com.google.android.material:material:1.10.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
implementation 'com.github.bumptech.glide:glide:4.12.0' | ||
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.5' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/com/salazarisaiahnoel/pacmanandroid/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.salazarisaiahnoel.pacmanandroid; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("com.salazarisaiahnoel.pacmanandroid", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?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:supportsRtl="true" | ||
android:theme="@style/Theme.PacmanAndroid" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".Play" | ||
android:exported="false" | ||
android:screenOrientation="portrait"/> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true" | ||
android:screenOrientation="portrait"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/salazarisaiahnoel/pacmanandroid/Fullscreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.salazarisaiahnoel.pacmanandroid; | ||
|
||
import android.app.Activity; | ||
import android.view.View; | ||
|
||
public class Fullscreen { | ||
public static void enableFullscreen(Activity activity){ | ||
int UI_OPTIONS = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; | ||
activity.getWindow().getDecorView().setSystemUiVisibility(UI_OPTIONS); | ||
} | ||
} |
151 changes: 151 additions & 0 deletions
151
app/src/main/java/com/salazarisaiahnoel/pacmanandroid/Ghost.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
package com.salazarisaiahnoel.pacmanandroid; | ||
|
||
import android.graphics.Canvas; | ||
import android.graphics.Color; | ||
import android.graphics.Paint; | ||
|
||
import java.util.Random; | ||
|
||
public class Ghost { | ||
int[][] map; | ||
int cellSizeRow, cellSizeCol; | ||
int posX, posY; | ||
int speed; | ||
int color; | ||
boolean isMoving = false; | ||
boolean isStart = false; | ||
int goOutCounter = 0; | ||
boolean should = false; | ||
|
||
boolean canMoveUp, canMoveDown, canMoveLeft, canMoveRight; | ||
Random ran = new Random(); | ||
int dir = 0; | ||
|
||
public Ghost(int color, int[][] map, int cellSizeRow, int cellSizeCol, int speed, int position, int place){ | ||
this.color = color; | ||
this.map = map; | ||
this.cellSizeRow = cellSizeRow; | ||
this.cellSizeCol = cellSizeCol; | ||
this.speed = speed; | ||
posX = cellSizeCol * (position + 9); | ||
posY = cellSizeRow * place; | ||
} | ||
|
||
public void draw(Canvas canvas) { | ||
Paint paint = new Paint(); | ||
paint.setColor(Color.TRANSPARENT); | ||
canvas.drawRect(posX, posY, posX + cellSizeCol, posY + cellSizeRow, paint); | ||
|
||
paint.setColor(color); | ||
canvas.drawCircle(posX + cellSizeCol / 2, posY + cellSizeRow / 2, cellSizeCol / 2, paint); | ||
canvas.drawRect(posX, posY + (cellSizeRow / 2), posX + cellSizeCol, posY + cellSizeRow, paint); | ||
} | ||
|
||
public void move(int dx, int dy) { | ||
int newX = posX + dx; | ||
int newY = posY + dy; | ||
|
||
if (isValidMove(newX, newY) && isValidMove(newX + cellSizeCol - 1, newY + cellSizeRow - 1) && isValidMove(newX, newY + cellSizeRow - 1) && isValidMove(newX + cellSizeCol - 1, newY)){ | ||
posX = newX; | ||
posY = newY; | ||
isMoving = true; | ||
} else { | ||
isMoving = false; | ||
} | ||
} | ||
|
||
boolean isValidMove(int newX, int newY){ | ||
if (newX >= 0 && newX < map[0].length * cellSizeCol && newY >= 0 && newY < map.length * cellSizeRow) { | ||
int col = newX / cellSizeCol; | ||
int row = newY / cellSizeRow; | ||
|
||
if (map[row][col] != 1) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
void goOutside(){ | ||
switch (goOutCounter){ | ||
case 0: | ||
if (!isStart){ | ||
move(-speed, 0); | ||
} | ||
if (!isMoving){ | ||
isStart = true; | ||
goOutCounter++; | ||
} | ||
break; | ||
case 1: | ||
if (isStart){ | ||
move(0, -speed); | ||
} | ||
if (!isMoving){ | ||
isStart = false; | ||
goOutCounter++; | ||
} | ||
break; | ||
case 2: | ||
if (!isStart){ | ||
if (isValidMove(posX, posY - speed) && isValidMove(posX + cellSizeCol - 1, posY + cellSizeRow - 1 - speed) && isValidMove(posX, posY + cellSizeRow - 1 - speed) && isValidMove(posX + cellSizeCol - 1, posY - speed)){ | ||
move(0, -speed); | ||
should = true; | ||
} else { | ||
if (should){ | ||
isStart = true; | ||
goOutCounter++; | ||
} | ||
move(speed, 0); | ||
} | ||
} | ||
break; | ||
case 3: | ||
if (isStart){ | ||
move(-speed, 0); | ||
} | ||
if (!isMoving){ | ||
isStart = false; | ||
goOutCounter++; | ||
} | ||
break; | ||
} | ||
} | ||
|
||
void moveRandomly(){ | ||
canMoveUp = isValidMove(posX, posY - speed) && isValidMove(posX + cellSizeCol - 1, posY + cellSizeRow - 1 - speed) && isValidMove(posX, posY + cellSizeRow - 1 - speed) && isValidMove(posX + cellSizeCol - 1, posY - speed); | ||
canMoveDown = isValidMove(posX, posY + speed) && isValidMove(posX + cellSizeCol - 1, posY + cellSizeRow - 1 + speed) && isValidMove(posX, posY + cellSizeRow - 1 + speed) && isValidMove(posX + cellSizeCol - 1, posY + speed); | ||
canMoveLeft = isValidMove(posX - speed, posY) && isValidMove(posX + cellSizeCol - 1 - speed, posY + cellSizeRow - 1) && isValidMove(posX - speed, posY + cellSizeRow - 1) && isValidMove(posX + cellSizeCol - 1 - speed, posY); | ||
canMoveRight = isValidMove(posX + speed, posY) && isValidMove(posX + cellSizeCol - 1 + speed, posY + cellSizeRow - 1) && isValidMove(posX + speed, posY + cellSizeRow - 1) && isValidMove(posX + cellSizeCol - 1 + speed, posY); | ||
switch (dir){ | ||
case 0: | ||
if (canMoveUp){ | ||
move(0, -speed); | ||
} else { | ||
dir = ran.nextInt(4); | ||
} | ||
break; | ||
case 1: | ||
if (canMoveDown){ | ||
move(0, speed); | ||
} else { | ||
dir = ran.nextInt(4); | ||
} | ||
break; | ||
case 2: | ||
if (canMoveLeft){ | ||
move(-speed, 0); | ||
} else { | ||
dir = ran.nextInt(4); | ||
} | ||
break; | ||
case 3: | ||
if (canMoveRight){ | ||
move(speed, 0); | ||
} else { | ||
dir = ran.nextInt(4); | ||
} | ||
break; | ||
} | ||
} | ||
} |
Oops, something went wrong.