Java Game Programming – User Input


Video is ready, Click Here to View ×

In episode 20 of Java Game Programming we expand our player class to allow Keyboard input as well as more precise Mouse input in order to have more control when modifying the game world. By the end of the video we have implemented all of the tools we need in order to utilize a rudimentary level editing system, just without the whole level saving part (patience!).


5 thoughts on “Java Game Programming – User Input

  1. Great Tutorials! Question: "right" won't display in my consol, so the whole while loop isnt working. Not an error, just has no effect.

    if(Keyboard.getEventKey() == Keyboard.KEY_RIGHT && Keyboard.getEventKeyState()){
    I might be missing a import.
    Substituted it this for now:


    But this still makes multiple clicks register.

  2. This guy is definitely not one of those spoon-feeding teachers that you don't learn anything from. I've done so much on my own to my game.

    -Hexagonal Isometric tiles and maps.
    -Intelligent mouse collision detectors that can be used for any polygon.
    -Saving and loading your game
    -Randomly generating a map
    -Filling a map with any of one tile type.

    Please keep it up! This tutorial series taught me how to use constructors and methods properly and expanded what I could do in my game.

  3. Still having the same problem as from the last tutorial. When I click to place a tile, its about 5 or 6 tiles to the left and down of where the actual pointer is.

    Here is the code I have, I'm really not sure why its doing it because it appears to be exactly what you have shown

    public void SetTile() {
            grid.SetTile((int) Math.floor(Mouse.getX() / 64),
                    (int) Math.floor((HEIGHT – Mouse.getY() – 1) / 64), types[index]);

    Thanks again for the great tutorials!

Leave a Reply

Your email address will not be published. Required fields are marked *