I currently have a mini game made in Java using Zen graphics but I was told to a
ID: 3551559 • Letter: I
Question
I currently have a mini game made in Java using Zen graphics but I was told to add more stuff to it if possible. If anyone could help me that would be awesome. Nothing challenging just additional options for the game to follow if possible. Only need a few but if all are acheived that be awesome!
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
}
}
}
Explanation / Answer
Here ya go partner! Yeee Hawwww! Make your own edits fruit cake!
int x = 0, y = 0, dx = 0, dy = 0, score = 0;
String text = "";
int life = 3; //How many lives game starts with
long startTime = System.currentTimeMillis();
Zen.setFont("Calibri-33");
while (Zen.isRunning() && life > 0) {
y = 0;// Answer for Question 0 I assume :P
boolean solved=false;
while (y <= Zen.getZenHeight()) {
if (text.length() == 0) {
x = (int) (((Zen.getZenWidth() / 2) * Math.random()) + 150);
y = 20;
dx = 0;
dy = (1 + (int)(score / 100)); //Faster Speed Here
text = "" + (int) (Math.random() * 999);
long elapsed = System.currentTimeMillis() - startTime;
if (elapsed != 0 && solved) {
score += elapsed/10;
solved = false;
}
}
Zen.setColor(0, 0, 0);//Control color of Backround
Zen.fillRect(10, 10, Zen.getZenWidth(), Zen.getZenHeight());//Two values control what border ignores Zen Color
Zen.setColor(20, 250, 20);//Control light effects of game fonts
Zen.drawText(text, x, y);
Zen.drawText("Level: " + (1 + (int)(score / 200)), 10,
Zen.getZenHeight() - 20);
Zen.drawText("Score: " + (score), 5, 60);
Zen.drawText(" Life: " + life, 10, 180);
Zen.fillRect(150, 20, 5, 450); //Control the line between game & scores
// Text Line
Zen.flipBuffer();
x += dx;
y += dy;
String user = Zen.getEditText();
Zen.setEditText("");
if (y == Zen.getZenHeight())
life--;
for (int i = 0; i < user.length(); i++) {
char c = user.charAt(i);
if (c == text.charAt(0))
text = text.substring(1);
}
solved = true;
startTime = System.currentTimeMillis();
Zen.sleep(100);
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.