Reference no: EM13162851
a mini game made in Java using Zen graphics .
1. An option to fix the numbers for how they always fall vertically and don't reset back to the top if they fall past the bottom of the screen
2. Flicker fix if possible using use Zen.flipBuffer
3. Making the game die with an exception if possible
4. Making game harder over time in no errors
5. Visual distractions if possible
6. Option to skip easier levels
public static void main(String[] args) {
int x=0, y=0, dx=0, dy=0, score = 0;
String text = "";
long startTime =System.currentTimeMillis();
Zen.setFont("Helvetica-33");
while (Zen.isRunning()) {
if (text.length() == 0) {
x = 0;
y = Zen.getZenHeight() / 2;
dx = 2;
dy = 0;
text = "" + (int) (Math.random() * 999);
long elapsed = System.currentTimeMillis() - startTime;
startTime = System.currentTimeMillis();
score += 3000 / elapsed;
}
Zen.setColor(255, 0, 255);
Zen.fillRect(0, 0, Zen.getZenWidth(), Zen.getZenHeight());
Zen.setColor(0, 255, 0);
Zen.drawText(text, x, y);
Zen.drawText("Level: 0",10,30);
Zen.drawText("Score: 0",10,60);
x += dx;
y += dy;
// Find out what keys the user has been pressing.
String user = Zen.getEditText();
// Reset the keyboard input to an empty string
// So next iteration we will only get the most recently pressed keys.
Zen.setEditText("");
for(int i=0;i < user.length();i++) {
char c = user.charAt(i);
if(c == text.charAt(0))
text = text.substring(1,text.length()); // all except first character
}
Zen.sleep(90);// sleep for 90 milliseconds
}
}
}