Heres my code. I have a lot of stuff commented out, thats for later use. But,
its supposed to be a rectangle that travels across the bottom of the screen,
i'm working on a game. I've already made Pong, kind of. Now i'm working on
another game, but this is giving me a major problem right from the beginning.
The rectangle will travel across the bottom, but run at like 3 frames a sec.
I'm a newbie to java, only been learning for about 1-2 months.



//Andrew Basti

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;

public class Blimp extends JApplet implements ActionListener, KeyListener
{
JPanel drawingArea = new JPanel();
JPanel scoreArea = new JPanel();

JLabel score = new JLabel("Score ");
Timer timer1;
//Timer timer2;

Graphics g;
Graphics gg;

int play1 = 0;

int timex = 50;
//int timey = 100;

//String score = new String("Player 1: " + play1 + " Player 2:
" + play2);

int xx = 0;
int yy = 0;
int x = 0;
int y = 300;
int h = 40;
int w = 20;

//public boolean pressedRight = true;
//public boolean pressedLeft = false;

Color bgColor = Color.DARK_GRAY;
//Color dropColor = Color.RED;

public void init()
{
timer1 = new Timer(timex,this);
//timer1.setInitialDelay(3000);

this.getContentPane().add(scoreArea, "North");
this.getContentPane().add(drawingArea, "Center");

scoreArea.add(score);
drawingArea.setBackground(Color.DARK_GRAY);

this.addKeyListener(this);
}
public void start()
{
g = drawingArea.getGraphics();
gg = scoreArea.getGraphics();
timer1.start();
//drawingArea.requestFocus();
}
public void stop()
{
timer1.stop();
}
public void actionPerformed(ActionEvent ae)
{
Object source = ae.getSource();

if(source == timer1)
{
stepCatcher();
animateCatcher();
}
}
public void stepCatcher ()
{
xx=x;
yy=y;
x+=5;
}
public void animateCatcher ()
{
g.setColor(bgColor);
g.fillRect(xx,yy,h,w);
g.setColor(Color.YELLOW);
g.fillRect(x,y,h,w);
}
public void keyPressed(KeyEvent ke)
{
/*int which = ke.getKeyChar();
if (which == 'k' || which == 'K')
{
pressedRight = true;
pressedLeft = false;
}
else if (which == 'j' || which == 'J')
{
pressedLeft = true;
pressedRight = false;
}
//animate2();*/
}
public void keyReleased(KeyEvent ke){}
public void keyTyped(KeyEvent ke)
{
/*int which = ke.getKeyChar();
if (which == 'k' || which == 'K')
{
pressedRight = true;
pressedLeft = false;
}
else if (which == 'j' || which == 'J')
{
pressedLeft = true;
pressedRight = false;
}*/
//animate2();
}
}