Loading .idea/compiler.xml +1 −1 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="CompilerConfiguration"> <bytecodeTargetLevel target="17" /> <bytecodeTargetLevel target="11" /> </component> </project> No newline at end of file .idea/misc.xml +2 −1 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/build/classes" /> </component> <component name="ProjectType"> Loading app/src/main/AndroidManifest.xml +4 −1 Original line number Diff line number Diff line Loading @@ -11,6 +11,9 @@ android:supportsRtl="true" android:theme="@style/Theme.Game2D" tools:targetApi="31"> <activity android:name=".MenuPause" android:exported="false" /> <activity android:name=".ChalkGameRIPActivity" android:exported="false" Loading app/src/main/java/com/example/game2d/ChalkGameClass.java +13 −18 Original line number Diff line number Diff line Loading @@ -59,14 +59,10 @@ public class ChalkGameClass extends View { private Bitmap pauseButton; private int pauseX = 1700; private int pauseX = 1800; private int pauseY = 20; private boolean pauseTouch = false; private Bitmap hintButton; private int hintX = 1800; private int hintY = 20; private int chalkIndex; Loading @@ -82,8 +78,8 @@ public class ChalkGameClass extends View { selectedShortHair = preferences.getBoolean("shortHairSelection", false); chalkIndex = preferences.getInt("ChalkQuestionIndex", 0); // ranGravity = (int) Math.floor(Math.random() * 5) + 1; //ranGravity is a random integer between 1 and 5 ranGravity = 2; ranGravity = (int) Math.floor(Math.random() * 5) + 1; //ranGravity is a random integer between 1 and 5 if(ranGravity%2 ==1) normGravity = true; //if ranGravity is odd, normal gravity is used where you jump up but rest at the bottom else Loading Loading @@ -125,7 +121,7 @@ public class ChalkGameClass extends View { } jumpcount = 0; lifeXstart = 1330; lifeXstart = 1430; //Initializing the chalk array Loading @@ -139,7 +135,7 @@ public class ChalkGameClass extends View { lifecounter = 3; pauseButton = BitmapFactory.decodeResource(getResources(), R.drawable.pause_new); hintButton = BitmapFactory.decodeResource(getResources(), R.drawable.question_new); } Loading Loading @@ -246,7 +242,7 @@ public class ChalkGameClass extends View { if(chalkPassed == chalkNum * 3) { chalkX[ii] = chalkX[ii] - 800; chalkXSpeed = 0; chalkPassed = 0; bossMusic.stop(); Loading Loading @@ -305,7 +301,6 @@ public class ChalkGameClass extends View { } canvas.drawBitmap(hintButton,hintX, hintY, null); } Loading @@ -330,11 +325,14 @@ public class ChalkGameClass extends View { { pauseTouch = onSingleTap(event); if (event.getAction() == MotionEvent.ACTION_UP) { if(pauseTouch == false) { touch = true; playerSpeed = -30; jumpcount++; } } return true; } Loading @@ -353,10 +351,7 @@ public class ChalkGameClass extends View { int y = (int) event.getY(); if ((pauseX < x && x < (pauseX + pauseButton.getWidth()) //if user touches pause button && pauseY < y && y < (pauseY + pauseButton.getHeight())) || ( hintX < x && x < (hintX + hintButton.getWidth()) // or if user touches hint button && hintY < y && y < (hintY + hintButton.getHeight())) ) && pauseY < y && y < (pauseY + pauseButton.getHeight()))) { return true; } Loading app/src/main/java/com/example/game2d/Game.java +32 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,10 @@ and rendering all objects to the screen. */ public class Game extends SurfaceView implements SurfaceHolder.Callback { Bitmap background; Bitmap pauseButton; private boolean pauseTouch; private int pauseX = 1800; private int pauseY = 20; private final Joystick joystick; private final Player player; public static boolean canMove; Loading Loading @@ -53,10 +57,10 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { Log.d("DIMENSION", String.valueOf(height)); Log.d("DIMENSION", String.valueOf(width)); // Set background // Set background and pause Button Bitmap original = BitmapFactory.decodeResource(context.getResources(), R.drawable.new_classroom_spots_scaled); background = Bitmap.createScaledBitmap(original, width, height, false); pauseButton = BitmapFactory.decodeResource(context.getResources(), R.drawable.pause_new); // Initialize game objects // initialize joystick int joystickX = 150; Loading @@ -80,6 +84,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { @Override public boolean onTouchEvent(MotionEvent event) { // handle touch event actions pauseTouch = onSingleTap(event); switch(event.getAction()) { // when user presses down case MotionEvent.ACTION_DOWN: Loading Loading @@ -137,6 +142,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { detector1.draw(canvas); detector2.draw(canvas); detector3.draw(canvas); canvas.drawBitmap(pauseButton, pauseX, pauseY, null); } // method to display how many updates per second (UPS) public void drawUPS(Canvas canvas) { Loading Loading @@ -192,6 +198,11 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { } canMove = false; } if(pauseTouch) { startPauseActivity(); } } // check screen width and height Loading @@ -216,4 +227,23 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { Intent intent = new Intent(gameContext, FirebaseActivity.class); gameContext.startActivity(intent); } public void startPauseActivity() { Intent intent = new Intent(gameContext, MenuPause.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); gameContext.startActivity(intent); } public boolean onSingleTap(MotionEvent event) { int x = (int) event.getX(); int y = (int) event.getY(); if (pauseX < x && x < (pauseX + pauseButton.getWidth()) //if user touches pause button && pauseY < y && y < (pauseY + pauseButton.getHeight())) { return true; } return false; } } Loading
.idea/compiler.xml +1 −1 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="CompilerConfiguration"> <bytecodeTargetLevel target="17" /> <bytecodeTargetLevel target="11" /> </component> </project> No newline at end of file
.idea/misc.xml +2 −1 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/build/classes" /> </component> <component name="ProjectType"> Loading
app/src/main/AndroidManifest.xml +4 −1 Original line number Diff line number Diff line Loading @@ -11,6 +11,9 @@ android:supportsRtl="true" android:theme="@style/Theme.Game2D" tools:targetApi="31"> <activity android:name=".MenuPause" android:exported="false" /> <activity android:name=".ChalkGameRIPActivity" android:exported="false" Loading
app/src/main/java/com/example/game2d/ChalkGameClass.java +13 −18 Original line number Diff line number Diff line Loading @@ -59,14 +59,10 @@ public class ChalkGameClass extends View { private Bitmap pauseButton; private int pauseX = 1700; private int pauseX = 1800; private int pauseY = 20; private boolean pauseTouch = false; private Bitmap hintButton; private int hintX = 1800; private int hintY = 20; private int chalkIndex; Loading @@ -82,8 +78,8 @@ public class ChalkGameClass extends View { selectedShortHair = preferences.getBoolean("shortHairSelection", false); chalkIndex = preferences.getInt("ChalkQuestionIndex", 0); // ranGravity = (int) Math.floor(Math.random() * 5) + 1; //ranGravity is a random integer between 1 and 5 ranGravity = 2; ranGravity = (int) Math.floor(Math.random() * 5) + 1; //ranGravity is a random integer between 1 and 5 if(ranGravity%2 ==1) normGravity = true; //if ranGravity is odd, normal gravity is used where you jump up but rest at the bottom else Loading Loading @@ -125,7 +121,7 @@ public class ChalkGameClass extends View { } jumpcount = 0; lifeXstart = 1330; lifeXstart = 1430; //Initializing the chalk array Loading @@ -139,7 +135,7 @@ public class ChalkGameClass extends View { lifecounter = 3; pauseButton = BitmapFactory.decodeResource(getResources(), R.drawable.pause_new); hintButton = BitmapFactory.decodeResource(getResources(), R.drawable.question_new); } Loading Loading @@ -246,7 +242,7 @@ public class ChalkGameClass extends View { if(chalkPassed == chalkNum * 3) { chalkX[ii] = chalkX[ii] - 800; chalkXSpeed = 0; chalkPassed = 0; bossMusic.stop(); Loading Loading @@ -305,7 +301,6 @@ public class ChalkGameClass extends View { } canvas.drawBitmap(hintButton,hintX, hintY, null); } Loading @@ -330,11 +325,14 @@ public class ChalkGameClass extends View { { pauseTouch = onSingleTap(event); if (event.getAction() == MotionEvent.ACTION_UP) { if(pauseTouch == false) { touch = true; playerSpeed = -30; jumpcount++; } } return true; } Loading @@ -353,10 +351,7 @@ public class ChalkGameClass extends View { int y = (int) event.getY(); if ((pauseX < x && x < (pauseX + pauseButton.getWidth()) //if user touches pause button && pauseY < y && y < (pauseY + pauseButton.getHeight())) || ( hintX < x && x < (hintX + hintButton.getWidth()) // or if user touches hint button && hintY < y && y < (hintY + hintButton.getHeight())) ) && pauseY < y && y < (pauseY + pauseButton.getHeight()))) { return true; } Loading
app/src/main/java/com/example/game2d/Game.java +32 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,10 @@ and rendering all objects to the screen. */ public class Game extends SurfaceView implements SurfaceHolder.Callback { Bitmap background; Bitmap pauseButton; private boolean pauseTouch; private int pauseX = 1800; private int pauseY = 20; private final Joystick joystick; private final Player player; public static boolean canMove; Loading Loading @@ -53,10 +57,10 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { Log.d("DIMENSION", String.valueOf(height)); Log.d("DIMENSION", String.valueOf(width)); // Set background // Set background and pause Button Bitmap original = BitmapFactory.decodeResource(context.getResources(), R.drawable.new_classroom_spots_scaled); background = Bitmap.createScaledBitmap(original, width, height, false); pauseButton = BitmapFactory.decodeResource(context.getResources(), R.drawable.pause_new); // Initialize game objects // initialize joystick int joystickX = 150; Loading @@ -80,6 +84,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { @Override public boolean onTouchEvent(MotionEvent event) { // handle touch event actions pauseTouch = onSingleTap(event); switch(event.getAction()) { // when user presses down case MotionEvent.ACTION_DOWN: Loading Loading @@ -137,6 +142,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { detector1.draw(canvas); detector2.draw(canvas); detector3.draw(canvas); canvas.drawBitmap(pauseButton, pauseX, pauseY, null); } // method to display how many updates per second (UPS) public void drawUPS(Canvas canvas) { Loading Loading @@ -192,6 +198,11 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { } canMove = false; } if(pauseTouch) { startPauseActivity(); } } // check screen width and height Loading @@ -216,4 +227,23 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { Intent intent = new Intent(gameContext, FirebaseActivity.class); gameContext.startActivity(intent); } public void startPauseActivity() { Intent intent = new Intent(gameContext, MenuPause.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); gameContext.startActivity(intent); } public boolean onSingleTap(MotionEvent event) { int x = (int) event.getX(); int y = (int) event.getY(); if (pauseX < x && x < (pauseX + pauseButton.getWidth()) //if user touches pause button && pauseY < y && y < (pauseY + pauseButton.getHeight())) { return true; } return false; } }