Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. package asteroidgame;
  2.  
  3. import blobmx.PolyBlob;
  4. import blobmx.SandBox;
  5. import blobmx.SandBoxMode;
  6. import blobmx.BlobGUI;
  7. import java.util.Random;
  8. import java.awt.Dimension;
  9.  
  10.  
  11. public class AsteroidGame implements BlobGUI{
  12. SandBox sb = new SandBox();
  13.  
  14. public static void main(String[] args) {
  15. AsteroidGame asteroidgame = new AsteroidGame();
  16. asteroidgame.generate();
  17. }
  18.  
  19. @Override
  20. public void generate(){
  21. this.sb.setSandBoxMode(SandBoxMode.FLOW);
  22. this.sb.setFrameRate(66);
  23. Dimension dim = sb.getPanelBounds();
  24. Rocket rocket = new Rocket (dim.width/2, dim.height/2, this.sb);
  25. sb.addBlob(rocket);
  26. int counter=1;
  27. Random random = new Random();
  28. while (counter < 10){
  29. int i= -3 + random.nextInt(7);
  30. if (i == 0)
  31. continue;
  32. int j= -3 + random.nextInt(7);
  33. if (j == 0)
  34. continue;
  35. int temp = random.nextInt(2);
  36. double rot;
  37. if (temp == 0)
  38. rot = 0.1;
  39. else
  40. rot = -0.1;
  41. Asteroid asteroid = new Asteroid(i,j,rot);
  42. sb.addBlob(asteroid);
  43. counter++;
  44. }
  45.  
  46. sb.init(this);
  47. }
  48.  
  49. public void AsteroidGame(){
  50. generate();
  51.  
  52.  
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement