-
-
Save codeforfun-jp/ca729fd262362245f5469f15a4df1cab to your computer and use it in GitHub Desktop.
CTB 11-4
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
public void hitCheck() { | |
// Orange | |
float orangeCenterX = orangeX + orange.getWidth() / 2; | |
float orangeCenterY = orangeY + orange.getHeight() / 2; | |
if (hitStatus(orangeCenterX, orangeCenterY)) { | |
orangeX = -10.0f; | |
score += 10; | |
soundPlayer.playHitSound(); | |
} | |
// Pink | |
float pinkCenterX = pinkX + pink.getWidth() / 2; | |
float pinkCenterY = pinkY + pink.getHeight() / 2; | |
if (hitStatus(pinkCenterX, pinkCenterY)) { | |
pinkX = -10.0f; | |
score += 30; | |
soundPlayer.playHitSound(); | |
} | |
// Black | |
float blackCenterX = blackX + black.getWidth() / 2; | |
float blackCenterY = blackY + black.getHeight() / 2; | |
if (hitStatus(blackCenterX, blackCenterY)) { | |
// Game Over! | |
if (timer != null) { | |
timer.cancel(); | |
timer = null; | |
soundPlayer.playOverSound(); | |
} | |
// 結果画面へ | |
Intent intent = new Intent(getApplicationContext(), ResultActivity.class); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment