hello, i need to make a simple version of the game CITY JUMPER url to the game: "http://www.addictinggames.com/cityjumper.html". I need to write a simple code for a java applet in JCreator. I have some done but it doesnt seem to be working right. also i can not get the keyboard to respond to the game. if someone knows anything abt a simple java program, can u please help. thanks in advance. Also, i dont know much abt java but i have to get this done for a project.. It will be kindly appreciated.
This is what I have so far for the
code:
/* Java based City Jumper Game
*
*
* ------
*
*/
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Jumper2 extends Applet implements Runnable, KeyListener {
int x = 0;
int y = 94;
int diam = 15;
public void init() {
Thread t = new Thread(this); // create thread
t.start(); // start thread
addKeyListener(this); // listen for when keyboard is used
} // end init
/*****************************************************************/ //All the graphics
public void paint(Graphics g) {
g.drawLine(0,110,800,110);
g.drawLine(0,260,800,260);
g.drawLine(0,410,800,410);
g.drawLine(0,535,800,535);
g.drawRect(150,55,50,55);//x , y , width, height
g.drawRect(420,55,60,55);
g.drawRect(680,55,20,55);
public void run() {
while (true) {
g.drawOval (x, y, diam, diam);
g.setColor(Color.white);
try {Thread.sleep(9);}
catch (InterruptedException e){}
g.drawOval(x, y, diam, diam);
g.setColor(Color.blue);
x = x+1;
}//while
}//run
}//paint
//******************************************************************
public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
if (key == e.VK_RIGHT) {
int y = y+5;
}
}
public void keyReleased(KeyEvent e) {
}//end keyReleased
public void keyTyped(KeyEvent e) {
}//end keyTyped
}//applet

This is what I have so far for the

/* Java based City Jumper Game
*
*
* ------
*
*/
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Jumper2 extends Applet implements Runnable, KeyListener {
int x = 0;
int y = 94;
int diam = 15;
public void init() {
Thread t = new Thread(this); // create thread
t.start(); // start thread
addKeyListener(this); // listen for when keyboard is used
} // end init
/*****************************************************************/ //All the graphics
public void paint(Graphics g) {
g.drawLine(0,110,800,110);
g.drawLine(0,260,800,260);
g.drawLine(0,410,800,410);
g.drawLine(0,535,800,535);
g.drawRect(150,55,50,55);//x , y , width, height
g.drawRect(420,55,60,55);
g.drawRect(680,55,20,55);
public void run() {
while (true) {
g.drawOval (x, y, diam, diam);
g.setColor(Color.white);
try {Thread.sleep(9);}
catch (InterruptedException e){}
g.drawOval(x, y, diam, diam);
g.setColor(Color.blue);
x = x+1;
}//while
}//run
}//paint
//******************************************************************
public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
if (key == e.VK_RIGHT) {
int y = y+5;
}
}
public void keyReleased(KeyEvent e) {
}//end keyReleased
public void keyTyped(KeyEvent e) {
}//end keyTyped
}//applet
