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

2021/12/15

Greenfoot.playSound("FUEL.mp3"); not working

1
2
sashvanth sashvanth

2021/12/15

#
sound is there in sounds folder but playing repeatedly while I click run without doing anything
danpost danpost

2021/12/15

#
sashvanth wrote...
sound is there in sounds folder but playing repeatedly while I click run without doing anything
Show ALL methods and field that deal with the sound and indicate class/classes (if not obvious).
sashvanth sashvanth

2021/12/16

#
thanks
sashvanth sashvanth

2021/12/16

#
ok
sashvanth sashvanth

2021/12/16

#
import greenfoot.*; /** * Write a description of class Car3 here. * * @author (your name) * @version (a version number or a date) */ public class Car3 extends Animal { /** * Act - do whatever the Car3 wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { KeyPress(); consumeFuel(); hitcar(); } void KeyPress() { if(Greenfoot.isKeyDown("left")) { move(-4); } if(Greenfoot.isKeyDown("right")) { move(4); } if(Greenfoot.isKeyDown("up")) { turn(4); } if(Greenfoot.isKeyDown("down")) { turn(-4); } } void consumeFuel() { if(canSee(Fuel.class)); { eat(Fuel.class); } } void hitcar() { if(canSee(Dot.class)) { eat(Dot.class); Greenfoot.playSound("Blast.mp3"); Greenfoot.stop(); } }
sashvanth sashvanth

2021/12/16

#
code for red dot public void act() { hitcar(); } void hitcar() { if(canSee(Car3.class)) { eat(Car3.class); Greenfoot.playSound("Blast.mp3"); Greenfoot.stop(); }
sashvanth sashvanth

2021/12/16

#
code for other vehicels move(4); hitcar(); if(isAtEdge()) { turn(45); } } void hitcar() { if(canSee(Car3.class)) { eat(Car3.class); Greenfoot.playSound("Blast.mp3"); Greenfoot.stop(); }
danpost danpost

2021/12/16

#
sashvanth wrote...
ok << Code Omitted >> code for red dot << Code Omitted >> code for other vehicels << Code Omitted >>
Nowhere in your given codes do I see anything for the "FUELmp3" sound file. Did I overlook it?
sashvanth sashvanth

2021/12/16

#
oh sorry one minute
sashvanth sashvanth

2021/12/16

#
code for car { KeyPress(); consumeFuel(); hitcar(); } void KeyPress() { if(Greenfoot.isKeyDown("left")) { move(-4); } if(Greenfoot.isKeyDown("right")) { move(4); } if(Greenfoot.isKeyDown("up")) { turn(4); } if(Greenfoot.isKeyDown("down")) { turn(-4); } } void consumeFuel() { if(canSee(Fuel.class)); { eat(Fuel.class); Greenfoot.playSound("FUEL.mp3"); } } void hitcar() { if(canSee(Dot.class)) { eat(Dot.class); Greenfoot.playSound("Blast.mp3"); Greenfoot.stop(); } } }
danpost danpost

2021/12/16

#
Show codes where you add Fuel actors into the world. From what I can tell so far, only by adding an abundance of them would cause the sound to play repeatedly.
sashvanth sashvanth

2021/12/17

#
import greenfoot.*; /** * Write a description of class Fuel here. * * @author (your name) * @version (a version number or a date) */ public class Fuel extends Animal { /** * Act - do whatever the Fuel 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. } } this is the code of the fuel which it is eating and no other actor can catch it
sashvanth sashvanth

2021/12/17

#
thanks
danpost danpost

2021/12/17

#
sashvanth wrote...
<< Code Omitted >> this is the code of the fuel which it is eating and no other actor can catch it
That is not where you add Fuel actors into the world.
danpost wrote...
Show codes where you add Fuel actors into the world.
The appropriate codes would contain things like addObject and new Fuel().
sashvanth sashvanth

2021/12/17

#
do you mean this BALL ball = new BALL(); addObject(ball, 68, 38); BALL ball2 = new BALL(); addObject(ball2, 103, 47); removeObject(ball2); BALL ball3 = new BALL(); addObject(ball3, 75, 68); ball3.setLocation(67, 59); BALL ball4 = new BALL(); addObject(ball4, 71, 86); ball4.setLocation(66, 78); Car2 car2 = new Car2(); addObject(car2, 248, 109); Car1 car1 = new Car1(); addObject(car1, 105, 192); Car3 car3 = new Car3(); addObject(car3, 368, 425); Aeroplane aeroplane = new Aeroplane(); addObject(aeroplane, 623, 170); Ambulance ambulance = new Ambulance(); addObject(ambulance, 498, 587); SCRT scrt = new SCRT(); addObject(scrt, 1920, 1701); Dot dot = new Dot(); addObject(dot, 1460, 361); Dot dot2 = new Dot(); addObject(dot2, 1411, 568); Dot dot3 = new Dot(); addObject(dot3, 425, 437); Dot dot4 = new Dot(); addObject(dot4, 261, 244); Dot dot5 = new Dot(); addObject(dot5, 986, 111); Dot dot6 = new Dot(); addObject(dot6, 1360, 659); Dot dot7 = new Dot(); addObject(dot7, 877, 452); Dot dot8 = new Dot(); addObject(dot8, 308, 762); Dot dot9 = new Dot(); addObject(dot9, 1209, 205); Dot dot10 = new Dot(); addObject(dot10, 1768, 438); Dot dot11 = new Dot(); addObject(dot11, 1569, 647); Dot dot12 = new Dot(); addObject(dot12, 1710, 80); Dot dot13 = new Dot(); addObject(dot13, 1609, 129); Car2 car22 = new Car2(); addObject(car22, 1694, 176); Car2 car23 = new Car2(); addObject(car23, 458, 439); car23.setLocation(447, 428); car23.setLocation(442, 436); car23.setLocation(446, 435); car23.setLocation(711, 356); Car2 car24 = new Car2(); addObject(car24, 824, 178); Car2 car25 = new Car2(); addObject(car25, 1416, 746); Car1 car12 = new Car1(); addObject(car12, 916, 446); Car1 car13 = new Car1(); addObject(car13, 1755, 455); Dot dot14 = new Dot(); addObject(dot14, 1064, 822); Dot dot15 = new Dot(); addObject(dot15, 1177, 912); Dot dot16 = new Dot(); addObject(dot16, 1704, 1071); Dot dot17 = new Dot(); addObject(dot17, 1661, 871); Dot dot18 = new Dot(); addObject(dot18, 1405, 850); Dot dot19 = new Dot(); addObject(dot19, 576, 978); Dot dot20 = new Dot(); addObject(dot20, 972, 896); Dot dot21 = new Dot(); addObject(dot21, 1362, 1243); Dot dot22 = new Dot(); addObject(dot22, 1517, 991); Dot dot23 = new Dot(); addObject(dot23, 711, 760); Dot dot24 = new Dot(); addObject(dot24, 1271, 1539); Dot dot25 = new Dot(); addObject(dot25, 508, 1321); Dot dot26 = new Dot(); addObject(dot26, 446, 1610); Dot dot27 = new Dot(); addObject(dot27, 785, 1277);
There are more replies on the next page.
1
2