Java Game Development #7 - Keyboard Input

preview_player
Показать описание

In this video we learn how to add keyboard input into our game. If you have any questions then be sure to leave a comment or contact me on twitter; realtutsgml. If you learned something then be sure to leave a like, comment, and favorite.

Have fun learning!

Рекомендации по теме
Комментарии
Автор

After years I have to say:

Thanks man, good tutorial!

staffel
Автор

Bit of an improvement mate from 5 likes. You put in a respectable amount of effort into this series so it was well deserved.

Madgod
Автор

Great tutorial. 
note that in minute 4:30 you use if{}else{} nested statements. It is a good idea inm this case to use switch statement.

That way the processing of keys is more clean, readeable, upgradeable and maintainable

franklyndiaz
Автор

Just wanted to say that I am enjoying and learning a lot from your videos, and I wanted to thank you for all of the work that you put into them. Keep up the great work.

lomani
Автор

Well I am just glad I was able to figure it out.. I tried everything I could think of from printing to the console to see if the key was registering. I adjusted the tick function to see if I missed something with p.setX(p.getX() +5)... but it did feel good to get it working. I even added a stationary enemy until I figure out the right loop to get it to bounce from side to side.

mookeynaz
Автор

at 7:00, if you do what he does, it sets the x and y values to 0 when the key is released, so everytime you release a key, the player moves to 0, 0

konevthebeast
Автор

I saw something, when you pres the key the image moves one step, then stops, after that he starts moving fluidly without stopping

how to solve this problem?, could be used Key binding instead?

comeycallate
Автор

I'm using these tutorials (after going somewhere else for a basic understanding of java) to remake a game i made in game maker! PS if any of my subscribers read this, no, its not towering

illdie
Автор

Why do you create the methods keyPressed and keyReleased in the class Game again? Would it not be better if you just define these methods in the class KeyInput and put a reference of the player in the constructor of KeyInput. Like that: public KeyInput(Game game, Player p). If you do it like that, you do not need to create keyPressed and keyReleased in both classes Game and KeyInput. It think that would be more clean ? Anyways I really like your videos !!

DuyNguyen-bnme
Автор

thanks for the reply, turns out, however, that my problem was that I forgot to put "p." before getX in the right key.

TimothyPorter
Автор

Love your Videos man! Keep it up! Im actully coming from C++ and i like these tutorials. But DAMN im glad that i started out with C++ it makes it so much easier to learn another language :P

dannesjo
Автор

Thanks for the awesome tutorial, now im thinking on how to rotate the plane counterclockwise if we press left and vice versa when i press right. Can you help me ??

Konzz
Автор

hey, i have a problem. Whenever I move right, my character will jump to the left side of the screen and is not able to move any more right. from that location on the left side of the screen, I am able to move up, down and left just fine but when I press right again it jumps to that location. any idea what would cause this?

TimothyPorter
Автор

Player is not should i do all are same code but why?
 Anybody help

msaifulcsse
Автор

I am getting the same thing as you. Everything seems to be okay I even set up a System.out.println to see if the key was being read and it does not appear to be. I assume your problem and mine are the same.

mookeynaz
Автор

Can I implement KeyListener instead of extending KeyAdapter? Will it do the same?

Xceedo
Автор

This series is just to good, thanks dude!

HaraSuke
Автор

Any way to increase the size of the loaded playerimage?

oggelicious
Автор

Instead of typing all these getters/setters yourself, you could right click in the class, go down to 'Source' and then click 'Generate getters and setters ...' . Eclipse makes it a whole lot easier :)

warba
Автор

I have a problem I have done everything exatly right and nothing happens when I hit my arrow keys please help

Funske