This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
notes:cprog:fall2024:projects:fwgx [2024/10/28 21:07] – [FWG1] wedge | notes: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 '' | ||
+ | Most functions return a integer value that represents whether a button is being pressed or not | ||
+ | |||
+ | < | ||
+ | int buttonA; | ||
+ | buttonA = gamepad_button_a() | ||
+ | |||
+ | if(buttonA == 1) | ||
+ | { | ||
+ | print_at(0, 0, " | ||
+ | } | ||
+ | </ | ||
+ | or | ||
+ | < | ||
+ | if(gamepad_button_a() == 1) | ||
+ | { | ||
+ | print_at(0, 0, " | ||
+ | } | ||
+ | </ | ||
+ | Some functions require an adress input: such as gamepad_direction() | ||
+ | < | ||
+ | int directionX; | ||
+ | int directionY; | ||
+ | |||
+ | gamepad_direction(& | ||
+ | |||
+ | 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" | ||
+ | } | ||
+ | </ | ||
=====structures===== | =====structures===== | ||
=====bounds checking===== | =====bounds checking===== | ||