import java.awt.*;
import java.applet.*;
import java.awt.Graphics;
import java.awt.event.*;
public class playertest extends Applet implements KeyListener
{
int x=100;
int y=500;
public void paint (Graphics g)
{
g.setColor (Color.blue);
g.fillRect (x, y, 15, 15);
g.fillRect (x-6, y+3, 30, 5);
g.setColor (Color.black);
g.fillOval (x-2, y - 15, 20, 20);
eyes (g);
mouth (g);
}
public void eyes (Graphics g)
{
g.setColor (Color.white);
g.fillOval (x + 11, y - 12, 6, 6);
g.fillOval (x + 1, y - 12, 6, 6);
}
public void mouth (Graphics g)
{
g.setColor (Color.red);
g.fillOval (x + 5, y - 6, 12, 5);
}
public void moveleft ()
{
x = x-2;
}
public void moveright ()
{
x=x+2;
}
public void keyPressed (KeyEvent e)
{
if (e.getKeyCode () == KeyEvent.VK_UP)
moveleft ();
else if (e.getKeyCode () == KeyEvent.VK_LEFT)
moveleft ();
else if (e.getKeyCode () == KeyEvent.VK_RIGHT)
moveright ();
}
public void keyReleased (KeyEvent e)
{
if (e.getKeyCode () == KeyEvent.VK_UP)
x=x;
else if (e.getKeyCode () == KeyEvent.VK_LEFT)
x =x;
else if (e.getKeyCode () == KeyEvent.VK_RIGHT)
x = x;
}
public void keyTyped (KeyEvent e)
{
}
}