public void checkPopupCollision() { for (int i = 0; i < 8; i++) { if (powerUps[i].isAktiv() && current_Player .getBounds() .intersects(powerUps[i].getX(), powerUps[i].getY(), 10, 10)) { powerUps[i].setAktiv(false); if (powerUps[i].getChange().equals("HP")) current_Player.setTp(current_Player.getTp() + powerUps[i].getChangeValue()); if (powerUps[i].getChange().equals("SP")) current_Player.setSpeed(powerUps[i].getChangeValue()); if (powerUps[i].getChange().equals("BP")) current_Player.setBp(current_Player.getBp() + powerUps[i].getChangeValue()); } } }
// Bewegung - Normal private void changepl() { // #if (mov_0) current_Player.setBp(250); current_Player.getSch().setStart_X(0); current_Player.getSch().setStart_Y(0); current_Player.getSch().setEnd_X(0); current_Player.getSch().setEnd_Y(0); current_Player.getSch().setterStart_time(0); current_Player.getSch().setterEnd_time(0); if (current_Player == player_1) { current_Player = player_2; other_Player = player_1; } else { current_Player = player_1; other_Player = player_2; } // #endif // #if (mov_1) // @ current_Player.setBp(0); // @ current_Player.getSch().setStart_X(0); // @ current_Player.getSch().setStart_Y(0); // @ current_Player.getSch().setEnd_X(0); // @ current_Player.getSch().setEnd_Y(0); // @ current_Player.getSch().setterStart_time(0); // @ current_Player.getSch().setterEnd_time(0); // @ current_Player.setLoad(0); // @ if (current_Player == player_1){ // @ current_Player = player_2; // @ other_Player = player_1; // @ } // @ else{ // @ current_Player = player_1; // @ other_Player = player_2; // @ } // #endif // #if (mov_2) // @ current_Player.setBp(250); // @ current_Player.getSch().setStart_X(0); // @ current_Player.getSch().setStart_Y(0); // @ current_Player.getSch().setEnd_X(0); // @ current_Player.getSch().setEnd_Y(0); // @ current_Player.getSch().setterStart_time(0); // @ current_Player.getSch().setterEnd_time(0); // @ if (current_Player == player_1){ // @ current_Player = player_2; // @ other_Player = player_1; // @ } // @ else{ // @ current_Player = player_1; // @ other_Player = player_2; // @ } // #elif (mov_3) // @ current_Player.setBp(0); // @ current_Player.getSch().setStart_X(0); // @ current_Player.getSch().setStart_Y(0); // @ current_Player.getSch().setEnd_X(0); // @ current_Player.getSch().setEnd_Y(0); // @ current_Player.getSch().setterStart_time(0); // @ current_Player.getSch().setterEnd_time(0); // @ current_Player.setLoad(0); // @ if (current_Player == player_1){ // @ current_Player = player_2; // @ other_Player = player_1; // @ } // @ else{ // @ current_Player = player_1; // @ other_Player = player_2; // @ } // #elif (mov_4) // @ current_Player.setBp(0); // @ current_Player.getSch().setStart_X(0); // @ current_Player.getSch().setStart_Y(0); // @ current_Player.getSch().setEnd_X(0); // @ current_Player.getSch().setEnd_Y(0); // @ current_Player.getSch().setterStart_time(0); // @ current_Player.getSch().setterEnd_time(0); // @ current_Player.setLoad(0); // @ if (current_Player == player_1){ // @ current_Player = player_2; // @ other_Player = player_1; // @ } // @ else{ // @ current_Player = player_1; // @ other_Player = player_2; // @ } // #endif }
public void drawBuffer() { Graphics2D b = buffer.createGraphics(); // DrawPanel Graphics2D pl_b = buffer.createGraphics(); Graphics2D pl_c = buffer.createGraphics(); rkt = buffer.createGraphics(); AffineTransform rkt_aff = new AffineTransform(); Graphics2D envi[] = new Graphics2D[amountEnv]; AffineTransform enviTrans[] = new AffineTransform[amountEnv]; b.setColor(Color.BLACK); b.fillRect(0, 0, w, h); // #if (Default) // @ // #elif (Blue_White) // @ ii_bg = new ImageIcon("imgs/Hintergrund/HgBlauWeiss1.gif"); // @ img_bg = ii_bg.getImage(); // @ b.drawImage(img_bg, w, w, this); // #elif (Blue_White_Green) // @ ii_bg = new ImageIcon("imgs/Hintergrund/HgBlauWeissGruen.gif"); // @ img_bg = ii_bg.getImage(); // @ b.drawImage(img_bg, w, w, this); // #elif (Purple_White) // @ ii_bg = new ImageIcon("imgs/Hintergrund/HgLilaWeiss.gif"); // @ img_bg = ii_bg.getImage(); // @ b.drawImage(img_bg, w, w, this); // #elif (Glass) // @ ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundglass05.gif"); // @ img_bg = ii_bg.getImage(); // @ b.drawImage(img_bg, w, w, this); // #elif (Lava) // @ ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundlava01.gif"); // @ img_bg = ii_bg.getImage(); // @ b.drawImage(img_bg, w, w, this); // #elif (Limba) // @ ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundlimba.gif"); // @ img_bg = ii_bg.getImage(); // @ b.drawImage(img_bg, w, w, this); // #elif (Old) ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundoldpnt01.gif"); img_bg = ii_bg.getImage(); b.drawImage(img_bg, w, w, this); // #elif (Ov_Paper) // @ ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundov_paper.gif"); // @ img_bg = ii_bg.getImage(); // @ b.drawImage(img_bg, w, w, this); // #elif (Paper) // @ ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundpaper05.gif"); // @ img_bg = ii_bg.getImage(); // @ b.drawImage(img_bg, w, w, this); // #elif (Univ) // @ ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrunduniv01.jpg"); // @ img_bg = ii_bg.getImage(); // @ b.drawImage(img_bg, w, w, this); // #elif (Water) // @ ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundwater01.jpg"); // @ img_bg = ii_bg.getImage(); // @ b.drawImage(img_bg, w, w, this); // #elif (Water_2) // @ ii_bg = new ImageIcon("imgs/Hintergrund/Hintergrundwater05.jpg"); // @ img_bg = ii_bg.getImage(); // @ b.drawImage(img_bg, w, w, this); // #endif b.setColor(Color.gray); b.fillRect(0, 0, w, 25); // oben b.fillRect(0, h - 50, w, 25); // unten b.fillRect(0, 0, 25, h); // links b.fillRect(w - 35, 0, 30, h); // rechts b.setColor(Color.WHITE); // rocket // #if (tar) // #if (Rectangle) // @ if (current_Player.isRocket()){ // @ rkt_aff.rotate(current_Player.getDegree(), sch.getX(), sch.getY()); // @ rkt.setTransform(rkt_aff); // @ System.out.println("Rok X:"+sch.getX()+" Rok Y:"+sch.getY()); // @ rkt.drawRect(sch.getX()+ current_Player.getWidth()/2, sch.getY() + // current_Player.getHeight()/2, kaliber, kaliber);} // Rocket 4Eck // #endif // #if (Oval) // @ if (current_Player.isRocket()){ // @ b.drawOval(sch.getX()+ current_Player.getWidth()/2, sch.getY() + // current_Player.getHeight()/2, kaliber, kaliber);} // Rocket Oval // #endif // #if (aa31) // @ if (current_Player.isRocket()){ // @ try { // @ rocketFire = ImageIO.read(new File("imgs/aa31.gif")); // @ rkt_aff.rotate(current_Player.getDegree(), sch.getX(), sch.getY()); // @ rkt.setTransform(rkt_aff); // @ rkt.drawImage(rocketFire, null, (int)sch.getX(), (int)sch.getY()); // @ //rkt.drawImage(rocketFire, null, (int)current_Player.getX(), // (int)current_Player.getY()); // @ } catch (IOException e) { // @ } // @ } // #endif // #if (Portal) // @ if (current_Player.isRocket()){ // @ try { // @ rocketFire = ImageIO.read(new File("imgs/portal.gif")); // @ rkt_aff.rotate(current_Player.getDegree(), sch.getX(), sch.getY()); // @ rkt.setTransform(rkt_aff); // @ rkt.drawImage(rocketFire, null, // sch.getX()+current_Player.getWidth()/2, sch.getY()+current_Player.getHeight()/2); // @ } catch (IOException e) { // @ } // @ } // #endif // #if (Nino) // @ if (current_Player.isRocket()){ // @ try { // @ rocketFire = ImageIO.read(new File("imgs/nino.gif")); // @ rkt_aff.rotate(current_Player.getDegree(), sch.getX(), sch.getY()); // @ rkt.setTransform(rkt_aff); // @ rkt.drawImage(rocketFire, null, // sch.getX()+current_Player.getWidth()/2, sch.getY()+current_Player.getHeight()/2); // @ } catch (IOException e) { // @ } // @ } // #endif // #endif for (int i = 0; i <= amountEnv - 1; i++) { envi[i] = buffer.createGraphics(); enviTrans[i] = new AffineTransform(); envi[i].setTransform(enviTrans[i]); envi[i].drawImage(env[i].getImg(), env[i].getX(), env[i].getY(), this); } for (int i = 0; i < 8; i++) { if (powerUps[i].isAktiv()) { b.setColor(powerUps[i].getCol()); b.drawImage(powerUps[i].getImg(), powerUps[i].getX(), powerUps[i].getY(), this); } } b.setColor(Color.WHITE); b.drawString("BP: " + current_Player.getBp(), 10, 20); b.drawString("TP P1/P2: " + player_1.getTp() + " / " + player_2.getTp(), 100, 20); if (current_Player.getSch().getEnd_X() != 0 && current_Player.getSch().getEnd_Y() != 0) { b.setColor(Color.YELLOW); b.drawLine( (int) current_Player.getSch().getStart_X(), (int) current_Player.getSch().getStart_Y(), (int) current_Player.getSch().getEnd_X(), (int) current_Player.getSch().getEnd_Y()); b.setColor(Color.WHITE); for (int i = 0; i < current_Player.getSch().getArImg().length; i++) { if (current_Player.getSch().getArImg()[i] != null && current_Player.getSch().isIsActive()) { b.drawImage( current_Player.getSch().getArImg()[i], (int) current_Player.getSch().getEnd_X() - current_Player.getSch().getArImg()[i].getWidth(this) / 2, (int) current_Player.getSch().getEnd_Y() - current_Player.getSch().getArImg()[i].getHeight(this) / 2, (int) (current_Player.getSch().getArImg()[i].getWidth(this) * (current_Player.getSch().getSpeed() / 150)), (int) (current_Player.getSch().getArImg()[i].getHeight(this) * (current_Player.getSch().getSpeed() / 150)), this); if (timeCounter == 75) { System.out.println("----------------------><---------------------"); if (player_1 .getBounds() .intersects( (int) current_Player.getSch().getEnd_X() - current_Player.getSch().getArImg()[i].getWidth(this) / 2, (int) current_Player.getSch().getEnd_Y() - current_Player.getSch().getArImg()[i].getHeight(this) / 2, (int) (current_Player.getSch().getArImg()[i].getWidth(this) * (current_Player.getSch().getSpeed() / 150)), (int) (current_Player.getSch().getArImg()[i].getHeight(this) * (current_Player.getSch().getSpeed() / 150)))) { player_1.setTp(player_1.getTp() - (int) current_Player.getSch().getSpeed() / 4); System.out.println("----------------------> P1 <---------------------"); } if (player_2 .getBounds() .intersects( (int) current_Player.getSch().getEnd_X() - current_Player.getSch().getArImg()[i].getWidth(this) / 2, (int) current_Player.getSch().getEnd_Y() - current_Player.getSch().getArImg()[i].getHeight(this) / 2, (int) (current_Player.getSch().getArImg()[i].getWidth(this) * (current_Player.getSch().getSpeed() / 150)), (int) (current_Player.getSch().getArImg()[i].getHeight(this) * (current_Player.getSch().getSpeed() / 150)))) { player_2.setTp(player_2.getTp() - (int) current_Player.getSch().getSpeed() / 4); System.out.println("----------------------> P2 <---------------------"); } } } if (timeCounter >= 150) { timeCounter = 0; current_Player.getSch().setIsActive(false); current_Player.getSch().setEnd_X(0); current_Player.getSch().setEnd_Y(0); } if (current_Player.getSch().isIsActive()) timeCounter += 1; System.out.println("timecounter: " + timeCounter); } } if (player_1.getTp() <= 0) b.drawString("SPIELER 2 HAT GEWONNEN !", w / 2, h / 2); if (player_2.getTp() <= 0) b.drawString("SPIELER 1 HAT GEWONNEN !", w / 2, h / 2); current_Player.setStop(false); b.setColor(Color.red); AffineTransform a = new AffineTransform(); a.rotate( current_Player.getDegree(), current_Player.getX() + current_Player.getWidth() / 2, current_Player.getY() + current_Player.getHeight() / 2); ((Graphics2D) pl_b).setTransform(a); pl_b.drawImage( current_Player.getImg(), (int) current_Player.getX(), (int) current_Player.getY(), this); System.out.println( "P1 X:" + (int) current_Player.getX() + " P1 Y:" + (int) current_Player.getY()); System.out.println("P1 W:" + current_Player.getWidth() + " P1 H:" + current_Player.getHeight()); AffineTransform a2 = new AffineTransform(); a2.rotate( other_Player.getDegree(), other_Player.getX() + other_Player.getWidth() / 2, other_Player.getY() + other_Player.getHeight() / 2); ((Graphics2D) pl_c).setTransform(a2); pl_c.drawImage( other_Player.getImg(), (int) other_Player.getX(), (int) other_Player.getY(), this); if (current_Player.isCollision() == true) { current_Player.setStop(true); if (timecount > 10) { b.setColor(Color.WHITE); b.drawString("C O L L I S I O N !", (int) w / 2 - 50, (int) h / 2); timecount--; } else { timecount = 0; current_Player.setBp(0); current_Player.setX(300); current_Player.setY(100); current_Player.getSch().setEnd_X(1); current_Player.getSch().setEnd_Y(1); current_Player.getSch().setStart_X(1); current_Player.getSch().setStart_Y(1); } b.dispose(); } }