• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows Joysticks: What I did today, and a Question

C

ConsolCWBY

Guest
I have been depressed lately over the Jam... I had not one scrap of code in my code base. In fact, I had not one script, one scrapt of useful code. So I plan on rectifying this. And that brings us to:
Today I made a couple of scripts - like this one:
Code:
// set_joystick_input(arg0) - where arg0 is the object calling the script...
// Reminder: global.player_stick is in the globe_init() script!
{
  var obP = argument0;
  with (obP)
  {
  if (joystick_xpos(global.player_stick)<0)
  {
  if (x>sprite_width)
  {
  x-=4;
  }
  }
  
  if (joystick_xpos(global.player_stick)>0)
  {
  if (x<room_width-sprite_width)
  {
  x+=4;
  }
  }

  if (joystick_ypos(global.player_stick)<0)
  {
  if (y>sprite_height)
  {
  y-=2;
  }
  }

  if (joystick_ypos(global.player_stick)>0)
  {
  if (y<room_height-sprite_width)
  {
  y+=2;
  }
  }

  if ((joystick_check_button(global.player_stick, 1))&&(!global.fire_rate))
  {
  var inst = 0;
  inst = instance_create(x,y,obj_player_bullet);
  with(inst)
  {
  vspeed = -4;
  direction = 90;
  }
  global.fire_rate = round(room_speed/4);
  }
  }
}
:) I am building my code base day by day!

Now for the question: I couldn't find it in the manual.. is there a way to detect how many buttons a Joystick device has? I know how many I have, but in ye olden dayz there were but 1. So, unless a new ANSII spec for joysticks came out while I was busy, I am supposing they still run the gamut of 1 to infinity-1
Is there a way to poll the device - beyond a config screen?
 
Last edited by a moderator:
C

ConsolCWBY

Guest
Yay! Thank you obscene! I must have been blind to have not seen it! Thanks again! :)
 
Top