#Need help to play .midi files in my java hangman game

1 messages · Page 1 of 1 (latest)

north violet
#
  • Photo nr. 1 is from our last assignment, where we made Tetris. The "TetrisSong.java" class is written entirely by our professors and was/is working perfectly.
  • Photo nr 2: I´ve tried to copy and modify the "TetrisSong.java" class to fit my HANGMAN game, but SOMETHING isn´t working.
  • Photo nr 3: Same problem as Photo nr 2.
  • Photo nr 4: The controller for my HANGMAN game; which is working (as far as I can tell) identically to the controller in my Tetris game (when it comes to playing these .midi files).

Please help; this is driving me crazy!

south gobletBOT
#

<@&987246399047479336> please have a look, thanks.

south gobletBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

onyx bison
#

what's the actual error its giving ?

#

and the last shot is using the wrong variable names

#

u got a class called Hang...Drums with a variable drumtrack, yet your calling this.hangmanM instead of drumtrack

#

same with the second red

#

3th and 4th will most likey be not-initialized

north violet
#

I figurde it out, I think

#

some naming errors among other stuff

#

But now my programme in general; which ran fine before I started adding the .midi files, isn´t running

#

it´s giving a huge list of alleged errors; even though I can´t see what those errors are supposed to be

#

for example line 22 here:
I can´t see whats wrong?

onyx bison
#

1st one seems to indicate the file does not exist. Tried printing that it can be found ?

#

( as your in vcs is not easy to debug )

north violet
#

I haven´t touched or made that Reader class

#

it was already in the repo when we we´re handed our assignments

onyx bison
#

that's not the error its saying 😉

north violet
#

oh

#

🥶

onyx bison
#

its giving a NPE

#

most likely its having troubles locating the file it's been given so it goes ' boom'

north violet
#

okok

#

do you think that the error is due to there being 2 new files (the 2 midi files) in the RESOURCES folder?

onyx bison
#

can u show a shot ?

north violet
#

wheras earlier, when the program was running nicely, there was only 1 file in the RESOURCES folder?

north violet
onyx bison
#

the resource folder

#

it shoud'nt matter how many files are in there

north violet
#

deathPiss2.png == pixelated pud of pee when game over is reached and the character is dead..... stupid; I know. Just ignore it

#

lol

onyx bison
#

name seems to be correct

#

what's on fileprocessor line 18 ?

north violet
#

a "group leader" from Uni is trying to help me now

#

tbh I think he´s not giving the right advice

#

line 18 in FileProcessor USED TO BE THIS:

#

InputStream in = getClass().getResourceAsStream(filename);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));

#

so line 18 and 19

#

now its this (which he told me to add)

onyx bison
#

that seems weird

#

new FileReader would make more sense

north violet
#

yes, AND IT WORKED EARLIER

#

ONLY changes made are:

  • added 2 x .midi files to RESOURCES folder
  • Created 2 new classes to process/read these .midi files
  • Added field variabeles + constructor info + initialized stuff needed to run the music from the .midi files
#

I don´t for the life of me understand how that effects a method that is UNTOUCHED in the midi file process, whose only task is to read a .txt file

onyx bison
#

what happens when u start it in debug mode ?

#

( and place a break point on that line 18 ( or whatever it is now )

north violet
#

figured it out!

#

the change this uni dude suggested did in fact work; i just had a typo in there

#

still dont see WHY it was necessary to change the file reader method; seeing that it worked fine before I added the midi files

#

but now my fucking midi files arent playing, haha

#

gotta love programming!!