TeamSweepy / Greywater

Repo for Greywater Isometric RPG
2 stars 0 forks source link

InputHandling #5

Closed Jeremy-Barnes closed 10 years ago

Jeremy-Barnes commented 10 years ago

Set up input handler that works for player input, menu navigation, and inventory interaction

ZigaByte commented 10 years ago

I set up listeners for input. Separated the GUI input and Game input. They both extend InputHandler that has been changed.

The methods and variables are static, since there will only be 1 instance of all the inputs.

Missing stuff: KEYBOARD INPUT, GUI INTERSECTION.

Jeremy-Barnes commented 10 years ago

It occurs to me now - do we need two classes? Can we just use one InputHandler class and direct its callbacks to either player or GUI based on whether or not the cursor is on top of the GUI?

ZigaByte commented 10 years ago

We could. I find it simpler this way though, it also looks cleaner

Jeremy-Barnes commented 10 years ago

Fine by me. Whats the plan to determine which Input Event to accept?

ZigaByte commented 10 years ago

The InputGUI determains if the event gets accepted by the GUI. It will check if the pointer intersected any off the GUI's collision boxes.

ZigaByte commented 10 years ago

Added the GUI collison boxes, so that the input does not get passed to Game if it intersects the GUI. Input is mostly done.

Jeremy-Barnes commented 10 years ago

Hey, I'm not going to make this change because I don't want to make any big changes on a system you're working on, but would you try this and see how it works:

On the Buttons and GUIComponents and stuff, you shouldn't need to calculate the ratio at all. If you size everything as if it is 1600x900 you can use Camera.getDefault().unproject() to convert user screen coordinates into game screen coordinates.

LibGDX does all the scaling automatically and so its a lot more precise to use their built in methods than recalculate everything ourselves. Also, unproject is a matrix based system, which is generally way faster than floating-point multiplication.

If you look into the InputGame class you can see an example of how the unprojecting points works.

if you can make that work in the InputGUI, please do. If its impossible for some reason, no big deal.

Jeremy-Barnes commented 10 years ago

Actually, here - I made this to explain unproject and why its so good.

http://i.imgur.com/cO67hd5.png

So if you use unproject, you don't have to scale up your GUI hitboxes, they can all be just the actual size of the GUI and unprojecting the mouse coordinates will do all the hard work.