Loading app/src/main/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,10 @@ android:supportsRtl="true" android:theme="@style/Theme.Game2D" tools:targetApi="31"> <activity android:name=".ArtActivity" android:exported="false" android:screenOrientation="landscape"/> <activity android:name=".ChalkGameRIPActivity" android:exported="false" Loading app/src/main/java/com/example/game2d/object/ArtActivity.java→app/src/main/java/com/example/game2d/ArtActivity.java +0 −0 File moved. View file app/src/main/java/com/example/game2d/Game.java +15 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { private final Detector detector1; private final Detector detector2; private final Detector detector3; private final Detector detector4; private GameLoop gameLoop; private Context gameContext; Loading Loading @@ -71,6 +72,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { detector1 = new Detector(getContext(), player, (float) (width * 0.25), (float) (height * 0.17), 100); detector2 = new Detector(getContext(), player, (float) (width * 0.47), (float) (height * 0.17), 100); detector3 = new Detector(getContext(), player, (float) (width * 0.75), (float) (height * 0.17), 100); detector4 = new Detector(getContext(), player, (float) (width * 0.1), (float) (height * 0.17), 100); // copy other developers lol setFocusable(true); Loading Loading @@ -137,6 +139,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { detector1.draw(canvas); detector2.draw(canvas); detector3.draw(canvas); detector4.draw(canvas); } // method to display how many updates per second (UPS) public void drawUPS(Canvas canvas) { Loading Loading @@ -170,6 +173,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { detector1.update(); detector2.update(); detector3.update(); detector4.update(); // Check for collision with detectors if (Circle.isColliding(player, detector1)) { if (canMove) { Loading @@ -192,6 +196,13 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { } canMove = false; } if (Circle.isColliding(player, detector4)) { if (canMove) { // call method to start art activity startArtActivity(); } canMove = false; } } // check screen width and height Loading @@ -216,4 +227,8 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { Intent intent = new Intent(gameContext, FirebaseActivity.class); gameContext.startActivity(intent); } public void startArtActivity() { Intent intent = new Intent(gameContext, ArtActivity.class); gameContext.startActivity(intent); } } Loading
app/src/main/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,10 @@ android:supportsRtl="true" android:theme="@style/Theme.Game2D" tools:targetApi="31"> <activity android:name=".ArtActivity" android:exported="false" android:screenOrientation="landscape"/> <activity android:name=".ChalkGameRIPActivity" android:exported="false" Loading
app/src/main/java/com/example/game2d/object/ArtActivity.java→app/src/main/java/com/example/game2d/ArtActivity.java +0 −0 File moved. View file
app/src/main/java/com/example/game2d/Game.java +15 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { private final Detector detector1; private final Detector detector2; private final Detector detector3; private final Detector detector4; private GameLoop gameLoop; private Context gameContext; Loading Loading @@ -71,6 +72,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { detector1 = new Detector(getContext(), player, (float) (width * 0.25), (float) (height * 0.17), 100); detector2 = new Detector(getContext(), player, (float) (width * 0.47), (float) (height * 0.17), 100); detector3 = new Detector(getContext(), player, (float) (width * 0.75), (float) (height * 0.17), 100); detector4 = new Detector(getContext(), player, (float) (width * 0.1), (float) (height * 0.17), 100); // copy other developers lol setFocusable(true); Loading Loading @@ -137,6 +139,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { detector1.draw(canvas); detector2.draw(canvas); detector3.draw(canvas); detector4.draw(canvas); } // method to display how many updates per second (UPS) public void drawUPS(Canvas canvas) { Loading Loading @@ -170,6 +173,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { detector1.update(); detector2.update(); detector3.update(); detector4.update(); // Check for collision with detectors if (Circle.isColliding(player, detector1)) { if (canMove) { Loading @@ -192,6 +196,13 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { } canMove = false; } if (Circle.isColliding(player, detector4)) { if (canMove) { // call method to start art activity startArtActivity(); } canMove = false; } } // check screen width and height Loading @@ -216,4 +227,8 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { Intent intent = new Intent(gameContext, FirebaseActivity.class); gameContext.startActivity(intent); } public void startArtActivity() { Intent intent = new Intent(gameContext, ArtActivity.class); gameContext.startActivity(intent); } }