I have made a Flappy Bird project for school purposes. I got to the part where the bird goes through the pipes and the score goes up by one. But it doesn't. A terminal windows pops up and it gives me a java lang null pointer exception at line 37 of my world class. Can someone help?
Names of pretty much all the variable, classes, etc are not in english so you might have problems with that. If needed, i can translate them.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | import greenfoot.*; public class background extends World { int razmak_cevi= 100 ; int cevbr= 0 ; int ptbr= 0 ; int score= 0 ; int prva_cev= 230 ; int zmbr= 0 ; skor skorObj= null ; public bg() { super ( 600 , 400 , 1 , false ); setPaintOrder(skor. class ,ptica. class ,zemlja. class ,cev. class ,cevnadole. class ,kraj. class ); ptica pt = new ptica(); addObject(pt, 100 , getHeight()/ 2 - 50 ); zemlja Zemlja = new zemlja(); //Stvori zemlju. addObject(Zemlja, 500 , 375 ); //Dodaj zemlju. skor Skor= new skor(); Skor.postaviskor( 0 ); addObject(Skor ,getWidth()/ 2 ,getHeight()/ 2 - 100 ); } public void act() { cevbr++; if (cevbr % 100 == 0 ) { stvoricev(); } if (cevbr >= prva_cev) { if (ptbr % 100 == 0 ) { score++; skorObj.postaviskor(score); //It shows me the null pointer at this line. Greenfoot.playSound( "sfxpoint.mp3" ); } ptbr++; } zmbr++; if (zmbr % 100 == 0 ) { stvorizemlju(); } } private void stvoricev() { cevnadole Cevnd = new cevnadole(); cev Cev = new cev(); GreenfootImage image = Cevnd.getImage(); addObject(Cev,getWidth(),getHeight()/ 2 + image.getHeight()- Greenfoot.getRandomNumber( 200 )); addObject(Cevnd,getWidth(),Cev.getY() - image.getHeight() - razmak_cevi); } private void stvorizemlju() { zemlja Zemlja = new zemlja(); addObject(Zemlja, 500 , 375 ); } } |