Nice idea, but after having a look at the code, it looks like there's a bug on this line:
count1 = score[place1] + score[place1+2];
(And the equivalent with count2.) After a while left running the scenario, I was proven correct :P
java.lang.ArrayIndexOutOfBoundsException: 800
at Xylophone.act(Xylophone.java:90)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:200)
at greenfoot.core.Simulation.run(Simulation.java:129)
Couple of other points - you do know you can use Greenfoot.getRandomNumber rather than Math.random? It's just simpler and doesn't require all the integer casting. Oh and you could reduce a lot of code duplication by cutting your act method down into a few seperate methods ;)
Thats not a bug, it just runs out of array to use, and so it complains. This is by no means the complete algorithm, i just wanted to get the ball motion correct. Having said that, I know there still is a lot of optimization to be done, especially on the sound playing part (I'm going to have a lot of sounds!). Thanks for the random! I only knew about a different class that you had to import, and i was feeling lazy
Ah fair enough :) The ball motion does work nicely even if the notes appear random! Incidentally, there might be a way round uploading loads of individual sounds, I'll see if I can throw a quick demo together of what I mean and upload it.
Unfortunately, The pop up prompt thing I'm using to input the songs does not allow copying of its displayed messages, so i had to be restricted to the console...
:(
A new version of this scenario was uploaded on Thu Jan 22 21:44:04 UTC 2009
A new version of this scenario was uploaded on Fri Jan 23 00:38:55 UTC 2009
Very great, but it would be nice if the pages would be automatically gone trough, if you play the music, so that you don't have to play every page in single.
I just made a cool song off the top of my head (which I accidentally wrote in 3/4 time somehow), and it wont let me output to console on the website. DX
I should be able to save a song with "getUserInfo()"! Seriously, now I have to re-write the song (albeit a short one) directly onto the the exact same program but in my computer... DX
@ Builderboy:
I recognized, you wrote
new Thread() {
public void run() {
channel[instrument].noteOn(note, volume);
try {
Thread.sleep(0);
}
catch(InterruptedException ex) {}
finally {
channel[instrument].noteOff(note,50);
}
}
}.run();
in the MidiPlayer-class.
May you meant '}.start();' at the end? Because this Thread is a useless created object, isn't it?
2009/1/8
2009/1/8
2009/1/8
2009/1/8
2009/1/10
2009/1/11
2009/1/11
2009/1/12
2009/1/12
2009/1/18
2009/1/18
2009/1/20
2013/7/30
2013/7/31
2013/7/31
2013/7/31
2013/10/9
2013/10/9
2013/10/9