I haven’t been programming in processing or java that long, but I am trying to make a game where and enemy spawns at random inter volts, but my enemy program isn’t working. Any help? Thank you
//var setup
int high = 2;
int enemyX = 850;
//setting it up
void setup() {
background(150);
size(1280, 800);
line(0, 260, 1280, 260);
line(0, 530, 1280, 530);
}
//Changing the variable for player height
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == 38 && !(high == 3)) {
high = high + 1;
} else if (e.getKeyCode() == 40 && !(high == 1)) {
high = high - 1;
}
}
//Player Drawing
void draw() {
if (high == 2) {
background(150);
line(0, 260, 1280, 260);
line(0, 530, 1280, 530);
rectMode(CENTER);
rect(300, 395, 250, 250);
} else if (high == 1) {
background(150);
line(0, 260, 1280, 260);
line(0, 530, 1280, 530);
rectMode(CENTER);
rect(300, 665, 250, 250);
} else if (high == 3) {
background(150);
line(0, 260, 1280, 260);
line(0, 530, 1280, 530);
rectMode(CENTER);
rect(300, 130, 250, 250);
}
if (enemyX <= 0) {
rectMode(CENTER);
rect(enemyX,665,250,250);
enemyX = enemyX - 5;
}
}