001
08.04.2006, 18:58 Uhr
foufou
|
Code: |
import java.awt.*; import java.awt.event.*;
class weltall extends Panel {
shuttle awing; schussfeld s1; schussfeld s2; kometenfeld k; ufo bad; boolean shuttleexist; boolean ufoexist, nextLevel; boolean gameover =false; Image dbImage; Graphics dbGraphics; Font fontbig = new Font("SansSerif",Font.PLAIN, 24);
public weltall( shuttle awing, schussfeld s1, schussfeld s2, kometenfeld k, ufo bad ) { this.awing = awing; this.s1= s1; this.s2 = s2; this.k = k; this.bad = bad; setBackground(Color.black); addKeyListener(new myKeyListener()); }
public void paint(Graphics g) { if(nextLevel) { g.setFont(fontbig); g.setColor(Color.white); g.drawString("ENTERING NEXT LEVEL", 170, 200); } else { if(shuttleexist) awing.drawMe(g); s1.drawShoots(g); s2.drawShoots(g); if(ufoexist) bad.drawMe(g); k.drawComet(g); } if(gameover) { g.setFont(fontbig); g.setColor(Color.white); g.drawString("GAME OVER !!!", 190, 200); GameOver(false); } } public void GameOver(boolean b) {gameover=b;} public void setUfo(boolean b) { ufoexist = b; } public void setShuttle(boolean b) { shuttleexist = b; } public void setLevel(boolean b) { nextLevel = b; }
public void update(Graphics g) { if (dbImage == null) { dbImage = createImage(this.size().width,this.size().height); dbGraphics = dbImage.getGraphics(); } dbGraphics.setColor(getBackground()); dbGraphics.fillRect(0,0,this.size().width,this.size().height); dbGraphics.setColor(getForeground()); paint(dbGraphics); g.drawImage(dbImage,0,0,this); }
// die Steuerung class myKeyListener extends KeyAdapter { public void keyPressed(KeyEvent e) { int a; a=e.getKeyCode(); if (shuttleexist) { if((a == KeyEvent.VK_LEFT) || (a == KeyEvent.VK_I)) { awing.dreheLinks(); } else if((a == KeyEvent.VK_RIGHT) || (a == KeyEvent.VK_P)) { awing.dreheRechts(); } else if(a == KeyEvent.VK_SPACE) { awing.fireShoot(s1); } else if((a == KeyEvent.VK_UP) || (a == KeyEvent.VK_O)) { awing.flip(); } if(a == KeyEvent.VK_SHIFT) { awing.setShield(true); awing.setRadius(20); } } } public void keyReleased(KeyEvent e) { if(e.getKeyCode() == KeyEvent.VK_SHIFT) { awing.setShield(false); awing.setRadius(10); } } } }
|
mod edit: BENUTZE DIE BOARD TAGS SELBER Dieser Post wurde am 17.04.2006 um 13:36 Uhr von Pablo editiert. |