Loading app/src/main/java/com/example/game2d/Game.java +15 −4 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { public static boolean canMove; private final Detector detector1; private final Detector detector2; private final Detector detector3; private GameLoop gameLoop; private Context gameContext; Loading Loading @@ -69,6 +70,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { // initialize new detectors 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); // copy other developers lol setFocusable(true); Loading Loading @@ -134,6 +136,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { // draw single detectors detector1.draw(canvas); detector2.draw(canvas); detector3.draw(canvas); } // method to display how many updates per second (UPS) public void drawUPS(Canvas canvas) { Loading Loading @@ -166,13 +169,13 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { player.update(); detector1.update(); detector2.update(); detector3.update(); // Check for collision with detectors if (Circle.isColliding(player, detector1)) { if (canMove) { // call method to start quiz activity startSecondActivity(); } Log.d("COLLISION", "DETECTOR"); canMove = false; } if (Circle.isColliding(player, detector2)) { Loading @@ -180,7 +183,13 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { // call method to start chalk activity startChalkActivity(); } Log.d("COLLISION", "DETECTOR"); canMove = false; } if (Circle.isColliding(player, detector3)) { if (canMove) { // call method to start leaderboard activity startLeaderboardActivity(); } canMove = false; } } Loading @@ -197,12 +206,14 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { public void startSecondActivity() { Intent intent = new Intent(gameContext, NameIntroActivity.class); gameContext.startActivity(intent); Log.d("COLLISION", "Starting name activity"); } // method to start chalk activity public void startChalkActivity() { Intent intent = new Intent(gameContext, ChalkIntroActivity.class); gameContext.startActivity(intent); Log.d("COLLISION", "Starting chalk activity"); } public void startLeaderboardActivity() { Intent intent = new Intent(gameContext, FirebaseActivity.class); gameContext.startActivity(intent); } } app/src/main/java/com/example/game2d/LeaderboardActivity.java +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ public class LeaderboardActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_leaderboard); Log.d("LEADERBOARD", "Leaderboard activity"); Window window = getWindow(); window.setFlags( Loading Loading
app/src/main/java/com/example/game2d/Game.java +15 −4 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { public static boolean canMove; private final Detector detector1; private final Detector detector2; private final Detector detector3; private GameLoop gameLoop; private Context gameContext; Loading Loading @@ -69,6 +70,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { // initialize new detectors 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); // copy other developers lol setFocusable(true); Loading Loading @@ -134,6 +136,7 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { // draw single detectors detector1.draw(canvas); detector2.draw(canvas); detector3.draw(canvas); } // method to display how many updates per second (UPS) public void drawUPS(Canvas canvas) { Loading Loading @@ -166,13 +169,13 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { player.update(); detector1.update(); detector2.update(); detector3.update(); // Check for collision with detectors if (Circle.isColliding(player, detector1)) { if (canMove) { // call method to start quiz activity startSecondActivity(); } Log.d("COLLISION", "DETECTOR"); canMove = false; } if (Circle.isColliding(player, detector2)) { Loading @@ -180,7 +183,13 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { // call method to start chalk activity startChalkActivity(); } Log.d("COLLISION", "DETECTOR"); canMove = false; } if (Circle.isColliding(player, detector3)) { if (canMove) { // call method to start leaderboard activity startLeaderboardActivity(); } canMove = false; } } Loading @@ -197,12 +206,14 @@ public class Game extends SurfaceView implements SurfaceHolder.Callback { public void startSecondActivity() { Intent intent = new Intent(gameContext, NameIntroActivity.class); gameContext.startActivity(intent); Log.d("COLLISION", "Starting name activity"); } // method to start chalk activity public void startChalkActivity() { Intent intent = new Intent(gameContext, ChalkIntroActivity.class); gameContext.startActivity(intent); Log.d("COLLISION", "Starting chalk activity"); } public void startLeaderboardActivity() { Intent intent = new Intent(gameContext, FirebaseActivity.class); gameContext.startActivity(intent); } }
app/src/main/java/com/example/game2d/LeaderboardActivity.java +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ public class LeaderboardActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_leaderboard); Log.d("LEADERBOARD", "Leaderboard activity"); Window window = getWindow(); window.setFlags( Loading