User Tools

Site Tools


notes:cprog:fall2024:projects:fwgx

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
notes:cprog:fall2024:projects:fwgx [2024/10/28 21:07] – [FWG1] wedgenotes:cprog:fall2024:projects:fwgx [2024/10/31 00:44] (current) – [gamepad] tkastne1
Line 12: Line 12:
  
 ====gamepad==== ====gamepad====
 +To get inputs from a gamepad you can include the ''input.h'' header file.
  
 +Most functions return a integer value that represents whether a button is being pressed or not
 +
 +<code>
 +int buttonA;
 +buttonA = gamepad_button_a()
 +
 +if(buttonA == 1)
 +{
 +  print_at(0, 0, "Button A pressed");
 +}
 +</code>
 +or
 +<code>
 +if(gamepad_button_a() == 1)
 +{
 +  print_at(0, 0, "Button A pressed");
 +}
 +</code>
 +Some functions require an adress input: such as gamepad_direction()
 +<code>
 +int directionX;
 +int directionY;
 +
 +gamepad_direction(&directionX, &directionY);
 +
 +if(directionX == 1)
 +{
 +  print_at(0, 0, "Right pressed");
 +}
 +else if(directionX == -1)
 +{
 +  print_at(0, 0, "Left pressed");
 +}
 +
 +if(directionY == 1)
 +{
 +  print_at(0, 18, "Up pressed");
 +}
 +else if(directionY == -1)
 +{
 +  print_at(0, 18, "Down pressed");
 +}
 +</code>
 =====structures===== =====structures=====
  
 =====bounds checking===== =====bounds checking=====
  
notes/cprog/fall2024/projects/fwgx.1730149651.txt.gz · Last modified: 2024/10/28 21:07 by wedge