i am a student and new to java programming..
can yOu please heLp me to make my tank move?
just need it to go around the applet,
up, down, left and right directions.
please someone heLp!
here's the code for my tank:
import javax.swing.*;
public class tank extends JApplet implements KeyListener{
int x1,x2;
int y1,y2;
int enemies,hits;
public void init(){
x1=0;
x2=0;
y1=0;
y2=0;
enemies=10;
hits=0;
resize(500,500);
}
public void paint(Graphics c){
c.setColor(Color.yellow);
c.fillRect(0,0,500,80);
c.setColor(Color.yellow);
c.fillRect(0,0,80,500);
c.setColor(Color.yellow);
c.fillRect(420,80,80,420);
c.setColor(Color.blue);
c.drawRect(180,320,150,150);
c.drawRoundRect(180,320,30,150,10,10);
c.drawRoundRect(210,345,90,100,10,10);
c.drawRoundRect(230,370,50,50,10,10);
c.drawRect(249,290,10,80);
c.drawRect(244,280,20,10);
c.drawRoundRect(300,320,30,150,10,10);
c.fillPolygon(x,y,3);
c.drawString("ENEMIES : " + enemies,50,30);
c.drawString("HITS : " + hits,375,30);
}
public void keyTyped(KeyEvent ev){}
public void keyReleased(KeyEvent ev){}
public void keyPressed(KeyEvent ev){}
}
please anyone heLp me..
teach me the missing lines of codes to make my program complete..
please.........
thanks in advance. :)