Scratch for Java

Sprite::pickRandom()

Picks a random number between the two limits.

Examples

import org.openpatch.scratch.*;

public class SpritePickRandom {
  public SpritePickRandom() {
    Stage myStage = new Stage(600, 240);
    Sprite zeta = new Sprite("green", "assets/zeta_green_badge.png");
    myStage.add(zeta);

    while (myStage.getTimer().forMillis(3000)) {
      int random = zeta.pickRandom(0, 100);
      zeta.think("Random: " + random);
      myStage.wait(200);
    }
    myStage.exit();
  }

  public static void main(String[] args) {
    new SpritePickRandom();
  }
}

View on GitHub

Syntax

Java

.pickRandom(min, max)

Scratch

Parameters

NameData TypeDescription
minintMinimal integer.
maxintMaximal integer.

Return

int