SSBB: Hammer Music

Discussion in 'Resources' started by chasechocolate, Mar 19, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    chasechocolate

    So I was fooling around on my piano today and I discovered the keys to play the music that plays when you get a hammer item in Super Smash Bros (Brawl). So... of course... I wanted to be able to play it using the note block sounds. I just created a few methods, one to loop to play the notes so I wouldn't have to copy-and-paste the note-playing code lines and the other to actually play the sound. Here is the code:
    Code:java
    1. //Made it protected because it is an unnecessary method, that is, most likely only used in this class
    2. protected void playNoteSound(Player player, Note note, int times){
    3. for(int i = 0; i < times; i++){
    4. player.playNote(player.getLocation(), Instrument.PIANO, note);
    5. }
    6. }
    7.  
    8. //Actually playing the sound
    9. public void playHammerMusic(Player player){
    10. Note g = new Note(5, Note.Tone.G, false);
    11. Note b = new Note(6, Note.Tone.B, false);
    12. Note d = new Note(6, Note.Tone.D, false);
    13.  
    14. //The music
    15. this.playNoteSound(player, g, 5);
    16. this.playNoteSound(player, b, 1);
    17. this.playNoteSound(player, g, 1);
    18. this.playNoteSound(player, b, 1);
    19. this.playNoteSound(player, g, 1);
    20. this.playNoteSound(player, b, 5);
    21. this.playNoteSound(player, d, 1);
    22. this.playNoteSound(player, b, 1);
    23. this.playNoteSound(player, d, 1);
    24. this.playNoteSound(player, b, 1);
    25.  
    26. //And repeat...
    27. this.playNoteSound(player, g, 5);
    28. this.playNoteSound(player, b, 1);
    29. this.playNoteSound(player, g, 1);
    30. this.playNoteSound(player, b, 1);
    31. this.playNoteSound(player, g, 1);
    32. this.playNoteSound(player, b, 5);
    33. this.playNoteSound(player, d, 1);
    34. this.playNoteSound(player, b, 1);
    35. this.playNoteSound(player, d, 1);
    36. this.playNoteSound(player, b, 1);
    37. }

    I have not actually tested how this will function in-game; it may need to have a few tick delay in between each note playing. If someone is willing to test this and see how it will function, feel free!
     
    xWatermelon likes this.
  2. Offline

    ZeusAllMighty11

    Instead of repeat, why not use a loop and a delayed scheduler? :3

    Thanks, I will try this out
     
  3. Offline

    bobacadodl

    Pretty sure you need delays between each note
     
  4. Offline

    chasechocolate

    Yeah, you probably do. Might add that into the code after a few tests.
     
  5. Offline

    creepers84

    chasechocolate Did you ever work this out. Would be awesome to see what you came up with...
     
  6. Offline

    Plo124

    chasechocolate
    A simple way would be to make a new thread (Async task), and use Thread.sleep() in that.
     
Thread Status:
Not open for further replies.

Share This Page