Re: Java and walking in the game.

2019-11-30 Thread AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector


  


Re: Java and walking in the game.

Thanks Kae_Jones. When I say it doesn't work, what happens is that when the right arrow is released, the program continues to play the sound of the steps for quite a while, at least 30 seconds after I release the button. I would like instead when the key is released the sound stops, as happens normally.@ashleygrobler04, I've tried your way, but the program doesn't compile, because if I put the try.. catch outside of a method it gives error.

URL: https://forum.audiogames.net/post/481432/#p481432




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Java and walking in the game.

2019-11-30 Thread AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector


  


Re: Java and walking in the game.

Thanks Kae_Jones. When I say it doesn't work, what happens is that when the right arrow is released, the program continues to play the sound of the steps for quite a while, at least 30 seconds after I release the button. I would like instead when the key is released the sound stops, as happens normally.

URL: https://forum.audiogames.net/post/481432/#p481432




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Java and walking in the game.

2019-11-29 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Java and walking in the game.

When you say it doesn't work, what specifically is happening?The methods you gave seem as though they should work[1], with some caveats. First, I'm not sure that keyReleased would fire during a Thread.sleep. Second, what causes the action to repeat while the key is down? Are you relying on it constantly firing, or are you using a timer that repeats the walking bit, but with  if(activate) instead?[1] If you're using Thread.sleep, it should be while nothing at all should be happening during the sleep time. For an example where nothing happens without user input, it's not too bad, but when you try something that is not turn-based, it will be a problem. So yes, it's much better to use timers, even though that means more work just to get walking working.

URL: https://forum.audiogames.net/post/481351/#p481351




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Java and walking in the game.

2019-11-29 Thread AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector


  


Re: Java and walking in the game.

Thanks a lot for your replies. I will try both methods and see which works better.Thanks,Ambro

URL: https://forum.audiogames.net/post/481311/#p481311




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Java and walking in the game.

2019-11-28 Thread AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector


  


Re: Java and walking in the game.

Try not to put the sleep function in your walking event while checking the arrow keys. try rather putting the sleep method there before checking your keys.

URL: https://forum.audiogames.net/post/480833/#p480833




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Java and walking in the game.

2019-11-28 Thread AudioGames . net Forum — Developers room : rkruger via Audiogames-reflector


  


Re: Java and walking in the game.

Hi,I see there's no replies yet, so in case you're still stuck with this:Noting your Thread.sleep method in the keyPressed event handler, I assume you want the walking action to be fired every second. However, it's generally unadvisable to have blocking operations in your event handling code. What I would suggest is to have a timer, or another thread, to perform your walking actions, and have your keyPressed and keyReleased events only set boolians (or enums) to specify when walking should acur.

URL: https://forum.audiogames.net/post/480824/#p480824




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Java and walking in the game.

2019-11-25 Thread AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector


  


Java and walking in the game.

Hello. This post is a question for everyone who knows Java.I want to tell you, about the game I sent you, that I discovered why sometimes it gave problems on some configurations. In practice it conflicted if a user had another version of Java. I was able to solve it by telling it to use only the Java version in the Jre folder. Soon I will send that game together with other games like the game of goose, monopoly, etc.I'd like to ask you a question. I'm trying to write a game where a character walks on a map, but I can't figure out how to set it. I set a function that says: when the right arrow is pressed and if activate == true, play the sound of the steps. Then I tell him that when the right arrow is released make activate = false . However it does not seem to work. Can someone help me? I know that Kae_Jones has a lot of experience in this. I'll copy a few lines of the code I wrote to you.public boolean activate= true;    public void keyReleased(KeyEvent ev) {       if (ev.getKeyCode() == KeyEvent.VK_RIGHT ) {activate=false;}     if (ev.getKeyCode() == KeyEvent.VK_LEFT ) {activate= false;}}    public void keyPressed(KeyEvent evt) {          Sound footsteps1 = TinySound.loadSound("/suoni/sound81.wav");     if (evt.getKeyCode() == KeyEvent.VK_RIGHT) {if (activate == true){             footsteps1.play();activate=false;try{    Thread.sleep(1000);}catch(InterruptedException ex){    Thread.currentThread().interrupt();}activate = true;

URL: https://forum.audiogames.net/post/479996/#p479996




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector