This site requires JavaScript, please enable it in your browser!
Greenfoot
Username
Password
Remember Me?
Sign Up, Lost Password
Activity
About
Documentation
Download
Discuss
Scenarios
Discussions
You need to login to take part
Current Discussions
AWESOME 3d tutorial
By wabuilderman, with 1 reply.
Replied to by wabuilderman, over 10 years ago:
scratch that, it doesn't cover everything.. But still, good tutorial.
Hey how can i add 3 background music for may 3 levels.
By TanRanoa, with no replies.
Please Help! :)
Hey I need Help. Im Having a problem to add a background music.
By TanRanoa, with no replies.
THIS IS MY CODES import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class MyWorld extends World { private GreenfootSound bgMusic = new GreenfootSound("All About That Bass"); public void started() { bgMusic.playLoop(); } Counter counter = new Counter(); public MyWorld() { // Create a new world with 600x400 cells with a cell size of 1x1 pixel super(790, 445, 1, false); prepare(); } public Counter getCounter() { return counter; } private void prepare() { addObject(counter, 100, 40); Blue BlueColor = new Blue(); addObject(BlueColor, 50 , 100); Green GreenColor = new Green(); addObject(GreenColor, 50 , 180); Purple PurpleColor = new Purple(); addObject(PurpleColor, 50 , 260); Red RedColor = new Red(); addObject(RedColor, 50 , 340); addObject(counter, 1000, 40); Water WaterColor = new Water(); addObject(WaterColor, 1000 , 100); Land LandColor = new Land(); addObject(LandColor, 900 , 180); Air AirColor = new Air(); addObject(AirColor, 800 , 260); Fire FireColor = new Fire(); addObject(FireColor, 1200 , 340); Tubig TubigColor = new Tubig(); addObject(TubigColor, 1400 , 100); Lupa LupaColor = new Lupa(); addObject(LupaColor, 1300 , 180); Hangin HanginColor = new Hangin(); addObject(HanginColor, 1100 , 260); Apoy ApoyColor = new Apoy(); addObject(ApoyColor, 1500 , 340); Bb BbColor = new Bb(); addObject(BbColor, 1600 , 100); Ll LlColor = new Ll(); addObject(LlColor, 1800 , 180); Aa AaColor = new Aa(); addObject(AaColor, 1700 , 260); Ff FfColor = new Ff(); addObject(FfColor, 1900 , 340); Waterb WaterbColor = new Waterb(); addObject(WaterColor, 2000 , 100); Landl LandlColor = new Landl(); addObject(LandColor, 2100 , 180); Aira AiraColor = new Aira(); addObject(AiraColor, 2300 , 260); Firef FirefColor = new Firef(); addObject(FirefColor, 2200 , 340); Bee BeeColor = new Bee(); addObject(BeeColor, 2500 , 100); Gee GeeColor = new Gee(); addObject(GeeColor, 2700 , 180); Pee PeeColor = new Pee(); addObject(PeeColor, 2600 , 260); Fee FeeColor = new Fee(); addObject(FeeColor, 2800 , 340); Beer BeerColor = new Beer(); addObject(BeerColor, 2900 , 100); Geer GeerColor = new Geer(); addObject(GeerColor, 3100 , 180); Peer PeerColor = new Peer(); addObject(PeerColor, 3000 , 260); Feer FeerColor = new Feer(); addObject(FeerColor, 3200 , 340); Bbb BbbColor = new Bbb(); addObject(BbbColor, 3400 , 100); Ggg GggColor = new Ggg(); addObject(GggColor, 3300 , 180); Ppp PppColor = new Ppp(); addObject(PppColor, 3500 , 260); Fff FffColor = new Fff(); addObject(FffColor, 3600 , 340); Bluer BluerColor = new Bluer(); addObject(BluerColor, 4200 , 100); Greener GreenerColor = new Greener(); addObject(GreenerColor, 4100 , 180); Purpler PurplerColor = new Purpler(); addObject(PurplerColor, 4300 , 260); Reder RederColor = new Reder(); addObject(RederColor, 4400 , 340); Blew BlewColor = new Blew(); addObject(BlewColor, 4600 , 100); Greek GreekColor = new Greek(); addObject(GreekColor, 4800 , 180); Prend PrendColor = new Prend(); addObject(PrendColor, 4700 , 260); Fight FightColor = new Fight(); addObject(FightColor, 4500 , 340); Beee BeeeColor = new Beee(); addObject(BeeeColor, 4900 , 100); Geee GeeeColor = new Geee(); addObject(GeeeColor, 5000 , 180); Peee PeeeColor = new Peee(); addObject(PeeeColor, 5200 , 260); Feee FeeeColor = new Feee(); addObject(FeeeColor, 5100 , 340); } public void stopped() { bgMusic.stop(); } { } }
headache java.lang.NullPointerException
By guntur, with 1 reply.
Replied to by danpost, over 10 years ago:
You cannot execute a method on an object reference that does not contain an object, but contain a 'null' reference. Once you remove 'this' from the world 'getWorld' will return 'null'. Move the 'removeobject(this)' line down past where you use 'getWorld' (before, or after, the 'Greenfoot.stop()' call).
raycasting headache
By wabuilderman, with 1 reply.
Replied to by davmac, over 10 years ago:
So far, the best thing I have that works (though it still doesn't really work) is this: (...) using this, it would determine if one face in a list is closer than another. It would then go about rearranging them using this method.
I think you have one or two conceptual misunderstandings. First, it is not possible to sort a set of faces by "distance to a point" in a way that is useful for rendering (whether it be by raycasting or not); for one thing, you render many points (whatever the dimensions of your screen or viewport are), not just the one, and faces that are closer to o
How to display a level screen in the world and change when actor dies
By cloud41910, with 3 replies.
Last reply by danpost, over 10 years ago:
There is no problem with the naming. The main problem ... well, there are two here. (1) every act cycle you will be creating and adding a new Level object into the world which will most certainly either (a) create lag (b) cause an OutOfMemory error and/or (c) cause a StackOverflow error; and, (2) the moment 'hit' removes the actor from the world, 'world' will be assigned a 'null' value on line 32 and a NullPointerException will occur on line 34 when you try to call methods on 'world'. If you only want to add a new Level object into the world when your player dies, then put the code to a
Jump code..
By JetLennit, with 24 replies.
Last reply by danpost, over 10 years ago:
@ZeroKnightZK, you should start a new discussion thread and post code you have tried.
Need help adding text
By csmith7, with 3 replies.
Last reply by danpost, over 10 years ago:
Like line 5 but with a different text string.
Getting an Error Message When I Kill an Enemy
By Kickero, with 1 reply.
Replied to by danpost, over 10 years ago:
The error occurs when the health of the actor gets to zero. When this happens, your act method is calling 'SirBAlert' which calls 'checkSirB'. Your health values goes to zero or below and the porcubutt is removed from the world. Execution then returns back to the act method, when 'checkAttack' is called. This method can execute fully as written without any problems because nothing in the method requires the actor be in the world (it only deals with fields and keystrokes). Then, finally execution back at the act method calls the method 'move'. The first line in that method (line 54 above
constructor tile in class tile cannot be applied to given types
By jeffca51, with 2 replies.
Last reply by jeffca51, over 10 years ago:
There, we go: the bit of Java I didn't know. Methods have return types, constructors don't. Alright, everything works as expected now. Thank you.
need get a variable from one class to another heres what i got
By Kickero, with 3 replies.
Last reply by Kickero, over 10 years ago:
Thanks!
|| Results for Fall 2014 ||
By NikZ, with 7 replies.
Last reply by NikZ, over 10 years ago:
danpost wrote...
danpost wrote...
NikZ wrote...
Yes, very close. danpost's scenario will be added to challenge winners, correct?
I made a request of it to JetLennit (owner of that collection).
It has now been accepted. (thanx jet)
Cool.
While...Else...?
By EIGNERT, with 9 replies.
Last reply by danpost, over 10 years ago:
It might be best if you show what you are attempting to do by posting the questionable code -- the more you give, the better understanding we would gain context-wise. It would give us a better idea of what might be needed and you may be able to move on more quickly.
Maze levels
By Nokomanida, with 1 reply.
Replied to by danpost, over 10 years ago:
Of course. Do you keep a reference to your player in your world class?
Instanceof issue.
By ajmetal, with 1 reply.
Replied to by danpost, over 10 years ago:
I am sure there is a simpler way. Post your monster class for assistance (use the 'code' link below the reply box to insert code into your post). Anyway, I do not see how 'instanceof' can help if all the monsters are created from the same class.
623
624
625
626
627
628
629
X