Java Game Programming – User Input

Java

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!).

Subscribe: http://bit.ly/1xbtb2h
Facebook: http://on.fb.me/1uLuDum
Twitter: http://bit.ly/Z2D5aE

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.

    while(Keyboard.next()){
    if(Keyboard.getEventKey() == Keyboard.KEY_RIGHT && Keyboard.getEventKeyState()){
    System.out.print("right");
    MoveIndex();
    }
    }
    I might be missing a import.
    Substituted it this for now:

    if(Mouse.isButtonDown(1)){
    System.out.println("right");
    MoveIndex();
    }

    But this still makes multiple clicks register.
    Thanks

  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.
    -Buttons
    -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 *