This site requires JavaScript, please enable it in your browser!
Greenfoot back
mariq_rasyid29
mariq_rasyid29 wrote ...

2021/5/25

help idk what i must to do

mariq_rasyid29 mariq_rasyid29

2021/5/25

#
This is the eror code form terminal idk what i must to do
java.lang.NullPointerException
	at greenfoot.Actor.<init>(Actor.java:139)
	at HUD.<init>(HUD.java:9)
	at Text.<init>(Text.java:9)
	at TempText.<init>(TempText.java:12)
	at BridgeStoneForest.<init>(BridgeStoneForest.java:128)
	at Playbutton.act(Playbutton.java:22)
	at greenfoot.core.Simulation.actActor(Simulation.java:567)
	at greenfoot.core.Simulation.runOneLoop(Simulation.java:530)
	at greenfoot.core.Simulation.runContent(Simulation.java:193)
	at greenfoot.core.Simulation.run(Simulation.java:183)
here the code at HUD Class
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class HUD here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class HUD extends Actor
{
    /**
     * Act - do whatever the HUD wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // Add your action code here.
    }    
}
here the code at text class code
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Text here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Text extends HUD
{
    /**
     * Act - do whatever the Text wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // Add your action code here.
    }    
}
here the code at Temp Text codes
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class TempText here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class TempText extends Text
{ private int timer;
         public TempText(String text, int showActs)
    {
        timer = showActs;
        setImage(new GreenfootImage(text, 28, Color.BLACK, Color.WHITE));
    }
     
    public void act()
    {
        if (--timer == 0) getWorld().removeObject(this);
    }
}
mariq_rasyid29 mariq_rasyid29

2021/5/25

#
also here at Bridgestoneforest world code
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
 * Write a description of class  BridgeStoneForest here.
 * 
 * @author (Muhamad Ariq Rasyid) 
 * @version (1.0 19 Feb 2021)
 */
public class BridgeStoneForest extends World
{   public GreenfootSound Back= new GreenfootSound("The Wolf Online Simulator Soundtrack Easter Event Castelvenia Netflix.mp3");
    public String[] dialog1 =
        {
            "Hello, My Name is Blizzard Wolf Smith, The Timber Wolf",
            "Welcome in Western Pack Territory.",
            "In the Night many Monster in Ancient Dugeons.",
            "But before that Please to My parents home",
            "to North East from here"
        };

    private int [][] StonesLoc=
        {{ 88 , 578 }, { 90 , 538 }, { 117 , 518 },
            { 160 , 518 }, { 204 , 518 }, { 204 , 518 }, 
            { 234 , 518 }, { 259 , 518 }, { 289 , 520 },
            { 327 , 520 }, { 357 , 521 }, { 387 , 521 },
            { 388 , 543 }, { 390 , 580 }
        };
    private int [][] Pine3Loc=
        {{ 552 , 565 } , { 588 , 564 } , { 108 , 468 } , { 124 , 468 } ,
            { 143 , 469 } , { 160 , 470 } , { 178 , 468 } , { 192 , 469 } ,
            { 207 , 469 } , { 226 , 471 } , { 322 , 470 } , { 268 , 471 } ,
            { 288 , 469 } , { 310 , 471 } , { 351 , 471 } , { 372 , 472 } ,
            { 104 , 21  } , { 67  , 24  } , { 41  , 27  } , { 161 , 21  } ,
            { 133 , 21  } , { 213 , 22  } , { 235 , 22  } , { 259 , 22  },
            { 287 , 21  } , { 310 , 21  } , { 515 , 24  } , { 543 , 24  },        
            { 573 , 24  } , { 604 , 24  } , { 634 , 23  } , { 668 , 26  },
            { 744 , 24  }
        };
    private int[][] Pine2Loc=
        { { 416 , 446 } , { 351 , 8 } , { 479 , 11 } ,
            { 703 ,   7 } , { 781 , 22 }
        };

    int [][]PineLoc=
        {  { 523 , 549 } , { 634 , 547 } , { 770 , 547 } , { 796 , 130 } ,
            { 797 , 153 } , { 795 , 171 } , { 797 , 201 } , { 797 , 229 } ,
            { 799 , 256 } , { 797 , 283 } , { 795 , 311 } , { 793 , 344 } ,
            { 793 , 375 } , { 790 , 421 } , { 791 , 466 } , { 790 , 506 } ,
            { 790 , 545 } , { 129 ,   6 } , {   6 ,  72 } , {  11 ,  36 } ,
            {   4 ,  49 } , {   5 ,  63 } , {   7 ,  91 } , {   7 , 113 } ,
            {  11 , 147 } , {   8 , 181 } , {   7 , 214 } , {   8 , 245 } ,
            {   8 , 283 } , {  89 , 453 }
        };
    /**
     * Constructor for objects of class PlaygameHome.
     * 
     */

    public BridgeStoneForest()
    {    
        // Create a new world with 800x600 cells with a cell size of 1x1 pixels.
        super(800, 600, 1); 
        //Background
        setBackground("corkboard.jpg");
        //backsound
        Back.playLoop();
        /**
         * NPC
         */
        //WolfLink
        WolfLink wolfLink = new WolfLink();
        addObject(wolfLink,419,68);
        //Cerberus
        Cerberus cerberus = new Cerberus();
        addObject(cerberus,704,525);
        //Werewolf
        Werewolf werewolf = new Werewolf();
        addObject(werewolf,33,533);
        //Rayquaza
        Rayquaza rayquaza = new Rayquaza();
        addObject(rayquaza,451,535);

        /**
         * Blizzard
         */
        //Blizzard
        Blizzard blizzard =  new Blizzard();
        addObject(blizzard,291,163);

        /**
         * MapsAttribute
         */
        /**
         * Pines
         */
        //Normal
        addPine3();
        //left
        addPine2();
        //Right
        addPine();
        //River
        River river = new River();
        addObject(river,238,568);

        //Stones
        addStones();
        //Flatfrom
        Flatfrom1 flatfrom1 = new Flatfrom1();
        addObject(flatfrom1,24,582);
        Flatfrom2 flatfrom2 = new Flatfrom2();
        addObject(flatfrom2,452,582);
        Flatfrom3 flatfrom3 = new Flatfrom3();
        addObject(flatfrom3,701,578);
        Flatfrom4 flatfrom4 = new Flatfrom4();
        addObject(flatfrom4,416,21);

        /**
         * Dens
         */
        //Blizzard home
        BlizzardHomes bh = new BlizzardHomes();
        addObject(bh,65,67);
        //Parents Den Den
        ParerentsHomes ph = new ParerentsHomes();
        addObject(ph,764,38);

        //info
        addObject(new TempText("Bridge Stone Forest", 60), 690, 577);
        //WolfSatue
        WolfStatue wolfStatue = new WolfStatue();
        addObject(wolfStatue,426,254);

        //Dialogue
        adddialog();

    }

    public void addStones()
    {for(int i=0; i<StonesLoc.length;i++)
        {Stones st = new Stones();
            addObject(st, StonesLoc[i][0], StonesLoc[i][1]);
        }
    }

    public void addPine3()
    {for (int i=0; i<Pine3Loc.length;i++)
        {Tree3 t3 = new Tree3();
            addObject(t3, Pine3Loc[i][0], Pine3Loc[i][1]);
        }
    }

    public void addPine2()
    {for (int i=0; i<Pine2Loc.length;i++)
        {Tree2 t2 = new Tree2();
            addObject(t2, Pine2Loc[i][0], Pine2Loc[i][1]);
        }
    }

    public void addPine()
    {for (int i=0; i<PineLoc.length;i++)
        {Tree t = new Tree();
            addObject(t, PineLoc[i][0], PineLoc[i][1]);
        }
    }

    public void act()
    {if (!getObjects(Dialogue.class).isEmpty() && "z".equals(Greenfoot.getKey()))
        {
            ((Dialogue)getObjects(Dialogue.class).get(0)).nextText();
        }
    }

    public void adddialog()
    { Dialogue dialogue = new Dialogue(dialog1);
        addObject(dialogue, 397,533);
    }

   
}
mariq_rasyid29 mariq_rasyid29

2021/5/25

#
and PlayButoon Code
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Playbutton here.
 * 
 * @author (Muhamad Ariq Rasyid) 
 * @version (1.1 13 Mar 2021)
 */
public class Playbutton extends Buttons
{
    private GreenfootSound Click= new GreenfootSound("Start.mp3");
    /**
     * Act - do whatever the Playbutton wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {if (getWorld() instanceof MainMenu) 
        {
        if(Greenfoot.mouseClicked(this)) {
          Click.play();
         ((MainMenu)getWorld()).Back.stop();
        {Greenfoot.setWorld(new BridgeStoneForest());
    }    
    
    }
 }
 }
}
danpost danpost

2021/5/25

#
mariq_rasyid29 wrote...
This is the eror code form terminal idk what i must to do << Error Trace Omitted >>
That appears to be a greenfoot bug -- not sure.
You need to login to post a reply.