Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Bullet.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. Copyright (c) Xerox Corporation 1998-2002. All rights reserved.
  3. Use and copying of this software and preparation of derivative works based
  4. upon this software are permitted. Any distribution of this software or
  5. derivative works must comply with all applicable United States export control
  6. laws.
  7. This software is made available AS IS, and Xerox Corporation makes no warranty
  8. about the software, its performance or its conformity to any specification.
  9. |<--- this code is formatted to fit into 80 columns --->|
  10. |<--- this code is formatted to fit into 80 columns --->|
  11. |<--- this code is formatted to fit into 80 columns --->|
  12. Bullet.java
  13. Part of the Spacewar game.
  14. */
  15. package spacewar;
  16. class Bullet extends SpaceObject {
  17. static private final int SIZE = 3; //Can't be changed for now!!!
  18. static private int LIFETIME = 50;
  19. private int lifeLeft;
  20. Bullet (Game theGame, double xP, double yP, double xV, double yV) {
  21. super(theGame, xP, yP, xV, yV);
  22. lifeLeft = LIFETIME;
  23. }
  24. int getSize() { return SIZE; }
  25. void handleCollision(SpaceObject obj) {
  26. die();
  27. }
  28. void clockTick() {
  29. if (--lifeLeft == 0)
  30. die();
  31. super.clockTick();
  32. }
  33. }