Sometimes - when developing games with AI - you want the AI-agent to move the mouse on its own (maybe in board-games like chess,tic-tac-toe,etc where such actions adds to the illusion that another player is playing with the user so-to-speak). You can achieve that by using love.mouse:setPosition but the problem is that it would appear very fake because the cursor is not moving to a position rather jumping to a position. So would it not be nice if you had a framework whose sole purpose-in-life was to achieve that functionality in LÖVE2D allowing you to make the mouse follow to a particular position with other features such as changing the speed at which mouse follows a position or automatically clicking mouse when the cursor has reached the position, etc.
This post only looks at some basic usage of autoCursor
For full documentation and usage refer to
https://github.com/YoungNeer/lovelib/tr ... autocursor
Code: Select all
acursor = require 'autoCursor'
function love.load()
acursor.setDestination(200,200)
--so here the destination point is (200,200)
end
function love.update(dt)
acursor.update()
end
Note that the mouse cursor is moving from the source point [default (0,0)] to destination point [here (200,200)] and the speed is set by default - 1 pixel/frame. You can change the speed to custom value in love.load (or other function) function like this-
Code: Select all
acursor.setSpeed(5,5)
Code: Select all
acursor.clickOnReachingDest()
Code: Select all
acursor.setCODTime(0.5)
Code: Select all
acursor.enableDragging()
All you have to do is make a table in a specific format (look at github link to know more) for ex-
Code: Select all
points={
{toX=400,toY=200}
{toY=500,drag=true}
}
Code: Select all
acursor.updateT(points,dt)
Finally lastly there's VIRTUAL MOUSE EVENTS which you can over-ride on your own for complicated cases. This is discussed in detail in the Example Section in the Github link.
There are some other features as well. Plus demos to get you started, Plus two Card Game examples to show you how you will can autoCursor in actual situations such as AI-MODE for Solitaire, etc games. So head on to the github link ( with Demos )
https://github.com/YoungNeer/lovelib/tr ... autocursor