Accepting user input for visual assignment

edited November 2017 in Questions about Code

first post here so bear with me :P

Now I'm not a programmer by trade, but my university offers a programming unit related to digital arts using processing. An assignment I'm working on requires the user to input an integer value which is then used to create a range for randomization. Ideally the output should look like a bunch of random high-rises, creating a city skyline (abstract art don't question it) with 5 "high-rises". However, only one is appearing and the GUI appears again. Any help would be much appreciated as I'm at wits end with my deadline approaching fast :|

import static javax.swing.JOptionPane.*; //GUI element class

void setup() { //setup canvas size(1250,750); //sets size of canvas



void draw(){

    String input = showInputDialog("Type in integer number...");
    int num = parseInt(input == null? "" : input, MIN_INT);

    if (input == null)  showMessageDialog(null, "You didn't enter anything!", "Alert", ERROR_MESSAGE);
    else if (num == MIN_INT)  showMessageDialog(null, "Entry \"" + input + "\" isn't a number!", "Alert", ERROR_MESSAGE);
    else showMessageDialog(null, "Number " + num + " has been registered.", "Info", INFORMATION_MESSAGE);

for(int i = 0 ; i < 5 ; i++) {

  background(random(125,175),random(125,175),random(125,175));  //sets colour of canvas, ideally in rgb

  fill (random (150,255));

  float X = random(num,num+400);
  float Y = random(num,num+450);


Sign In or Register to comment.