Java Game Programming - User Input

preview_player
Показать описание
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!).

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

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.

christopherk
Автор

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!

Cruel_Moose
Автор

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

comptonparkable
Автор

These tutorials are great, i just wish he spent a little more time explaining exactly what he is doing

porku
join shbcf.ru