import javax.microedition.lcdui.game.*;
import javax.microedition.lcdui.*;
public class BallCanvas extends GameCanvas implements Runnable
{
int x;
int y;
int vx;
int vy;
Graphics g;
public BallCanvas()
{
super(false);
x = 0;
y = 0;
vy = 1;
vx = 1;
setFullScreenMode(true);
g = this.getGraphics();
}
public void run()
{
if ((x > 100) | (x < 0))
{
vx = -vx;
}
if ((y > 100) | (y < 0))
{
vy = -vy;
}
vx += vx;
vy += vy;
g.fillRect(20, 20, 20, 20);
try
{
Thread.sleep(150);
}
catch(Exception e)
{
}
}
}
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Ball extends MIDlet
{
Display dis;
BallCanvas mainCanvas;
public Ball()
{
dis = Display.getDisplay(this);
mainCanvas = new BallCanvas();
}
public void startApp()
{
System.out.println("START");
Thread t = new Thread(mainCanvas);
}
public void pauseApp()
{
System.out.println("PAUSE");
}
public void destroyApp(boolean b)
{
System.out.println("CANCEL");
}
}
import javax.microedition.lcdui.*;
public class BallCanvas extends GameCanvas implements Runnable
{
int x;
int y;
int vx;
int vy;
Graphics g;
public BallCanvas()
{
super(false);
x = 0;
y = 0;
vy = 1;
vx = 1;
setFullScreenMode(true);
g = this.getGraphics();
}
public void run()
{
if ((x > 100) | (x < 0))
{
vx = -vx;
}
if ((y > 100) | (y < 0))
{
vy = -vy;
}
vx += vx;
vy += vy;
g.fillRect(20, 20, 20, 20);
try
{
Thread.sleep(150);
}
catch(Exception e)
{
}
}
}
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Ball extends MIDlet
{
Display dis;
BallCanvas mainCanvas;
public Ball()
{
dis = Display.getDisplay(this);
mainCanvas = new BallCanvas();
}
public void startApp()
{
System.out.println("START");
Thread t = new Thread(mainCanvas);
}
public void pauseApp()
{
System.out.println("PAUSE");
}
public void destroyApp(boolean b)
{
System.out.println("CANCEL");
}
}