How to wait for input?
in
Programming Questions
•
1 year ago
Here is my code so far:
- import processing.core.*;
import java.util.*; - public class Monopoly extends PApplet
{
PImage img;
public void setup()
{
img = loadImage("monopoly.jpg");
size(687, 807);
smooth();
PFont new_font;
new_font = loadFont("BankGothic-Medium-48.vlw");
textFont(new_font, 32);
}
int turn;
String names[] = {"GO", "Mediteranean Avenue", "Community Chest", "Baltic Avenue", "Income Tax", "Reading Railroad", "Oriential Avenue", "Chance", "Vermont Avenue", "Connecticut Avenue", "Just Visiting", "St. Charles Place", "States Avenue", "Virginia Avenue", "Pennsylvania Railroad", "St. James Place", "Community Chest", "Tennesee Avenue", "New York Avenue", "Free Parking", "Kentucky Avenue", "Chance", "Indiana Avenue", "Illinois Avenue", "B & O Railroad", "Atlantic Avenue", "Ventnor Avenue", "Water Works", "Marven Gardens", "Jail", "Pacific Avenue", "North Carolina Avenue", "Community Chest", "Pennsylvania Avenue", "Short Line", "Chance", "Park Place", "Luxury Tax", "Boardwalk"};
int properties = 0;
public void draw()
{
int score = 0;
int roll = 0;
int num = 0;
int num1 = 0;
turn = 0;
if (properties != 15)
{
Random rand = new Random();
num = rand.nextInt(6);
num1 = rand.nextInt(6);
roll = num + num1;
fill(255);
smooth();
background(0);
image(img, 0, 100);
text("Score: $" + score, 0, 32);
text("Roll: " + roll, 0, 64);
if (turn == 0)
{
text("Turn = Player", 0, 96);
}
else
if (turn == 1)
{
text("Turn = Computer", 0, 96);
}
text("Press 'Enter':", 300, 32);
if (key == '\n')
{
try
{
Thread.sleep(5);
}
catch
(InterruptedException e)
{
}
}
}
}
} How would I make it wait for the users input after it says Press Enter?
1