Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package asteroidgame;
- import blobmx.PolyBlob;
- import blobmx.SandBox;
- import blobmx.SandBoxMode;
- import blobmx.BlobGUI;
- import java.util.Random;
- import java.awt.Dimension;
- public class AsteroidGame implements BlobGUI{
- SandBox sb = new SandBox();
- public static void main(String[] args) {
- AsteroidGame asteroidgame = new AsteroidGame();
- asteroidgame.generate();
- }
- @Override
- public void generate(){
- this.sb.setSandBoxMode(SandBoxMode.FLOW);
- this.sb.setFrameRate(66);
- Dimension dim = sb.getPanelBounds();
- Rocket rocket = new Rocket (dim.width/2, dim.height/2, this.sb);
- sb.addBlob(rocket);
- int counter=1;
- Random random = new Random();
- while (counter < 10){
- int i= -3 + random.nextInt(7);
- if (i == 0)
- continue;
- int j= -3 + random.nextInt(7);
- if (j == 0)
- continue;
- int temp = random.nextInt(2);
- double rot;
- if (temp == 0)
- rot = 0.1;
- else
- rot = -0.1;
- Asteroid asteroid = new Asteroid(i,j,rot);
- sb.addBlob(asteroid);
- counter++;
- }
- sb.init(this);
- }
- public void AsteroidGame(){
- generate();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement