Skip to content

Instantly share code, notes, and snippets.

@Gitonym
Last active March 17, 2018 23:28
Show Gist options
  • Save Gitonym/cc8ac4c45e44e606899e46b3903247d1 to your computer and use it in GitHub Desktop.
Save Gitonym/cc8ac4c45e44e606899e46b3903247d1 to your computer and use it in GitHub Desktop.
A Topdown shooter for the Arduboy
#include <Tinyfont.h>
#include <ArduboyTones.h>
#include <Arduboy2.h>
Arduboy2 arduboy;
ArduboyTones sound(arduboy.audio.enabled);
Tinyfont tinyfont = Tinyfont(arduboy.sBuffer, Arduboy2::width(), Arduboy2::height());
const unsigned char speaker[] PROGMEM = {
0x1e, 0x3f, 0x00, 0x0c, 0x00, 0x12, 0x0c, 0x21, 0x1e,
};
const unsigned char menu[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xd0, 0x50, 0x50, 0x50, 0xd0, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xf0, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0xf0, 0x10, 0x10, 0x10, 0x10, 0xa0, 0x47, 0x08, 0x10, 0x08, 0x47, 0xa0, 0x10, 0x10, 0x10, 0x10,
0xf0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x40, 0xa0, 0xa0, 0xa0, 0x40, 0xc0, 0x00, 0x70, 0x8c, 0x04,
0xfa, 0xaa, 0xaa, 0x54, 0x8c, 0x70, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x7c, 0x42, 0x41, 0x42, 0x7c, 0x00, 0x01, 0x01, 0x01, 0x01,
0x01, 0x00, 0x00, 0x00, 0x07, 0x18, 0x17, 0x22, 0x22, 0x22, 0x17, 0x18, 0x07, 0x00, 0x01, 0x01,
0x02, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7d, 0x85, 0x05, 0x85, 0x7d, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7d, 0x85,
0x05, 0x85, 0x7d, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x81, 0x81, 0x41, 0x41, 0x41, 0x81, 0x81, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x1f, 0x11, 0x11, 0x11, 0x11, 0x0a, 0xc4, 0x20, 0x11, 0x20, 0xc4, 0x0a, 0x11, 0x11, 0x11, 0x11,
0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x11, 0x11, 0x11, 0x11, 0x0a, 0xc4, 0x20,
0x11, 0x20, 0xc4, 0x0a, 0x11, 0x11, 0x11, 0x11, 0x1f, 0x00, 0x04, 0x04, 0x1f, 0x04, 0x04, 0x00,
0x0e, 0x31, 0x2e, 0x45, 0x45, 0x45, 0x2e, 0x31, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04,
0x04, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char xhaku[] PROGMEM = {
0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81, 0xff, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xff,
0xc0, 0x30, 0x1c, 0x13, 0x13, 0x1c, 0x30, 0xc0, 0xff, 0x18, 0x24, 0x24, 0x42, 0x42, 0x81, 0x81,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff,
};
const unsigned char charger[] PROGMEM = {
0x33, 0xff, 0x7a, 0x2c, 0x2c, 0x7a, 0xff, 0x33,
};
const unsigned char roamer[] PROGMEM = {
0x70, 0xde, 0xfb, 0x7a, 0x7a, 0xfb, 0xde, 0x70,
};
const unsigned char bullet[] PROGMEM = {
0x18, 0x42, 0x18, 0xa5, 0xa5, 0x18, 0x42, 0x18,
};
const unsigned char player[] PROGMEM = {
0x1c, 0xb2, 0xf3, 0x5e, 0x5e, 0xf3, 0xb2, 0x1c,
};
const unsigned char bar[] PROGMEM = {
0xff, 0x81, 0xbd, 0xa1, 0x81, 0xbd, 0x81, 0x9d, 0xa1, 0x9d, 0x81, 0xbd, 0xb5, 0xa5, 0x81, 0xa9,
0xb5, 0x95, 0x81, 0xa5, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff, 0x81, 0xa9, 0xb5, 0x95, 0x81,
0xbd, 0xa5, 0x81, 0xbd, 0xa5, 0xbd, 0x81, 0xbd, 0x95, 0xb5, 0x9d, 0x81, 0xbd, 0xb5, 0xa5, 0x81,
0xa5, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff,
};
const unsigned char gameOver[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0x01, 0xf9, 0xf9, 0xf9, 0xf9, 0x09,
0xc9, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0xcf, 0xcf, 0xcf, 0xcf, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x01, 0x01, 0xf9, 0xf9, 0xf9, 0xf9, 0x09, 0x09, 0x09, 0x09, 0x09, 0xf9, 0x01, 0x01, 0xff,
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0x01, 0xf9, 0xf1, 0xe3, 0xc7, 0x8f,
0x8e, 0x44, 0x22, 0x11, 0xf9, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x01, 0x01, 0x79, 0x79, 0x79, 0x79, 0x49, 0x49, 0x49, 0xc9, 0xc9, 0xc9, 0xc9, 0x09, 0x0f,
0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0x9f, 0x9f, 0x9f, 0x9f, 0x90,
0x93, 0x92, 0x92, 0x92, 0x9e, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x80, 0x80, 0xf3, 0xf3, 0xf3, 0xf3, 0x12, 0x12, 0x12, 0x12, 0x12, 0xf3, 0x80, 0x80, 0xff,
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x80, 0x80, 0x9e, 0x9e, 0x9e, 0x9e, 0x92, 0x92, 0x92, 0x93, 0x93, 0x93, 0x93, 0x90, 0xf0,
0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x01, 0x01, 0xf9, 0xf9, 0xf9, 0xf9, 0x09, 0x09, 0x09, 0x09, 0x09, 0xf9, 0x01, 0x01, 0xff,
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0d, 0x31, 0xc1, 0x07, 0x1f, 0x7f, 0xff,
0xf8, 0x60, 0x18, 0x07, 0xc1, 0xf1, 0xfd, 0xff, 0x3f, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x01, 0x01, 0x79, 0x79, 0x79, 0x79, 0x49, 0x49, 0x49, 0xc9, 0xc9, 0xc9, 0xc9, 0x09, 0x0f,
0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0x01, 0x19, 0x19, 0x19, 0x19, 0x19,
0x99, 0x99, 0x99, 0x99, 0x99, 0x81, 0x81, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x80, 0x80, 0x9f, 0x9f, 0x9f, 0x9f, 0x90, 0x90, 0x90, 0x90, 0x90, 0x9f, 0x80, 0x80, 0xff,
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0c, 0x30, 0xc1,
0xc1, 0xf0, 0xfc, 0xff, 0x3f, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x80, 0x80, 0x9e, 0x9e, 0x9e, 0x9e, 0x92, 0x92, 0x92, 0x93, 0x93, 0x93, 0x93, 0x90, 0xf0,
0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0xff, 0xff, 0xfe, 0xfc, 0x08,
0x11, 0x23, 0x47, 0x8f, 0x9e, 0xbc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char inbo[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff,
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x9f, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00,
0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x83, 0x87, 0x8f, 0x9f, 0xfe, 0xfc, 0xf8, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff,
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff,
0xff, 0xe0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x83, 0xff, 0xff, 0xff, 0xfc, 0x80, 0x00,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x81, 0x81, 0xc2, 0xbc,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x01, 0x01, 0x01, 0xff,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff,
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff,
0xff, 0xff, 0xfc, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x8f, 0xff, 0xff, 0xff, 0xf0,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x9c, 0xbe, 0xff, 0xff, 0xe3, 0xc1, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff,
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff,
0xff, 0xff, 0xff, 0x0f, 0xf0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0xbf, 0xff, 0xff,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0x01, 0x01, 0x01, 0x02, 0xfc,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff,
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff,
0xff, 0xff, 0xff, 0x00, 0x01, 0x3e, 0xc0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x87, 0xff,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0x80, 0x80, 0x80, 0xc0, 0xbf,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x80, 0x80, 0x80, 0xff,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff,
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff,
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0xc0, 0xe0, 0xf0, 0x78, 0x3f, 0x1f, 0x0f, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
int screen = 0; //0 = "push any button"
//1 = menu
//2 = game
bool pressedA = false;
bool pressedB = false;
bool clutterDrawn = false;
int playerX = 64;
int playerY = 32;
int anim = 7; //0-7 idle animation
bool bulletState[10] = {false, false, false, false, false, false, false, false, false, false};
int bulletX[10];
int bulletY[10];
int bulletDir[10];
int enemyState[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int enemyX[10];
int enemyY[10];
int score = 0;
int lives = 9;
void setup() {
arduboy.begin();
arduboy.setFrameRate(30);
arduboy.initRandomSeed();
arduboy.clear();
}
void loop() {
if (!(arduboy.nextFrame())) {
return;
}
if (arduboy.everyXFrames(10)) {
if (anim == 7) {
anim = 0;
} else {
anim = anim + 1;
}
}
arduboy.pollButtons();
if (screen == 0) { //push any button screen
arduboy.drawBitmap(0, 0, inbo, 128, 64, WHITE); //draw INBO
if (arduboy.everyXFrames(30)) { //make "push any button" flash on screen
arduboy.setCursor(15, 56);
arduboy.print("-Push any Button-");
}
if (arduboy.everyXFrames(60)) { //make "push any button" flash on screen
arduboy.fillRect(0, 56, 128, 8, BLACK);
}
if (arduboy.justPressed(A_BUTTON) or arduboy.justPressed(B_BUTTON) or arduboy.justPressed(UP_BUTTON) or arduboy.justPressed(DOWN_BUTTON) or arduboy.justPressed(LEFT_BUTTON) or arduboy.justPressed(RIGHT_BUTTON)) {
pressedA = true;
pressedB = true;
screen = 1; //go to menu
arduboy.clear();
}
}
if (screen == 1) {
//drawStartMenu();
drawMenu();
if (arduboy.justPressed(B_BUTTON) and pressedB == false) {
arduboy.audio.toggle(); //toggle sound
sound.tone(1000, 50);
arduboy.audio.saveOnOff();
} else {
pressedB = false;
}
if (arduboy.justPressed(A_BUTTON) and pressedA == false) {
sound.tone(500, 100, 1000, 50);
screen = 2;
arduboy.clear();
} else {
pressedA = false;
}
}
if (screen == 2) {
arduboy.drawBitmap(0, 0, bar, 128, 8, WHITE);
tinyfont.setCursor(50, 2);
arduboy.fillRect(50, 2, 14, 4, BLACK);
if (score < 0) {
score = 0;
}
tinyfont.print(score);
tinyfont.setCursor(21, 2);
arduboy.fillRect(21, 2, 4, 4, BLACK);
tinyfont.print(lives);
drawPlayer();
drawRoom();
drawDoors(!(cleared()));
drawEnemies();
drawBullets();
takeDamage();
if (arduboy.everyXFrames(10)) {
killEnemies();
moveBullets();
destroyBullets();
killEnemies();
}
if (arduboy.everyXFrames(31)) {
moveEnemies();
}
if (arduboy.justPressed(RIGHT_BUTTON)) {
if (arduboy.pressed(A_BUTTON)) {
shootBullet(0);
} else {
if (playerX == 120 and playerY == 32 and cleared()) {
nextRoom(0);
} else {
movePlayer(0);
}
}
}
if (arduboy.justPressed(UP_BUTTON)){
if (arduboy.pressed(A_BUTTON)) {
shootBullet(1);
} else {
if (playerY == 8 and (playerX == 56 or playerX == 64) and cleared()) {
nextRoom(1);
} else {
movePlayer(1);
}
}
}
if (arduboy.justPressed(LEFT_BUTTON)){
if (arduboy.pressed(A_BUTTON)) {
shootBullet(2);
} else {
if (playerX == 0 and playerY == 32 and cleared()) {
nextRoom(2);
} else {
movePlayer(2);
}
}
}
if (arduboy.justPressed(DOWN_BUTTON)){
if (arduboy.pressed(A_BUTTON)) {
shootBullet(3);
} else {
if (playerY == 56 and (playerX == 56 or playerX == 64) and cleared()) {
nextRoom(3);
} else {
movePlayer(3);
}
}
}
if (!(clutterDrawn)) {
drawClutter();
spawnEnemies();
clutterDrawn = true;
}
}
if (screen == 3) {
arduboy.drawBitmap(0, -8, gameOver, 128, 64, WHITE);
arduboy.drawPixel(random(0, 128), random(0, 64), WHITE);
arduboy.drawPixel(random(0, 128), random(0, 64), WHITE);
if (arduboy.everyXFrames(3)) {
arduboy.drawPixel(random(43, 85), random(51, 61), WHITE);
}
arduboy.drawBitmap(44, 52, xhaku, 40, 8, BLACK);
if (arduboy.justPressed(A_BUTTON) or arduboy.justPressed(B_BUTTON) or arduboy.justPressed(UP_BUTTON) or arduboy.justPressed(DOWN_BUTTON) or arduboy.justPressed(LEFT_BUTTON) or arduboy.justPressed(RIGHT_BUTTON)) {
clutterDrawn = false;
playerX = 64;
playerY = 32;
lives = 9;
for (int i = 0; i < 10; i++) {
enemyState[i] = 0;
}
arduboy.clear();
sound.tone(500, 100, 1000, 50);
screen = 1;
}
}
arduboy.display(); //render screen
}
void drawMenu() {
if (arduboy.pressed(A_BUTTON)) {
arduboy.fillRect(21, 22, 7, 7, WHITE);
} else {
arduboy.fillRect(21, 22, 7, 7, BLACK);
}
if (arduboy.pressed(B_BUTTON)) {
arduboy.fillRect(30, 18, 7, 7, WHITE);
} else {
arduboy.fillRect(30, 18, 7, 7, BLACK);
}
if (arduboy.pressed(RIGHT_BUTTON)) {
arduboy.fillRect(11, 21, 5, 3, WHITE);
} else {
arduboy.fillRect(11, 21, 5, 3, BLACK);
}
if (arduboy.pressed(UP_BUTTON)) {
arduboy.fillRect(7, 15, 3, 5, WHITE);
} else {
arduboy.fillRect(7, 15, 3, 5, BLACK);
}
if (arduboy.pressed(LEFT_BUTTON)) {
arduboy.fillRect(1, 21, 5, 3, WHITE);
} else {
arduboy.fillRect(1, 21, 5, 3, BLACK);
}
if (arduboy.pressed(DOWN_BUTTON)) {
arduboy.fillRect(7, 25, 3, 5, WHITE);
} else {
arduboy.fillRect(7, 25, 3, 5, BLACK);
}
tinyfont.setCursor(0, 0);
tinyfont.print("A TO START");
tinyfont.setCursor(0, 5);
tinyfont.print("B TO TOGGLE SOUND");
arduboy.drawBitmap(90, 4, speaker, 9, 8, WHITE);
if (!(arduboy.audio.enabled())) {
arduboy.fillRect(92, 4, 7, 6, BLACK);
}
tinyfont.setCursor(18, 40);
tinyfont.print("WALK");
tinyfont.setCursor(74, 40);
tinyfont.print("SHOOT");
arduboy.drawBitmap(0, 0, menu, 128, 64, WHITE);
arduboy.drawBitmap(41, 14, roamer, 8, 8, WHITE);
arduboy.drawBitmap(41, 23, charger, 8, 8, WHITE);
tinyfont.setCursor(50, 16);
tinyfont.print("WALKS RANDOMLY");
tinyfont.setCursor(50, 26);
tinyfont.print("WALKS TO YOU");
}
void drawStartMenu() {
arduboy.setCursor(0, 4);
arduboy.print("A to Start...");
arduboy.setCursor(0, 20);
arduboy.print("B to toggle Sound");
arduboy.drawCircle(56, 52, 8, 1);
arduboy.drawCircle(72, 41, 8, 1);
arduboy.setCursor(54, 49);
arduboy.print ("A");
arduboy.setCursor(70, 38);
arduboy.print ("B");
arduboy.drawTriangle(114, 20, 114, 28, 106, 24, 1);
if (arduboy.audio.enabled()) {
arduboy.drawFastVLine(116, 23, 3, 1);
arduboy.drawFastVLine(118, 22, 5, 1);
arduboy.drawFastVLine(120, 21, 7, 1);
} else {
arduboy.drawFastVLine(116, 23, 3, 0);
arduboy.drawFastVLine(118, 22, 5, 0);
arduboy.drawFastVLine(120, 21, 7, 0);
}
}
void drawRoom() {
arduboy.drawFastVLine(0, 8, 56, 1); //left wall
arduboy.drawFastVLine(127, 8, 56, 1); //right wall
arduboy.drawFastHLine(0, 63, 128, 1); //bottom wall
arduboy.drawFastHLine(0, 8, 128, 1); //top wall
}
void drawDoors(bool right) {
//draw right frame
arduboy.drawFastHLine(125, 31, 2, 1);
arduboy.drawFastHLine(125, 40, 2, 1);
//draw top frame
arduboy.drawFastVLine(55, 9, 2, 1);
arduboy.drawFastVLine(72, 9, 2, 1);
//draw left frame
arduboy.drawFastHLine(1, 31, 2, 1);
arduboy.drawFastHLine(1, 40, 2, 1);
//draw bottom frame
arduboy.drawFastVLine(55, 61, 2, 1);
arduboy.drawFastVLine(72, 61, 2, 1);
// draw right door if true
if (!(right)) {
arduboy.drawFastVLine(127, 32, 8, 0);
arduboy.drawFastHLine(56, 8, 16, 0);
arduboy.drawFastVLine(0, 32, 8, 0);
arduboy.drawFastHLine(56, 63, 16, 0);
}
}
void drawClutter() {
for (int x = 0; x < 128; x = x + 8) {
for (int y = 8; y < 64; y = y + 8) {
arduboy.drawPixel(x + random(0, 8), y + random(0, 8), WHITE);
}
}
}
void movePlayer(int dir) {
sound.tone(500, 10);
if (dir == 0 and playerX < 120) {
arduboy.drawBitmap(playerX, playerY, player, 8, 8, BLACK);
arduboy.drawRect(playerX + 1, playerY + 2, 2, 2, BLACK);
arduboy.drawRect(playerX + 5, playerY + 2, 2, 2, BLACK);
playerX = playerX + 8;
}
if (dir == 1 and playerY > 8) {
arduboy.drawBitmap(playerX, playerY, player, 8, 8, BLACK);
arduboy.drawRect(playerX + 1, playerY + 2, 2, 2, BLACK);
arduboy.drawRect(playerX + 5, playerY + 2, 2, 2, BLACK);
playerY = playerY - 8;
}
if (dir == 2 and playerX > 0) {
arduboy.drawBitmap(playerX, playerY, player, 8, 8, BLACK);
arduboy.drawRect(playerX + 1, playerY + 2, 2, 2, BLACK);
arduboy.drawRect(playerX + 5, playerY + 2, 2, 2, BLACK);
playerX = playerX - 8;
}
if (dir == 3 and playerY < 56) {
arduboy.drawBitmap(playerX, playerY, player, 8, 8, BLACK);
arduboy.drawRect(playerX + 1, playerY + 2, 2, 2, BLACK);
arduboy.drawRect(playerX + 5, playerY + 2, 2, 2, BLACK);
playerY = playerY + 8;
}
}
void drawPlayer() {
arduboy.drawBitmap(playerX, playerY, player, 8, 8, WHITE);
//walking animation
if (anim == 0 or anim == 1 or anim == 4 or anim == 5) {
arduboy.drawPixel(playerX + 1,playerY + 7, BLACK);
arduboy.drawPixel(playerX + 2,playerY + 7, BLACK);
} else {
arduboy.drawPixel(playerX + 5,playerY + 7, BLACK);
arduboy.drawPixel(playerX + 6,playerY + 7, BLACK);
}
//blinking animation
if (anim == 7) {
arduboy.drawRect(playerX + 1, playerY + 2, 2, 2, WHITE);
arduboy.drawRect(playerX + 5, playerY + 2, 2, 2, WHITE);
}
if (anim == 0) {
arduboy.drawRect(playerX + 1, playerY + 2, 2, 2, BLACK);
arduboy.drawRect(playerX + 5, playerY + 2, 2, 2, BLACK);
}
}
void shootBullet(int dir) {
for (int i = 0; i < 10; i++) {
if (!(bulletState[i])) {
bulletState[i] = true;
bulletDir[i] = dir;
if (dir == 0) {
bulletX[i] = playerX + 8;
bulletY[i] = playerY;
}
if (dir == 1) {
bulletX[i] = playerX;
bulletY[i] = playerY - 8;
}
if (dir == 2) {
bulletX[i] = playerX - 8;
bulletY[i] = playerY;
}
if (dir == 3) {
bulletX[i] = playerX;
bulletY[i] = playerY + 8;
}
i = 11;
score -= 10;
sound.tone(750, 75);
}
}
}
void drawBullets() {
for (int i = 0; i < 10; i++) {
if (bulletState[i]) {
arduboy.drawBitmap(bulletX[i], bulletY[i], bullet, 8, 8, WHITE);
}
}
}
void moveBullets() {
for (int i = 0; i < 10; i++) {
if (bulletState[i]) {
arduboy.drawBitmap(bulletX[i], bulletY[i], bullet, 8, 8, BLACK);
if (bulletDir[i] == 0) {
bulletX[i] = bulletX[i] + 8;
}
if (bulletDir[i] == 1) {
bulletY[i] = bulletY[i] - 8;
}
if (bulletDir[i] == 2) {
bulletX[i] = bulletX[i] - 8;
}
if (bulletDir[i] == 3) {
bulletY[i] = bulletY[i] + 8;
}
}
}
}
void destroyBullets() {
for (int i = 0; i < 10; i++) {
if (bulletX[i] < 0 or bulletX[i] > 120 or bulletY[i] < 8 or bulletY[i] > 56) {
bulletState[i] = false;
}
}
}
void spawnEnemies() {
int enemyAmount = random(1, 11);
for (int i = 0; i < enemyAmount; i++) {
enemyState[i] = random(1, 3);
enemyX[i] = 8 * random(0, 16);
enemyY[i] = 8 * random(1, 8);
if (enemyX[i] == playerX and enemyY[i] == playerY) {
enemyState[i] = 0;
}
for (int j = i - 1; j >= 0; j--) {
if (enemyX[j] == enemyX[i] and enemyY[j] == enemyY[i]) {
enemyState[i] = 0;
}
}
}
}
void drawEnemies() {
for (int i = 0; i < 10; i++) {
if (enemyState[i] == 1) {
arduboy.drawBitmap(enemyX[i], enemyY[i], roamer, 8, 8, WHITE);
}
if (enemyState[i] == 2) {
arduboy.drawBitmap(enemyX[i], enemyY[i], charger, 8, 8, WHITE);
}
}
}
void moveEnemies() {
for (int i = 0; i < 10; i++) {
int dir = random(0, 5);
if (enemyState[i] == 1) {
if (!(dir == 4 or dir == 3)) {
arduboy.drawBitmap(enemyX[i], enemyY[i], roamer, 8, 8, BLACK);
}
if (dir == 0) {
if (enemyX[i] < 120) {
enemyX[i] += 8;
} else {
dir = random(1, 4);
}
}
if (dir == 1) {
if (enemyY[i] > 8) {
enemyY[i] -= 8;
} else {
dir = random(2, 4);
}
}
if (dir == 2) {
if (enemyX[i] > 0) {
enemyX[i] -= 8;
} else {
dir = 3;
}
}
if (dir == 3) {
if (enemyY[i] < 56) {
arduboy.drawBitmap(enemyX[i], enemyY[i], roamer, 8, 8, BLACK);
enemyY[i] += 8;
}
}
}
if (enemyState[i] == 2) {
arduboy.drawBitmap(enemyX[i], enemyY[i], charger, 8, 8, BLACK);
if (playerX > enemyX[i]) {
enemyX[i] += 8;
}
if (playerX < enemyX[i]) {
enemyX[i] -= 8;
}
if (playerY > enemyY[i]) {
enemyY[i] += 8;
}
if (playerY < enemyY[i]) {
enemyY[i] -= 8;
}
}
}
}
void killEnemies() {
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
if (enemyState[i] > 0 and bulletState[j] == true and enemyX[i] == bulletX[j] and enemyY[i] == bulletY[j]) {
if (enemyState[i] == 1) {
arduboy.drawBitmap(enemyX[i], enemyY[i], roamer, 8, 8, BLACK);
}
if (enemyState[i] == 2) {
arduboy.drawBitmap(enemyX[i], enemyY[i], charger, 8, 8, BLACK);
}
score += 10;
enemyState[i] = 0;
sound.tone(100, 75);
}
}
}
}
void takeDamage() {
bool damageTaken = false;
for (int i = 0; i < 10; i++) {
if (enemyX[i] == playerX and enemyY[i] == playerY and enemyState[i] > 0) {
damageTaken = true;
if (enemyState[i] == 1) {
arduboy.drawBitmap(enemyX[i], enemyY[i], roamer, 8, 8, BLACK);
}
if (enemyState[i] == 2) {
arduboy.drawBitmap(enemyX[i], enemyY[i], charger, 8, 8, BLACK);
}
enemyState[i] = 0;
}
}
if (damageTaken) {
lives -= 1;
sound.tone(250, 150, 100, 75);
if (lives < 1) {
screen = 3;
sound.tone(300, 150, 150, 150, 50, 150);
arduboy.clear();
}
}
}
bool cleared() {
for (int i = 0; i < 10; i++) {
if (enemyState[i] > 0) {
return false;
}
}
return true;
}
void nextRoom(int dir) {
arduboy.clear();
clutterDrawn = false;
if (dir == 0) {
playerX = 0;
}
if (dir == 1) {
playerY = 56;
}
if (dir == 2) {
playerX = 120;
}
if (dir == 3) {
playerY = 8;
}
for (int i = 0; i < 10; i++) {
bulletState[i] = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment