i wrote a game and i have a cannot find symbol constuctor error. i need this by the morning or at the latest tommarow its for a school project.
my code for the main class is
//shooter game //main class import javax.swing.*; //frame import java.awt.*; //color import java.util.*; import java.awt.event.*; import java.io.*; 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,600); 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,int,java.awt.Color,java.lang.St ring)
on lines 18 and 19
Player p1=new Player(5,150,10,50,Color.RED,"LEFT.gif"); Player p2=new Player(585,150,10,50,Color.GREEN,"RIGHT.gif");
i have no clue what to do so any help would be great thanx