Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created June 10, 2021 01:37
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/7226298a7e2e9716f0b0f32d31f86474 to your computer and use it in GitHub Desktop.
Save codeforfun-jp/7226298a7e2e9716f0b0f32d31f86474 to your computer and use it in GitHub Desktop.
CTB 12-3
public void changePos() {
hitCheck();
// Orange
orangeX -= orangeSpeed;
if (orangeX < 0) {
orangeX = screenWidth + 20;
orangeY = (float)Math.floor(Math.random() * (frameHeight - orange.getHeight()));
}
orange.setX(orangeX);
orange.setY(orangeY);
// Black
blackX -= blackSpeed;
if (blackX < 0) {
blackX = screenWidth + 10;
blackY = (float)Math.floor(Math.random() * (frameHeight - black.getHeight()));
}
black.setX(blackX);
black.setY(blackY);
// Pink
pinkX -= pinkSpeed;
if (pinkX < 0) {
pinkX = screenWidth + 5000;
pinkY = (float)Math.floor(Math.random() * (frameHeight - pink.getHeight()));
}
pink.setX(pinkX);
pink.setY(pinkY);
// Box
if (action_flg) {
boxY -= boxSpeed;
} else {
boxY += boxSpeed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment