Share Pastebin
Guest
Public paste!

Spoon

By: a guest | Feb 9th, 2010 | Syntax: None | Size: 0.83 KB | Hits: 31 | Expires: Never
Copy text to clipboard
  1. Alien aliens[];
  2. Player player;
  3.  
  4.  
  5. PImage invader, explode;
  6. void setup() {
  7.   size(SCREENX, SCREENY);
  8.   invader = loadImage ("invader.GIF");
  9.   explode = loadImage ("exploding.GIF");
  10.   aliens = new Alien[10];
  11.   init_aliens(aliens, invader, explode);
  12.   player = new Player(350);
  13.   frameRate = 5;
  14. }
  15.  
  16. void init_aliens(Alien baddies[], PImage okImg, PImage exImg){
  17.   for(int i=0; i<aliens.length; i++){
  18.       baddies[i] = new Alien(i*(okImg.width+GAP), 0, okImg, exImg);
  19.   }
  20. }
  21. void draw(){
  22.   print (player.xposish);
  23.   player.move(mouseX);
  24.   player.draw();
  25.   background(0);
  26.   move_array(aliens);
  27.   draw_array(aliens);
  28. }
  29.  
  30.  
  31. void draw_array(Alien aliens[]){
  32.   for(int i=0; i<aliens.length; i++)  
  33.     aliens[i].draw();
  34. }
  35.  
  36.  
  37. void move_array(Alien aliens[]){
  38.   for(int i=0; i<aliens.length; i++)
  39.     aliens[i].move();
  40. }