Space invaders with a nRF2401A wireless joypad
Dependencies: Gameduino mbed nRF2401A
Fork of Gameduino_Invaders_game by
Gameduino and an nRF2401A hooked up to an mbed on an mbeduino:
main.cpp
- Committer:
- TheChrisyd
- Date:
- 2013-10-26
- Revision:
- 4:bb78bedae411
- Parent:
- 2:20a89dc286d5
- Child:
- 5:3ede9991d8e0
File content as of revision 4:bb78bedae411:
#include "mbed.h" #include "GD.h" #include "shield.h" GDClass GD(ARD_MOSI, ARD_MISO, ARD_SCK, ARD_D9, USBTX, USBRX) ; /*--------------------------------------------------------- A Space Invaders clone for Gameduino http://www.artlum.com/gameduino/gameduino.html#invaders Version 0.9 alpha - Still seme things to add but I'm out of memory! Edit "joystick.cpp" if you have a custom joystick. ---------------------------------------------------------*/ #include "game.h" #include "arduino.h" #include "nRF2401A.h" #define WIRELESS nRF2401A wireless_joypad(p10, p11, p12, p13, p14); byte wireless_dpad = 0; byte wireless_buttons = 0; DigitalOut debug(LED1); //void nRF2401A_rx (void *arg); void nRF2401A_rx (void *arg) { wireless_joypad.readMsg_byte(&wireless_dpad, 0 ); wireless_joypad.readMsg_byte(&wireless_buttons, 1 ); debug = !debug; } void setup() { GD.begin(); #ifdef WIRELESS wait(0.005); wireless_joypad.setDataPayloadLength(4 << 3) .setAddress(0x0, 0x0, 0x53, 0x53, 0x53, 3 << 3) .setCRCMode(nRF2401A::NO_CRC) .setDataRate(nRF2401A::BIT_RATE_250KBITS) .setChannel(0x02); wireless_joypad.flushControlPacket(); wireless_joypad.attachRXHandler(&nRF2401A_rx, 0); #endif makeGraphics(); Coprocessor::reset(samplePlaybackBuffer); randomSeed(GD.rd(FRAME)); resetGameSounds(); initGame(); } void loop() { GD.waitvblank(); updateGame(); updateGameSounds(); // Debugging/info if (0) { joystick.dump(0,33); // Show the joystick state int yline = Coprocessor::yline(); showNumber(yline,0,31); } // Screenshot when you press the select button if (0 and joystick.isPressed(Joystick::buttonSelect)) { sendScreenshot(); } } int main() { setup(); while (1) { loop(); } }