so im trying to make a game for school that i have to have done by friday at the max

my source for the main class is

//shooter game
//main class

import javax.swing.*;              //frame
import java.awt.*;                //color
import java.util.*;
import java.awt.event.*;

public class Shooter extends JFrame implements KeyListener{
		Image img;
		Graphics dbi;
		
		boolean u,d,w,s;
		int S,E;
		
	    Player p1=new Player(5,150,10,50,Color.RED,"LEFT.gif");
	    Player p2=new Player(585,150,10,50,Color.GREEN,"RIGHT.gif");
	    ArrayList<Bullets>b=new ArrayList<Bullets>();
	
	public Shooter () {
		setTitle("Shooter");
		setSize(600,400);
		setResizable(false);
		setBackground(Color.BLACK);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		addKeyListener(this);
		u=d=w=s=false;
		S=E=0;
		
		setVisible(true);
	}
	
	public void paint(Graphics g){
		img=createImage(getWidth(),getHeight());
		dbi=img.getGraphics();
		
		paintComponent(dbi);
		g.drawImage(img,0,0,this);
		repaint();
	}
	public void paintComponent(Graphics g){
		if(p1.health>0&&p2.health>0){
			for(Bullets b1:b){
				b1.draw(g);
			}
			update();
		}
		else{
			if(p1.health<=0){
				g.setColor(p2.col);
				g.drawString("PLAYER 2 WINS!",250,190);
			}
			else{g.setColor(p1.col);
				g.drawString("PLAYER 1 WINS!",250,190);
				
			}
		}
		p1.draw(g);
		p2.draw(g);
		
	}
	public void update(){
		if(w&&p1.y>24)p1.moveUp();
		if(s&&p1.y<347)p1.moveDown();
		if(u&&p2.y>24)p2.moveUp();
		if(d&&p2.y<347)p2.moveDown();
		if(E==1){
			Bullets add=p2.getBull();
			add.xVel=-3;
			b.add(add);
			E++;
			E++;
		}
		if(S==1){
			Bullets add=p1.getBull();
			add.xVel=3;
		}
		for(int x=0;x<b.size();x++){
			b.get(x).move();
			if(b.get(x).rect.intersects(p1.rect)&&b.get(x).xVel<0){
				p1.health--;
				b.remove(x);
				x--;
				continue;
			}
			if(b.get(x).rect.intersects(p2.rect)&&b.get(x).xVel<0){
				p2.health--;
				b.remove(x);
				x--;
				continue;
			}
			
			
		}
	}
	public void keyTyped(KeyEvent e){}
	public void keyPressed(KeyEvent e){
		switch(e.getKeyCode()){
			case KeyEvent.VK_UP:u=true;break;
		case KeyEvent.VK_DOWN:d=true;break;
		case KeyEvent.VK_W:w=true;break;
		case KeyEvent.VK_S:s=true;break;


		case KeyEvent.VK_SPACE:S++;break;
		case KeyEvent.VK_ENTER:E++;break;
		}
		
	}
	public void keyReleased(KeyEvent e){
		switch(e.getKeyCode()){
			case KeyEvent.VK_UP:u=false;
			case KeyEvent.VK_DOWN:d=false;
			case KeyEvent.VK_W:w=false;
			case KeyEvent.VK_S:s=false;
			
			case KeyEvent.VK_ENTER:E=0;break;
			case KeyEvent.VK_SPACE:S=0;break;
			
		}
	}
	
	
	
	public static void main(String[]beans){
		KeyListener a=new Shooter ();
	}
}

i get the error
cannot find symbol constructor Player(int,int,int,intjava.awt.Color.lang.String
for lines 16 and 17


which are

Player p1=new Player(5,150,10,50,Color.RED,"LEFT.gif");
	    Player p2=new Player(585,150,10,50,Color.GREEN,"RIGHT.gif");

any help would be muchly appreciated

Class Player, wherever it's declared needs to have a constructor having the signature

public Player(int, int, int, int, java.awt.Color, lang.String){
}

in Player class define constructor as you need...

you can define more than one constructor also..

class name and constructor name should be same...

my player class is this what should change/add to fix the the error in other post

//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 ht,int wd){       
		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 ht,int wd, 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 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);
	}					
}

here the constructor you called with 6 parameters..

Player p1=new Player(5,150,10,50,Color.RED,"LEFT.gif");


but in your code no matching arguments with 6 parameters..

14.public Player(){ 

22.public Player(int x,int y){      

	
32. public Player(int x, int y,int ht,int wd){       


43.public Player(int x, int y,int ht,int wd, String s){

i added

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);
		
		
	}

but im still getting the same error

i added

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);
		
		
	}

but im still getting the same error

add like this..

Player p1=new Player(5,150,10,50,new Color(0,0,0,0),"LEFT.gif");


change value untill you get decided color..like new Color(25,25,15,15)..etc..

that didnt work either i changed it to

Player p1=new Player(5,150,10,50,new Color(25,25,20,15),"LEFT.gif");
	    Player p2=new Player(585,150,10,50,new Color(25,10,15,15),"RIGHT.gif");

another problem im having is when i run it my window is clear no background at all

then post your error which thrown by compiler...

except bullet class i ran it ...

it outputs on window with text Play win!!

i still get the same error the build out put says

--------------------Configuration: shooter - JDK version 1.6.0_18 <Default> - <Default>--------------------
C:\Users\nic\Documents\shooter\src\Shooter.java:18: cannot find symbol
symbol : constructor Player(int,int,int,int,java.awt.Color,java.lang.String)
location: class Player
Player p1=new Player(5,150,10,50,new Color(25,25,20,15),"LEFT.gif");
^
C:\Users\nic\Documents\shooter\src\Shooter.java:19: cannot find symbol
symbol : constructor Player(int,int,int,int,java.awt.Color,java.lang.String)
location: class Player
Player p2=new Player(585,150,10,50,new Color(25,10,15,15),"RIGHT.gif");
^
2 errors

Process completed.

are these two class in the same directory..

reason for such an error is

When a programmer do not Imported the class name.

check you imported or not this line

import package.Player

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

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

mark it as solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.