Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created June 8, 2021 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeforfun-jp/45760b6f5977b7a6b09ea7f48579b4ea to your computer and use it in GitHub Desktop.
Save codeforfun-jp/45760b6f5977b7a6b09ea7f48579b4ea to your computer and use it in GitHub Desktop.
CTB 6-2
public void hitCheck() {
// Orange
float orangeCenterX = orangeX + orange.getWidth() / 2;
float orangeCenterY = orangeY + orange.getHeight() / 2;
if (0 <= orangeCenterX && orangeCenterX <= boxSize &&
boxY <= orangeCenterY && orangeCenterY <= boxY + boxSize) {
orangeX = -10.0f;
score += 10;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment