Space invaders with a nRF2401A wireless joypad

Dependencies:   Gameduino mbed nRF2401A

Fork of Gameduino_Invaders_game by Chris Dick

Gameduino and an nRF2401A hooked up to an mbed on an mbeduino:

/media/uploads/TheChrisyd/2014-03-08_22.53.54.jpg

Revision:
4:bb78bedae411
Parent:
2:20a89dc286d5
--- a/joystick.h	Fri Dec 21 13:53:46 2012 +0000
+++ b/joystick.h	Sat Oct 26 22:34:08 2013 +0000
@@ -13,6 +13,14 @@
 
 //#include "WProgram.h"
 #include "arduino.h"
+
+#define STICK_LEFT_BIT    0x01
+#define STICK_RIGHT_BIT   0x02
+#define STICK_UP_BIT      0x04
+#define STICK_DOWN_BIT    0x08
+#define ANALOG_STICK_BIT  0x80
+#define STICK_INFO_MASK (ANALOG_STICK_BIT)
+
 class Joystick {
   byte buttons;      // State of buttons, packed into a byte
   byte prev;         // State of the buttons on previous read
@@ -29,7 +37,6 @@
 
   // Return "true" if analog X/Y position is available
   bool hasAnalogStick();
-
 // Digital joystick functions
   enum button_name {
     buttonA      = 0x01,
@@ -49,10 +56,10 @@
   bool changed(byte n) { return bool((buttons^prev)&n); }
   
   // Joystick up/down/left/right (or analog stick)
-  bool left()  { return (dpad&0x01)!=0; }
-  bool right() { return (dpad&0x02)!=0; }
-  bool up()    { return (dpad&0x04)!=0; }
-  bool down()  { return (dpad&0x08)!=0; }
+  bool left()  { return (dpad&STICK_LEFT_BIT)!=0; }
+  bool right() { return (dpad&STICK_RIGHT_BIT)!=0; }
+  bool up()    { return (dpad&STICK_UP_BIT)!=0; }
+  bool down()  { return (dpad&STICK_DOWN_BIT)!=0; }
 
 
 // Analog joystick functions