I figured out how to use the keyboard api, I was thing it would be the same but I guess I'm wrong. This is how I tried to implement joystick.
Code: Select all
if love.joystick.isDown( joystick, 1 ) then
player.body:applyForce(10, 0.0)
print("moving right")
elseif love.joystick.isDown( joystick, -1 ) then
player.body:applyForce(-10, 0.0)
print("moving left")
end
if love.joystick.isDown( joystick, 2 ) then
player.body:applyForce(0, -500)
elseif love.joystick.isDown( joystick, -2 ) then
player.body:applyForce(0, 100)
end
-- as I did with love.keyboard.isDown which worked
if love.keyboard.isDown("right") then
player.body:applyForce(10, 0.0)
print("moving right")
elseif love.keyboard.isDown("left") then
player.body:applyForce(-10, 0.0)
print("moving left")
end
if love.keyboard.isDown("up") then
player.body:applyForce(0, -500)
elseif love.keyboard.isDown("down") then
player.body:applyForce(0, 100)
end
Code: Select all
then I put love.joystick.isDown( 0, 1 )
Code: Select all
if love.joystick.getHat(0 , 1 )then
objects.block1.body:applyForce(10, 0)
end
So basically the joystick.love is where i'm trying to figure out how to make the joystick to work and the prototypeshoter.love is a game I'm working on and would like to have joystick capabilities.