Re: need help quickly plz!!!
Hi,
You are using a Player class which is not defined anywhere. Please define Player class first and then try to execute your Shooter class
Re: need help quickly plz!!!
this is my Player class
Code :
//shooter game
//player class
import java.awt.*;
public class Player{
int x,y;
int height,width;
int health;
Image img;
Rectangle rect;
Color col;
public Player(){
x=y=height=width=0;
img=null;
col=Color.WHITE;
health=10;
rect=new Rectangle(x,y,width,height);
}
public Player(int x,int y){
this.x=x;
this.y=y;
height=width=0;
col=Color.WHITE;
img=null;
health=10;
rect=new Rectangle(x,y,width,height);
}
public Player(int x,int y,int wd,int ht){
this.x=x;
this.y=y;
height=ht;
width=wd;
img=null;
col=Color.WHITE;
health=10;
rect=new Rectangle(x,y,width,height);
}
public Player(int x,int y,int wd,int ht,String s){
this.x=x;
this.y=y;
height=ht;
width=wd;
col=Color.WHITE;
health=10;
img=Toolkit.getDefaultToolkit().getImage(s);
rect=new Rectangle(x,y,width,height);
}
public Player(int x,int y,int wd,int ht,Color c,String s){
this.x=x;
this.y=y;
height=ht;
width=wd;
col=c;
health=10;
img=Toolkit.getDefaultToolkit().getImage(s);
rect=new Rectangle(x,y,width,height);
}
public void draw(Graphics g){
g.drawImage(img,x,y,null);
}
public void setImage(String s){
img=Toolkit.getDefaultToolkit().getImage(s);
}
public void moveUp() {
y-=3;
rect.setLocation(x,y);
}
public void moveDown(){
y+=3;
rect.setLocation(x,y);
}
public Bullets getBull(){
return new Bullets(x+8,y+23,3,3,col);
}
}
Re: need help quickly plz!!!
Hi I used your player class but now it is giving an error on Bullets. What is Bullets now?
Is it some another class?
Re: need help quickly plz!!!
yes here it is
Code :
//shooter game
//Bullets class
import java.awt.*;
public class Bullets{
int x,y;
int xVel;
int height,width;
Rectangle rect;
Color col;
public Bullets(){
x=y=height=width=0;
col=Color.WHITE;
rect=new Rectangle(x,y,width,height);
}
public Bullets (int x,int y,int wd,int ht,Color c){
this.x=x;
this.y=y;
this.xVel=0;
height=ht;
width=wd;
col=c;
rect=new Rectangle(x,y,width,height);
}
public Bullets (int x,int y,int wd,int ht,int xVel,Color c){
this.x=x;
this.y=y;
this.xVel=xVel;
height=ht;
width=wd;
col=c;
rect=new Rectangle(x,y,width,height);
}
public void draw(Graphics g){
g.setColor(col);
g.fillOval(x,y,width,height);
}
public void move(){
x=+xVel;
rect.setLocation(x,y);
}
}
Re: need help quickly plz!!!
i dont know what was happening but i recopied the code into a different workspace and now i have no errors thank you so much
Re: need help quickly plz!!!
Hi I want to run your program. Please give the necessary files like LEFT.gif and Right.gif. I want to try your program.