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
Wie lasse ich meine Hinhtergrundmusik stoppen von Level zu Leve
By helpmeplease, with no replies.
public class Level1 extends World { Pou1 pou1; Boden1 boden1; GreenfootSound backgroundMusic = new GreenfootSound("hintergrundmusik.wav"); // erstellt neue hinterg int zaehler = 0; double p = 0.01; public static final GreenfootSound Level1 = new GreenfootSound("hintergrundmusik.wav"), Level2 = new GreenfootSound("hintergrundmusik.wav"), Level3 = new GreenfootSound("hintergrundmusik.wav"); /* * Erzeugt die Welt, färbt den Hintergrund und * platziert ein Pou-Objekt unten in die Mitte. */ public Level1() { super(800, 600, 1); /* erzeugt den Boden am unteren Rand der Welt */ boden1 = new Boden1(); int boden1Hoehe = boden1.getImage().getHeight(); addObject(boden1, 400, 600 - boden1Hoehe/2); /* erzeugt Pou und platziert ihn mittig oberhalb des Bodens */ pou1 = new Pou1(); int pou1Hoehe = pou1.getImage().getHeight(); addObject(pou1, 400, 620 - boden1Hoehe - pou1Hoehe/2); } /* * Wenn man das Spiel startet setzt es die hintergrundmusik auf 50. */ public void started() { backgroundMusic.setVolume(50); //change bg to what you declared the file as } /* * Setzt die Hintergrundmusik auf 0 wenn man auf stopp drückt. */ public void stopped() { backgroundMusic.setVolume(0); } // erzeugt mit der Wahrscheinlichkeit 0,01 ein Essen-Objekt public void act() { erzeugeMitWahrscheinlichkeit(p, new Pizza1()); erzeugeMitWahrscheinlichkeit(p, new Pommes1()); erzeugeMitWahrscheinlichkeit(p, new Schuh1()); erzeugeMitWahrscheinlichkeit(p, new Stein1()); erzeugeMitWahrscheinlichkeit(0.001, new Hamster()); backgroundMusic.playLoop(); //spielt die Hintergrundmusik in dauerschleife ab. } /* * Erzeugt mit Wahrscheinlichkeit p (zwischen 0 und 1) den angegebenen Akteur. */ void erzeugeMitWahrscheinlichkeit(double p, Actor akteur) { double zufallszahl = Math.random(); if (zufallszahl <= p) { platziereZufaellig(akteur); } } /* * Platziert das Objekt gegenstand an zufälliger Stelle am oberen Rand der Welt. */ void platziereZufaellig(Actor gegenstand) { int x = 50 + Greenfoot.getRandomNumber(700); // zwischen 50 und 749 int y = Greenfoot.getRandomNumber(50); // zwischen 0 und 49 addObject(gegenstand, x, y); // platziert das Objekt gegenstand an der Stelle (x|y) } } Leider weiß ich nicht warum die musik bei level 2 noch bleibt
these should now become faster and more
By helpmeplease, with 6 replies.
Last reply by danpost, almost 3 years ago:
helpmeplease wrote...
I dont understand how this could help me to get my objects that fly from the top to go faster and more as time goes by
With a field like: <Code Omitted>in your world class to count act steps (frames), you could use in your world class:
Objekte sollen mit der zeit schneller und mehr runterfallen
By helpmeplease, with 8 replies.
Last reply by helpmeplease, almost 3 years ago:
dankeschön und wie mach ich das jetzt mit der fallgeschwindigkeit
Having a list with multiple actors
By FALAFFI, with 3 replies.
Last reply by danpost, almost 3 years ago:
FALAFFI wrote...
thank you but it dosnt work and says "incompatible types: java.util.List<Gegner5> cannot be converted to java.util.List <greenfoot.Actor>
Sorry. Try this for line 2: <Code Omitted>
Help needed car simulator
By Luisam21, with 2 replies.
Last reply by Luisam21, almost 3 years ago:
danpost wrote...
Luisam21 wrote...
Hello, can someone help me? I am programming a simple car simulator and want the user to put in the destination and depending on where the destination is I want a object (little flag) to appear on The map but I doesn’t appear,’. ( Destination is the class of the flag) << Code Omitted >>
The input value might be the same as the literal string given; however, it is not the same object (two different strings containing similar character string sets). To compare the two, use: <Code Omitted>
Thank you so much! It
cant jump while holding two buttons
By Mauckenweg, with 2 replies.
Last reply by danpost, almost 3 years ago:
Mauckenweg wrote...
In my jumpnrun you can use a/d to move and m to sprint. this works fine but i cant jump (space) while sprinting. is it possible to fix this?
It is not possible to jump at all without any code for jumping.
Issues with transfering values of counters
By Kolala, with 16 replies.
Last reply by danpost, almost 3 years ago:
Kolala wrote...
Is there a way tho how I can change the counters image depending on the world?
It might be best to have the
Menu
world change the
Counter
object image explicitly.
Question about Minesweeper
By katenech, with 4 replies.
Last reply by katenech, almost 3 years ago:
" is not good programming" - I agree with you :) It was... for simplicity)) Thank you for explanation
I'm having trouble with using two separate counters.
By Wish10940, with 5 replies.
Last reply by danpost, almost 3 years ago:
Wish10940 wrote...
I've got this error after touching the hive << Error Trace Omitted >> it says it's a problem with the line bg.getPollen().stored += bg.getCounter().pollen;
Either the bee is being removed from the world before the
act
method calls this
empty
method or one of your world methods (
getPollen
or
getCounter
) is not returning a counter object.
Delay a method on a single actor
By FALAFFI, with 2 replies.
Last reply by FALAFFI, almost 3 years ago:
thank you
My hp isn't decreasing in subsequent order ;-;
By Bee, with 4 replies.
Last reply by Bee, almost 3 years ago:
Thank you so much!
How do i stop my Mario from jumping to high?
By Ima_pan_cake, with 1 reply.
Replied to by danpost, almost 3 years ago:
Ima_pan_cake wrote...
<< Code Omitted >> It does work when you press space to jump but when you hold space he wont stop until you let go. How do i stop this?
You need to add another condition to jump -- mainly, is the actor standing on the ground (or on top of an object). Easiest way to check this is to apply gravity and fall first; then, check for obstacles. If the vertical speed is positive and an obstacle is found, than the on ground state is met and you can then check for the jump key. My
Jump and Run Demo w/Moving Platform
i
Image doesn't switch
By Hitsheep, with 2 replies.
Last reply by Hitsheep, almost 3 years ago:
danpost wrote...
Hitsheep wrote...
I'm trying to make a bar that switches to 3 other images as time goes while the button C is held down. However, the image doesn't switch. Can someone explain what went wrong? << Code Omitted >>
Using a
SimpleTimer
is making things more difficult than they need to be. You can just count act steps to time the
fishingBar
:
Unable to add object to world
By Hitsheep, with 2 replies.
Last reply by Hitsheep, almost 3 years ago:
danpost wrote...
Hitsheep wrote...
Can someone explain why the class Rod is unable to add the object fishingBar into the World? << Code Omitted >>
Sure. Line 12 declares a field (instance variable member) named
curWorld
, which is assigned an initial value by calling the
getWorld
method. Problem is that this assignment is done before the
Rod
actor is placed into a world, meaning the field is assigned a
null
value (that is, no
World
object is assigned to the field). There seems to be no logic to your codes, on a whole. Most of the fields are not use
ice attack
By Magzlum, with 12 replies.
Last reply by danpost, almost 3 years ago:
Magzlum wrote...
https://www.greenfoot.org/scenarios/31564 this is my game in case you didnt understand what it looked like, and what i have so pls give me some things i can put in my game and a better ice code
Cannot better codes unseen. It would help if you uploaded your scenario again (update it), but with the
Publish source code
check box checked.
20
21
22
23
24
25
26
X