Class engine.generator.interface.PlayerMouse
Handles player default mouse actions Defines some methods to help use the mouse in an uniform way in all modules
Methods
engine.generator.interface.PlayerMouse:mouseMove (tmx, tmy, spotHostiles, astar_check, force_move)
Runs to the clicked mouse spot
if no monsters in sight it will try to make an A* path, if it fails it will do a direct path
if there are monsters in sight it will move one stop in the direct path direction
this method requires to use PlayerRun interface
engine.generator.interface.PlayerMouse:mouseScrollMap (map, xrel, yrel)
Handles mouse scrolling the map
engine.generator.interface.PlayerMouse:mouseHandleDefault (key, allow_move, button, mx, my, xrel, yrel, event)
Handles global mouse event This will handle events like this: Left click: player mouse movement Shift + left click: map scroll Any other click: pass on the click as a key event, to allow actions to be bound to the mouse
Methods
- engine.generator.interface.PlayerMouse:mouseMove (tmx, tmy, spotHostiles, astar_check, force_move)
-
Runs to the clicked mouse spot
if no monsters in sight it will try to make an A* path, if it fails it will do a direct path
if there are monsters in sight it will move one stop in the direct path direction
this method requires to use PlayerRun interfaceParameters:
- tmx the coords clicked
- tmy the coords clicked
- spotHostiles a function taking only the player as a parameter that must return true if hostiles are in sight
- astar_check nil or a function to check each tile on the astar path for passability
- force_move force movement even if mouse_move is disabled
- engine.generator.interface.PlayerMouse:mouseScrollMap (map, xrel, yrel)
-
Handles mouse scrolling the map
Parameters:
- map the Map to scroll
- xrel the x movement velocity, gotten from a mouse event
- yrel the y movement velocity, gotten from a mouse event
- engine.generator.interface.PlayerMouse:mouseHandleDefault (key, allow_move, button, mx, my, xrel, yrel, event)
-
Handles global mouse event
This will handle events like this:
Left click: player mouse movement
Shift + left click: map scroll
Any other click: pass on the click as a key event, to allow actions to be bound to the mouse
Parameters:
- key the Key object to which to pass the event if not treated, this should be your game default key handler probably
- allow_move true if this will allow player movement (you should use it to check that you are not in targetting mode)
- button the mouse button that was pressed
- mx absolute x
- my absolute y
- xrel relative x
- yrel relative y
- event click event