How can i remove the ufo when they got hited by the bullet?

edited October 2013 in Questions about Code

i am trying to create a space invader mini game...but i found it hard to remove the ufo when they got hited by the bullet as I am not sure about the code...can anyone here give me a help:P here is my code

int a=0;
int b=0;
int c=0;
int x = 250;
int y = 480;
int bullet_x = 250;
int bullet_y = 480;
PImage bg;
PImage flight;
PImage ufo;
import ddf.minim.*;
AudioPlayer player;
Minim minim;

void setup()
  {
  size (500,500);
  bg=loadImage("space.jpg");
  ufo=loadImage("ufo.png");
  flight=loadImage("flight.png");
   minim = new Minim(this);
  player = minim.loadFile("invaders.mp3",2048);
  player.play();
  player.loop();
  ellipseMode(CENTER);
  rectMode(CENTER);
  smooth();
  }

void draw()
  {
  background(bg);
  bullet_y = bullet_y - 5;
  fill(2,251,242);
  rect(bullet_x, bullet_y, 10, 10);
  image(flight,x-17,445,35,56);
  a=a+2;
  b=b+4;
  c=c+3;
  image(ufo,a,30,40,21);
  image(ufo,b,70,40,21);
  image(ufo,c,110,40,21);
  if(a > width) {
    a = 0;
  }
  if(b > width) {
    b = 0;
  }
  if(c > width) {
    c = 0;
  }
  if (keyPressed == true && key == 'd')
  {
    x = x+3;
  }
  if (keyPressed == true && key == 'a')
  {
    x = x-3;
  }



  }

void keyPressed()
  {

  if (key == ' ')
    {
    bullet_y = y;
    bullet_x = x;
     minim = new Minim(this);
  player = minim.loadFile("gun.mp3",2048);
  player.play();
    }
  }

  void stop()
{
  player.close();
  minim.stop();
  super.stop();
}

Answers

Sign In or Register to comment.