Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

I'm trying to add sound..

$
0
0
hello everybody,

i'm trying to add sound to my game but it's saying:

Null pointer exception

i don't know what's wrong with it. can someone help me?

thanks in advance.

this is my game:



int knopX = 510;
int knopY = 420;
int breedte = 100;  //beginscherm
int hoogte = 100;
boolean schakel;  
boolean over;

int score =0;
PFont lettertype;

PImage background2;
PImage start;

import ddf.minim.*;

Minim minim;
AudioPlayer player;

buster buster1;
Enemies spook1;
Enemies spook2;
Enemies spook3;
Enemies spook4;
Enemies spook5;
Enemies spook6;
Enemies spook7;

void setup () {
  size(900, 800);
  buster1 = new buster(30, 540, 4);
  spook1 = new Enemies(random(0, width), 0, 3);
  spook1 = new Enemies(random(0, width), 0, 2);
  spook2 = new Enemies(random(0, width), 0, 5);
  spook3 = new Enemies(random(0, width), 0, 2);
  spook4 = new Enemies(random(0, width), 0, 6);
  spook5 = new Enemies(random(0, width), 0, 4);
  spook6 = new Enemies(random(0, width), 0, 6);
  spook7 = new Enemies(random(0, width), 0, 4);
  background2 = loadImage("background4.png");
  start = loadImage("beginscherm.png");
  lettertype = loadFont("AbadiMT-CondensedLight-48.vlw");
  
  player = minim.loadFile("GhostBusters.mp3");
  minim = new Minim("GhostBusters.mp3");
  player.play();

}

void draw() {
  image(start, 0, 0);

  fill(0, 0, 0, 0);
  stroke(0, 0, 0, 0);
  rect(knopX, knopY, breedte, hoogte);
  
  
  
  if (mouseX > knopX && mouseX < knopX + breedte && mouseY > knopY && mouseY < knopY + hoogte) {
    fill(0, 0, 0, 0);
    rect(knopX, knopY, breedte, hoogte); 
    over = true ;
  }

  else { 
    over = false;
  }

  if (schakel == true) {
    image(background2, 0, 0);
    textFont(lettertype,25);
    fill(0,255);
    text(score+" ghosts caught",50,50);


    buster1.tekenBuster();
    buster1.beweegBuster();

    spook1.tekenEnemies();
    spook1.beweegEnemies();
    spook1.checkEnemies();

    spook2.tekenEnemies();
    spook2.beweegEnemies();
    spook2.checkEnemies();

    spook3.tekenEnemies();
    spook3.beweegEnemies();
    spook3.checkEnemies();

    spook4.tekenEnemies();
    spook4.beweegEnemies();
    spook4.checkEnemies();

    spook5.tekenEnemies();
    spook5.beweegEnemies();
    spook5.checkEnemies();
  }
}


void mousePressed() {
  if (over==true) {
    schakel = !schakel;
  }

  if (over==false) {
  }
}

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


Viewing all articles
Browse latest Browse all 1768

Trending Articles