Confused on how to make joystick to work

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
kingslovelua
Citizen
Posts: 71
Joined: Mon Sep 26, 2011 7:16 pm

Confused on how to make joystick to work

Post by kingslovelua »

So I post up that I couldn't get TLbind to work for me here:viewtopic.php%20f=5&t=3781&start=20 , but I never got answer on why I couldn't get it to work, well I never got a answer at all. Now I basically just want to keep it simple and just write up the code to make joystick work.

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 ) 
and it moved on it's own and i tried the same with

Code: Select all

if  love.joystick.getHat(0 , 1 )then 
 objects.block1.body:applyForce(10, 0)
end 
and it also moved on it's own but how do it get it to work the way i want it.


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.
Attachments
prototype shoot 0.0.0.0.1.1.love
and this is the game i'm working and would like to have the joystick in
(6.5 KiB) Downloaded 103 times
joyStick.love
this is where im trying to work on the joystick
(1.81 KiB) Downloaded 110 times
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Confused on how to make joystick to work

Post by Lafolie »

The joystick indexing has been changed to start at 1 and not 0.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
kingslovelua
Citizen
Posts: 71
Joined: Mon Sep 26, 2011 7:16 pm

Re: Confused on how to make joystick to work

Post by kingslovelua »

Lafolie wrote:The joystick indexing has been changed to start at 1 and not 0.

Thank you, how do I give you a +1 karma all i did was put one and it started to work thanks
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Confused on how to make joystick to work

Post by Nixola »

There's a small "+" button on the user's profile or under its avatar, near its posts
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Confused on how to make joystick to work

Post by Lafolie »

Nixola wrote:There's a small "+" button on the user's profile or under its avatar, near its posts
It?
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Confused on how to make joystick to work

Post by Nixola »

I'm talking about the "generic user", not about you ;)
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest