// note - Adafruit logo splash disabled in Adafruit_SSD1306.h
// 32514 / 524 original
// 30312 / 512 resize several images, move image array to PROGMEM
// 29992 / 517
// 29652 / 503
// 28822 / 491
// 28332 / 487
// 28254 / 483
// 27726 / 467 changed floats to long/int/byte
// 27168 / 467 optimized storage of menu text - note there is an error in display of submenu
// 27054 / 467 final version with Adafruit_SSD1306
/* Tamaguino
by Alojz Jakob <http://jakobdesign.com>
********** TAMAGUINO ***********
Tamagotchi clone for Arduino
********************************
*/
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
////#include <EEPROM.h>
//#define OLED_RESET 4
#define OLED_RESET -1 //no RESET pin on display
//Adafruit_SSD1306 display(OLED_RESET);
//Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET); //new constructor
#include <U8g2lib.h>
//#include "u8g2_font_glcdfont.c"
#define displayWidth 128
#define displayHeight 64
#define yOffset 7 //U8g2 text baseline is 7 pixels lower than Adafruit_SSD1306
U8G2_SSD1306_128X64_NONAME_F_HW_I2C display(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
const int button1Pin = 9;
const int button2Pin = 8;
const int button3Pin = 7;
const int soundPin = 6;
int button1State = 0;
int button2State = 0;
int button3State = 0;
//int hi_address = 0;
//int hunger_address = 2;
//int happiness_address = 3;
//int health_address = 4;
//int discipline_address = 5;
//int weight_address = 6;
//int age_address = 7;
#include "xbm.h"
/*
// splash 48x24
const unsigned char splash1 [] PROGMEM = {
0x00, 0x39, 0xc0, 0x00, 0x00, 0x00, //..........###..###..............................
0x00, 0x39, 0xc0, 0x00, 0x00, 0x00, //..........###..###..............................
0x00, 0x39, 0xc0, 0x00, 0x00, 0x00, //..........###..###..............................
0x00, 0x38, 0x00, 0x00, 0x00, 0x00, //..........###...................................
0x00, 0x38, 0x00, 0x00, 0x00, 0x00, //..........###...................................
0x07, 0xb9, 0xce, 0x78, 0x0f, 0xc0, //.....####.###..###..###..####.......######......
0x0f, 0xf9, 0xcf, 0xfc, 0x1f, 0xe0, //....#########..###..##########.....########.....
0x1f, 0xf9, 0xcf, 0xfe, 0x3f, 0xf0, //...##########..###..###########...##########....
0x3c, 0x79, 0xcf, 0x1e, 0x38, 0x78, //..####...####..###..####...####...###....####...
0x38, 0x39, 0xce, 0x0e, 0x70, 0x38, //..###.....###..###..###.....###..###......###...
0x38, 0x39, 0xce, 0x0e, 0x70, 0x38, //..###.....###..###..###.....###..###......###...
0x38, 0x39, 0xce, 0x0e, 0x70, 0x38, //..###.....###..###..###.....###..###......###...
0x38, 0x39, 0xce, 0x0e, 0x70, 0x38, //..###.....###..###..###.....###..###......###...
0x38, 0x39, 0xce, 0x0e, 0x70, 0x38, //..###.....###..###..###.....###..###......###...
0x3c, 0x79, 0xce, 0x0e, 0x78, 0x70, //..####...####..###..###.....###..####....###....
0x1f, 0xf9, 0xce, 0x0e, 0x3f, 0xf0, //...##########..###..###.....###...##########....
0x0f, 0xf9, 0xce, 0x0e, 0x1f, 0xe0, //....#########..###..###.....###....########.....
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //................................................
0x00, 0x02, 0x00, 0x10, 0x00, 0x10, //..............#............#...............#....
0x25, 0x37, 0x53, 0x90, 0xe1, 0xb8, //..#..#.#..##.###.#.#..###..#....###....##.###...
0x29, 0x22, 0x51, 0xd0, 0x93, 0x90, //..#.#..#..#...#..#.#...###.#....#..#..###..#....
0x19, 0x22, 0x52, 0x50, 0x92, 0x10, //...##..#..#...#..#.#..#..#.#....#..#..#....#....
0x11, 0x23, 0x73, 0xd0, 0xf1, 0x98, //...#...#..#...##.###..####.#....####...##..##...
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, //................................#...............
};
//splash dino 80x40
const unsigned char splash2[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x39, 0xff, 0xe0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0xff, 0xf8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xe1, 0xfc,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfe, 0x3e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5e, 0xc1, 0xde,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7d, 0x80, 0x2f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x1f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfa,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x07, 0xf4,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf5, 0xe0, 0x1f, 0xe8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xaa, 0xbc, 0x7f, 0xd0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3d, 0x55, 0x5f, 0xff, 0xa0,
0x00, 0x00, 0x00, 0x00, 0x00, 0xea, 0xaa, 0xaf, 0xff, 0x40,
0x00, 0x00, 0x00, 0x00, 0x03, 0xd5, 0x55, 0xff, 0xfe, 0x80,
0x00, 0x00, 0x00, 0x00, 0x07, 0xab, 0xae, 0xbf, 0xfd, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0x5f, 0xdf, 0xff, 0xfa, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3f, 0xee, 0xfb, 0x6f, 0xf4, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xe8, 0x00,
0x00, 0x00, 0x00, 0x01, 0xff, 0xf7, 0xff, 0xff, 0xd0, 0x00,
0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xa0, 0x00,
0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xfd, 0xc0, 0x00,
0x00, 0x00, 0x00, 0xff, 0xdf, 0xff, 0xfe, 0xfe, 0x80, 0x00,
0x00, 0x00, 0x1f, 0xff, 0xef, 0xef, 0xff, 0x7f, 0x00, 0x00,
0x00, 0x03, 0xff, 0xff, 0x9f, 0xdf, 0xff, 0xbf, 0x00, 0x00,
0x00, 0xff, 0xff, 0xfc, 0x1f, 0xa1, 0xfc, 0x7f, 0x80, 0x00,
0x0f, 0xff, 0xff, 0xe0, 0x1f, 0xb0, 0x03, 0xbf, 0x80, 0x00,
0x1f, 0xff, 0x80, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//............................................................#####...............
//...........................................................#############........
//..........................................................###..############.....
//..........................................................###.###############...
//..........................................................#########....#######..
//.........................................................##############...#####.
//.........................................................#.####.##.....###.####.
//.........................................................#####.##.........#.####
//..........................................................###.#............#####
//...........................................................................#####
//...........................................................................#####
//...........................................................................#####
//..........................................................................######
//........................................................................#######.
//.......................................................................######.#.
//...................................................######............#######.#..
//................................................####.#.####........########.#...
//.............................................####.#.#.#.#.####...#########.#....
//..........................................####.#.#.#.#.#.#.##############.#.....
//........................................###.#.#.#.#.#.#.#.#.############.#......
//......................................####.#.#.#.#.#.#.################.#.......
//.....................................####.#.#.###.#.###.#.############.#........
//...................................#####.#.#######.##################.#.........
//..................................#########.###.#####.##.##.########.#..........
//................................###################################.#...........
//...............................#############.#####################.#............
//.............................####################################.#.............
//...........................###################################.###..............
//........................##########.####################.#######.#...............
//...................################.#######.############.#######................
//..............###################..#######.##############.######................
//........######################.....######.#....#######...########...............
//....#######################........######.##..........###.#######...............
//...##############...................######......................................
//.######.........................................................................
//.###............................................................................
//###.............................................................................
//##..............................................................................
//##..#...........................................................................
//.###............................................................................
// front grass 32x10
const unsigned char grass_front [] PROGMEM = { //32x8
0x00, 0x01, 0x00, 0x00, //...............#................
0x00, 0x00, 0x80, 0x80, //................#.......#.......
0x00, 0x08, 0x89, 0xc0, //............#...#...#..###......
0x48, 0x5c, 0x50, 0x84, //.#..#....#.###...#.#....#....#..
0x9c, 0x48, 0x50, 0x22, //...###...#..#....#.#......#...#.
0x88, 0x80, 0x44, 0x22, //....#...#........#...#....#...#.
0x40, 0x84, 0x2e, 0x21, //.#......#....#....#.###...#....#
0x49, 0x24, 0xa4, 0xb1, //.#..#..#..#..#..#.#..#..#.##...#
};
//grass 2 (dino walking on) 4x8
const unsigned char grass [] PROGMEM = { //8x6
0xff, //.#######
0xee, //.##.###.
0xbb, //..###.##
0x55, //.#.#.#.#
0xaa, //..#.#.#.
0x11, //...#...#
};
//trees 112x20
const unsigned char trees [] PROGMEM = { //112x20
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x05, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x15, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x55, 0x40, 0x00, 0x55, 0x40, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x15, 0x04, 0x40, 0x15, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x02, 0xa0, 0x00, 0x00, 0x01, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x28, 0x84, 0x24, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x04, 0x40, 0x00, 0x82, 0x00, 0x00, 0x01, 0x10, 0x00, 0x04, 0x40, 0x00, 0x00,
0x00, 0x01, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x41, 0x00, 0x10, 0x00, 0x00, 0x00,
0x00, 0x04, 0x40, 0x00, 0x88, 0x82, 0x40, 0x91, 0x04, 0x24, 0x41, 0x10, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x10, 0x44, 0x44, 0x11, 0x04, 0x10, 0x11, 0x04, 0x01, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x02, 0x10, 0x00, 0x80, 0x00,
0x00, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x04, 0x00,
0x08, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
};
//......................................................#......................#..................................
//................................................................................................................
//...........................................#.........#.#...................#.#.#................................
//.........................................................#......................................................
//..........................................#.#......#.#.#.................#.#.#.#................................
//................................................................................................................
//.........................................#.#.#...#.#.#.#.#...............#.#.#.#.#..............................
//................................#..............................#......................#.........................
//.........................................#.#.#.....#.#.#.....#...#.........#.#.#................................
//..............................#.#.#............................#...#................#...........................
//...............#..........................#.#...#....#....#..#...#...........#..................................
//.............#...#..............#.....#........................#...#.................#...#......................
//...............#..............#...#..............................#.....#...........#............................
//.............#...#..............#...#...#.....#..#......#..#...#.....#....#..#...#.....#...#....................
//...............#................................................................................................
//...........................#.....#...#...#...#.....#...#.....#.....#.......#...#.....#.........#................
//...............#...................................................................................#............
//......................#..............................#........................#....#............#...............
//............#................#...........................................#...........................#..........
//....#.............#....................#.......................#............................................#...
const unsigned char mountains [] PROGMEM = { //128x16
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e,
0x01, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f,
0x03, 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0x07, 0x74, 0x07, 0x80, 0x10, 0x00, 0x00, 0x80, 0x00, 0x06, 0x80, 0x00, 0x00, 0x00, 0x00, 0xd5,
0x0e, 0xc2, 0x0d, 0xc0, 0x28, 0x01, 0x01, 0xc1, 0x00, 0x1f, 0x40, 0x00, 0x00, 0x00, 0x01, 0x28,
0x1d, 0x13, 0x1b, 0x60, 0x54, 0x03, 0x83, 0xa3, 0x80, 0x36, 0x20, 0x00, 0x00, 0x00, 0x06, 0xd0,
0x3a, 0x41, 0xb4, 0x30, 0xe2, 0xcc, 0xf7, 0x57, 0xc0, 0xd8, 0x10, 0x00, 0x00, 0x00, 0x19, 0x20,
0x68, 0x84, 0x49, 0x19, 0xa1, 0x36, 0x5d, 0x2a, 0xa1, 0xa0, 0x10, 0x00, 0x00, 0x00, 0xe6, 0x40,
0xd2, 0x10, 0xa4, 0x0c, 0x80, 0x8c, 0x1a, 0x15, 0x57, 0x40, 0x88, 0x00, 0x00, 0x1f, 0x38, 0x80,
0x49, 0x08, 0x00, 0x06, 0x02, 0xc0, 0x24, 0x18, 0x0b, 0x80, 0x05, 0x0b, 0x8c, 0xe0, 0x23, 0x00,
0xa0, 0x20, 0x00, 0x11, 0x00, 0x00, 0x48, 0x84, 0x84, 0x02, 0x20, 0x5d, 0xf3, 0x00, 0xcd, 0xc0,
0x50, 0x00, 0x04, 0x04, 0x01, 0x44, 0x00, 0x00, 0x08, 0x00, 0x00, 0x30, 0x04, 0x07, 0x10, 0x20,
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x40, 0x40, 0x00, 0x10,
0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x01, 0x11, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x20, 0x02,
};
//.........#...................................................................................................................#..
//........###.................................................................................................................###.
//.......#####...............................................................................................................#####
//......#######.........##.......................................................#..........................................######
//.....###.###.#.......####..........#....................#....................##.#.......................................##.#.#.#
//....###.##....#.....##.###........#.#..........#.......###.....#...........#####.#.....................................#..#.#...
//...###.#...#..##...##.##.##......#.#.#........###.....###.#...###.........##.##...#..................................##.##.#....
//..###.#..#.....##.##.#....##....###...#.##..##..####.###.#.#.#####......##.##......#...............................##..#..#.....
//.##.#...#....#...#..#..#...##..##.#....#..##.##..#.###.#..#.#.#.#.#....##.#........#............................###..##..#......
//.#.#..#....#....#.#..#......##..#.......#...##.....##.#....#.#.#.#.#.###.#......#...#......................#####..###...#.......
//.#..#..#....#................##.......#.##........#..#.....##.......#.###............#.#....#.###...##..###.......#...##........
//..#.......#................#...#.................#..#...#....#..#....#........#...#......#.###.#####..##........##..##.###......
//.#.#.................#.......#.........#.#...#......................#.....................##.........#.......###...#......#.....
//.....................................#......................................#....................#.......#.................#....
//.#............#.........................................#......#...............................#...#...#.......#................
//.................................#..............................................#.......#.........................#...........#.
const unsigned char cloud2 [] PROGMEM = { //32x5
0x04, 0x70, 0x18, 0x00, //.....#...###.......##...........
0x6e, 0xfb, 0x7c, 0xee, //.##.###.#####.##.#####..###.###.
0xff, 0xff, 0xfd, 0xff, //.#####################.#########
0x6f, 0xfb, 0x38, 0xee, //.##.#########.##..###...###.###.
0x07, 0x70, 0x52, 0x00, //.....###.###.....#.#..#.........
};
// walking sprites
// walk right
const unsigned char dinoWalk0 [] PROGMEM = { //32x9
0x00, 0x07, 0xc0, 0x60, //.............#####.......##.....
0x00, 0x1f, 0xf1, 0xf0, //...........#########...#####....
0x00, 0x3f, 0xff, 0xb8, //..........###############.###...
0x00, 0x7b, 0xff, 0xfc, //.........####.################..
0x00, 0xff, 0xff, 0xd8, //........##################.##...
0x03, 0xff, 0x7f, 0xe0, //......##########.##########.....
0x0f, 0xf7, 0xde, 0x00, //....########.#####.####.........
0x7f, 0xf8, 0x3c, 0x00, //.############.....####..........
0x00, 0xbc, 0x7a, 0x00, //........#.####...####.#.........
};
const unsigned char dinoWalk1 [] PROGMEM = { //32x9
0x00, 0x07, 0xc0, 0x60, //.............#####.......##.....
0x00, 0x1f, 0xf1, 0xf0, //...........#########...#####....
0x00, 0x37, 0xff, 0xb8, //..........##.############.###...
0x00, 0x7f, 0xff, 0xfc, //.........#####################..
0x00, 0xff, 0x7f, 0xd8, //........########.#########.##...
0x03, 0xff, 0xff, 0xe0, //......#####################.....
0x0f, 0xbf, 0xda, 0x00, //....#####.########.##.#.........
0x7f, 0xf8, 0x3c, 0x00, //.############.....####..........
0x00, 0x30, 0x18, 0x00, //..........##.......##...........
};
const unsigned char dinoWalk2 [] PROGMEM = { //32x9
0x00, 0x07, 0xc0, 0x60, //.............#####.......##.....
0x00, 0x1b, 0xf1, 0xf0, //...........##.######...#####....
0x00, 0x3f, 0xff, 0xb8, //..........###############.###...
0x00, 0x7f, 0x7f, 0xfc, //.........#######.#############..
0x00, 0xff, 0xff, 0xd8, //........##################.##...
0x03, 0xff, 0xff, 0xe0, //......#####################.....
0x0f, 0xbf, 0xfa, 0x00, //....#####.###########.#.........
0x7f, 0x78, 0x3c, 0x00, //.#######.####.....####..........
0x00, 0xf4, 0x5e, 0x00, //........####.#...#.####.........
};
// walk left
const unsigned char dinoWalk3 [] PROGMEM = { //32x9
0x06, 0x03, 0xe0, 0x00, //.....##.......#####.............
0x0f, 0x8f, 0xf8, 0x00, //....#####...#########...........
0x1d, 0xff, 0xfc, 0x00, //...###.###############..........
0x3f, 0xff, 0xde, 0x00, //..################.####.........
0x1b, 0xff, 0xff, 0x00, //...##.##################........
0x07, 0xfe, 0xff, 0xc0, //.....##########.##########......
0x00, 0x7b, 0xef, 0xf0, //.........####.#####.########....
0x00, 0x3c, 0x1f, 0xfe, //..........####.....############.
0x00, 0x5e, 0x3d, 0x00, //.........#.####...####.#........
};
const unsigned char dinoWalk4 [] PROGMEM = { //32x9
0x06, 0x03, 0xe0, 0x00, //.....##.......#####.............
0x0f, 0x8f, 0xf8, 0x00, //....#####...#########...........
0x1d, 0xff, 0xec, 0x00, //...###.############.##..........
0x3f, 0xff, 0xfe, 0x00, //..#####################.........
0x1b, 0xfe, 0xff, 0x00, //...##.#########.########........
0x07, 0xff, 0xff, 0xc0, //.....#####################......
0x00, 0x5b, 0xfd, 0xf0, //.........#.##.########.#####....
0x00, 0x3c, 0x1f, 0xfe, //..........####.....############.
0x00, 0x18, 0x0c, 0x00, //...........##.......##..........
};
const unsigned char dinoWalk5 [] PROGMEM = { //32x9
0x06, 0x03, 0xe0, 0x00, //.....##.......#####.............
0x0f, 0x8f, 0xd8, 0x00, //....#####...######.##...........
0x1d, 0xff, 0xfc, 0x00, //...###.###############..........
0x3f, 0xfe, 0xfe, 0x00, //..#############.#######.........
0x1b, 0xff, 0xff, 0x00, //...##.##################........
0x07, 0xff, 0xff, 0xc0, //.....#####################......
0x00, 0x5f, 0xfd, 0xf0, //.........#.###########.#####....
0x00, 0x3c, 0x1e, 0xfe, //..........####.....####.#######.
0x00, 0x7a, 0x2f, 0x00, //.........####.#...#.####........
};
// --------- GAME SPRITES ---------- //
const unsigned char dinoJump [] PROGMEM = { //32x9
0x00, 0x07, 0xc0, 0x60, //.............#####.......##.....
0x00, 0x1f, 0xf1, 0xf0, //...........#########...#####....
0x00, 0x3b, 0xff, 0xb8, //..........###.###########.###...
0x00, 0x7f, 0xdf, 0xfc, //.........#########.###########..
0x00, 0xff, 0xff, 0xd8, //........##################.##...
0x03, 0xff, 0xff, 0xe0, //......#####################.....
0x0f, 0xff, 0xfe, 0x00, //....###################.........
0x7d, 0xf8, 0x1f, 0x00, //.#####.######......#####........
0x03, 0xc0, 0x07, 0x80, //......####...........####.......
};
const unsigned char obstacle1 [] PROGMEM = { //16x6
0x00, 0x00, //................
0x1e, 0x00, //...####.........
0x2f, 0x00, //..#.####........
0x5e, 0x80, //.#.####.#.......
0x5f, 0xc0, //.#.#######......
0xb7, 0xc0, //..##.#####......
};
const unsigned char obstacle2 [] PROGMEM = { //16x6
0x14, 0x00, //...#.#..........
0x08, 0x00, //....#...........
0x52, 0x00, //.#.#..#.........
0x34, 0x00, //..##.#..........
0x69, 0x40, //.##.#..#.#......
0xf0, 0x80, //.###....#.......
};
const unsigned char poop [] PROGMEM = { //16x6
0x80, 0x88, //........#...#...
0x01, 0x81, //.......##......#
0x02, 0xe0, //......#.###.....
0x27, 0x10, //..#..###...#....
0x0b, 0xf0, //....#.######....
0x1c, 0x08, //...###......#...
};
// EATING
const unsigned char eatingTop [] PROGMEM = { //48x21
//0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //................................................
0x00, 0x00, 0x07, 0xfc, 0x00, 0x00, //.....................#########..................
0x00, 0x00, 0x1f, 0xff, 0x00, 0x00, //...................#############................
0x00, 0x00, 0x1f, 0xff, 0x80, 0x00, //...................##############...............
0x00, 0x00, 0x3f, 0xff, 0xe0, 0x00, //..................#################.............
0x00, 0x00, 0x7f, 0xff, 0xf0, 0x00, //.................###################............
0x00, 0x00, 0xff, 0xff, 0xf8, 0x00, //................#####################...........
0x00, 0x01, 0xff, 0xff, 0xfc, 0x00, //...............#######################..........
0x00, 0x03, 0x7c, 0x7f, 0xfe, 0x00, //..............##.#####...##############.........
0x00, 0x02, 0xf9, 0xff, 0xfe, 0x00, //..............#.#####..################.........
0x00, 0x0c, 0xf3, 0xff, 0xff, 0x00, //............##..####..##################........
0x00, 0x1f, 0xf4, 0x7f, 0xff, 0x80, //...........#########.#...################.......
0x00, 0x7f, 0xf0, 0x7f, 0xff, 0xc0, //.........###########.....#################......
0x00, 0xff, 0xf8, 0xff, 0xff, 0xc0, //........#############...##################......
0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, //......####################################......
0x0f, 0xff, 0xff, 0xff, 0xff, 0xe0, //....#######################################.....
0x1f, 0xe7, 0xff, 0xe0, 0xff, 0xe0, //...########..##############.....###########.....
0x3f, 0xdf, 0xff, 0xde, 0xff, 0xf0, //..########.###############.####.############....
0x7f, 0xbf, 0xff, 0xbf, 0x7f, 0xf0, //.########.###############.######.###########....
0x7f, 0x7f, 0xfe, 0x77, 0xbf, 0xf8, //.#######.##############..###.####.###########...
0x7f, 0x7f, 0xf9, 0xf7, 0xbf, 0xfc, //.#######.############..#####.####.############..
0x3f, 0xff, 0xe7, 0xef, 0xbf, 0xfe, //..#################..######.#####.#############.
};
const unsigned char eating1 [] PROGMEM = { //48x18 (48x40 total)
//0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //................................................
//0x00, 0x00, 0x07, 0xfc, 0x00, 0x00, //.....................#########..................
//0x00, 0x00, 0x1f, 0xff, 0x00, 0x00, //...................#############................
//0x00, 0x00, 0x1f, 0xff, 0x80, 0x00, //...................##############...............
//0x00, 0x00, 0x3f, 0xff, 0xe0, 0x00, //..................#################.............
//0x00, 0x00, 0x7f, 0xff, 0xf0, 0x00, //.................###################............
//0x00, 0x00, 0xff, 0xff, 0xf8, 0x00, //................#####################...........
//0x00, 0x01, 0xff, 0xff, 0xfc, 0x00, //...............#######################..........
//0x00, 0x03, 0x7c, 0x7f, 0xfe, 0x00, //..............##.#####...##############.........
//0x00, 0x02, 0xf9, 0xff, 0xfe, 0x00, //..............#.#####..################.........
//0x00, 0x0c, 0xf3, 0xff, 0xff, 0x00, //............##..####..##################........
//0x00, 0x1f, 0xf4, 0x7f, 0xff, 0x80, //...........#########.#...################.......
//0x00, 0x7f, 0xf0, 0x7f, 0xff, 0xc0, //.........###########.....#################......
//0x00, 0xff, 0xf8, 0xff, 0xff, 0xc0, //........#############...##################......
//0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, //......####################################......
//0x0f, 0xff, 0xff, 0xff, 0xff, 0xe0, //....#######################################.....
//0x1f, 0xe7, 0xff, 0xe0, 0xff, 0xe0, //...########..##############.....###########.....
//0x3f, 0xdf, 0xff, 0xde, 0xff, 0xf0, //..########.###############.####.############....
//0x7f, 0xbf, 0xff, 0xbf, 0x7f, 0xf0, //.########.###############.######.###########....
//0x7f, 0x7f, 0xfe, 0x77, 0xbf, 0xf8, //.#######.##############..###.####.###########...
//0x7f, 0x7f, 0xf9, 0xf7, 0xbf, 0xfc, //.#######.############..#####.####.############..
//0x3f, 0xff, 0xe7, 0xef, 0xbf, 0xfe, //..#################..######.#####.#############.
0x5f, 0xfe, 0x1f, 0x1f, 0xbf, 0xff, //.#.############....#####...######.##############
0x67, 0xf1, 0xf9, 0x1f, 0xbf, 0xff, //.##..#######...######..#...######.##############
0x38, 0x0f, 0xe8, 0x3f, 0xbf, 0xff, //..###.......#######.#.....#######.##############
0x1f, 0xff, 0xe0, 0x3f, 0xbf, 0xff, //...################.......#######.##############
0x0e, 0xfe, 0x40, 0xbf, 0x6f, 0xff, //....###.#######..#......#.######.##.############
0x04, 0x54, 0x00, 0xff, 0x57, 0xff, //.....#...#.#.#..........########.#.#.###########
0x00, 0x10, 0x01, 0xfe, 0xab, 0xff, //...........#...........########.#.#.#.##########
0x00, 0x18, 0x01, 0xfd, 0x55, 0xff, //...........##..........#######.#.#.#.#.#########
0x00, 0x18, 0x05, 0xfa, 0xaa, 0xff, //...........##........#.######.#.#.#.#.#.########
0x00, 0x1d, 0x27, 0xf1, 0x55, 0x5f, //...........###.#..#..#######...#.#.#.#.#.#.#####
0x00, 0x0f, 0x7f, 0xe0, 0xaa, 0xaf, //............####.##########.....#.#.#.#.#.#.####
0x00, 0x07, 0xff, 0x80, 0x55, 0x57, //.............############........#.#.#.#.#.#.###
0x00, 0x03, 0xfe, 0x00, 0x2a, 0xab, //..............#########...........#.#.#.#.#.#.##
0x00, 0x01, 0xf0, 0x00, 0x15, 0x55, //...............#####...............#.#.#.#.#.#.#
0x00, 0x00, 0x00, 0x00, 0x0a, 0xaa, //....................................#.#.#.#.#.#.
0x00, 0x00, 0x00, 0x00, 0x05, 0x55, //.....................................#.#.#.#.#.#
0x00, 0x00, 0x00, 0x00, 0x02, 0xaa, //......................................#.#.#.#.#.
0x00, 0x00, 0x00, 0x00, 0x01, 0x55, //.......................................#.#.#.#.#
};
const unsigned char eating2 [] PROGMEM = { //48x18 (48x40 total)
//0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //................................................
//0x00, 0x00, 0x07, 0xfc, 0x00, 0x00, //.....................#########..................
//0x00, 0x00, 0x1f, 0xff, 0x00, 0x00, //...................#############................
//0x00, 0x00, 0x1f, 0xff, 0x80, 0x00, //...................##############...............
//0x00, 0x00, 0x3f, 0xff, 0xe0, 0x00, //..................#################.............
//0x00, 0x00, 0x7f, 0xff, 0xf0, 0x00, //.................###################............
//0x00, 0x00, 0xff, 0xff, 0xf8, 0x00, //................#####################...........
//0x00, 0x01, 0xff, 0xff, 0xfc, 0x00, //...............#######################..........
//0x00, 0x03, 0x7c, 0x7f, 0xfe, 0x00, //..............##.#####...##############.........
//0x00, 0x02, 0xf9, 0xff, 0xfe, 0x00, //..............#.#####..################.........
//0x00, 0x0c, 0xf3, 0xff, 0xff, 0x00, //............##..####..##################........
//0x00, 0x1f, 0xf4, 0x7f, 0xff, 0x80, //...........#########.#...################.......
//0x00, 0x7f, 0xf0, 0x7f, 0xff, 0xc0, //.........###########.....#################......
//0x00, 0xff, 0xf8, 0xff, 0xff, 0xc0, //........#############...##################......
//0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, //......####################################......
//0x0f, 0xff, 0xff, 0xff, 0xff, 0xe0, //....#######################################.....
//0x1f, 0xe7, 0xff, 0xe0, 0xff, 0xe0, //...########..##############.....###########.....
//0x3f, 0xdf, 0xff, 0xde, 0xff, 0xf0, //..########.###############.####.############....
//0x7f, 0xbf, 0xff, 0xbf, 0x7f, 0xf0, //.########.###############.######.###########....
//0x7f, 0x7f, 0xfe, 0x77, 0xbf, 0xf8, //.#######.##############..###.####.###########...
//0x7f, 0x7f, 0xf9, 0xf7, 0xbf, 0xfc, //.#######.############..#####.####.############..
//0x3f, 0xff, 0xe7, 0xef, 0xbf, 0xfe, //..#################..######.#####.#############.
0x5f, 0xfe, 0x1f, 0x1f, 0xbf, 0xff, //.#.############....#####...######.##############
0x67, 0xf1, 0xf9, 0x1f, 0xbf, 0xff, //.##..#######...######..#...######.##############
0x38, 0x0f, 0xe8, 0x3f, 0xbf, 0xff, //..###.......#######.#.....#######.##############
0x1f, 0xff, 0xe1, 0x7f, 0x3f, 0xff, //...################....#.#######..##############
0x0e, 0xfe, 0x41, 0xfe, 0xef, 0xff, //....###.#######..#.....########.###.############
0x04, 0xd4, 0x0b, 0xfd, 0x57, 0xff, //.....#..##.#.#......#.########.#.#.#.###########
0x00, 0xd4, 0x0f, 0xfa, 0xab, 0xff, //........##.#.#......#########.#.#.#.#.##########
0x00, 0x60, 0x9f, 0xf5, 0x55, 0xff, //.........##.....#..#########.#.#.#.#.#.#########
0x00, 0x75, 0xff, 0xca, 0xaa, 0xff, //.........###.#.###########..#.#.#.#.#.#.########
0x00, 0x3f, 0xff, 0x05, 0x55, 0x5f, //..........##############.....#.#.#.#.#.#.#.#####
0x00, 0x1f, 0xfc, 0x02, 0xaa, 0xaf, //...........###########........#.#.#.#.#.#.#.####
0x00, 0x07, 0xc0, 0x01, 0x55, 0x57, //.............#####.............#.#.#.#.#.#.#.###
0x00, 0x00, 0x00, 0x00, 0xaa, 0xab, //................................#.#.#.#.#.#.#.##
0x00, 0x00, 0x00, 0x00, 0x15, 0x55, //...................................#.#.#.#.#.#.#
0x00, 0x00, 0x00, 0x00, 0x0a, 0xaa, //....................................#.#.#.#.#.#.
0x00, 0x00, 0x00, 0x00, 0x05, 0x55, //.....................................#.#.#.#.#.#
0x00, 0x00, 0x00, 0x00, 0x02, 0xaa, //......................................#.#.#.#.#.
0x00, 0x00, 0x00, 0x00, 0x01, 0x55, //.......................................#.#.#.#.#
};
const unsigned char eating3 [] PROGMEM = { //48x18 (48x40 total)
//0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //................................................
//0x00, 0x00, 0x07, 0xfc, 0x00, 0x00, //.....................#########..................
//0x00, 0x00, 0x1f, 0xff, 0x00, 0x00, //...................#############................
//0x00, 0x00, 0x1f, 0xff, 0x80, 0x00, //...................##############...............
//0x00, 0x00, 0x3f, 0xff, 0xe0, 0x00, //..................#################.............
//0x00, 0x00, 0x7f, 0xff, 0xf0, 0x00, //.................###################............
//0x00, 0x00, 0xff, 0xff, 0xf8, 0x00, //................#####################...........
//0x00, 0x01, 0xff, 0xff, 0xfc, 0x00, //...............#######################..........
//0x00, 0x03, 0x7c, 0x7f, 0xfe, 0x00, //..............##.#####...##############.........
//0x00, 0x02, 0xf9, 0xff, 0xfe, 0x00, //..............#.#####..################.........
//0x00, 0x0c, 0xf3, 0xff, 0xff, 0x00, //............##..####..##################........
//0x00, 0x1f, 0xf4, 0x7f, 0xff, 0x80, //...........#########.#...################.......
//0x00, 0x7f, 0xf0, 0x7f, 0xff, 0xc0, //.........###########.....#################......
//0x00, 0xff, 0xf8, 0xff, 0xff, 0xc0, //........#############...##################......
//0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, //......####################################......
//0x0f, 0xff, 0xff, 0xff, 0xff, 0xe0, //....#######################################.....
//0x1f, 0xe7, 0xff, 0xe0, 0xff, 0xe0, //...########..##############.....###########.....
//0x3f, 0xdf, 0xff, 0xde, 0xff, 0xf0, //..########.###############.####.############....
//0x7f, 0xbf, 0xff, 0xbf, 0x7f, 0xf0, //.########.###############.######.###########....
//0x7f, 0x7f, 0xfe, 0x77, 0xbf, 0xf8, //.#######.##############..###.####.###########...
//0x7f, 0x7f, 0xf9, 0xf7, 0xbf, 0xfc, //.#######.############..#####.####.############..
//0x3f, 0xff, 0xe7, 0xef, 0xbf, 0xfe, //..#################..######.#####.#############.
0x5f, 0xfe, 0x1f, 0xdf, 0xbf, 0xff, //.#.############....#######.######.##############
0x67, 0xf1, 0xff, 0x3f, 0xbf, 0xff, //.##..#######...#########..#######.##############
0x38, 0x0f, 0xfc, 0xff, 0xbf, 0xff, //..###.......##########..#########.##############
0x1f, 0xff, 0xf3, 0xff, 0x3f, 0xff, //...#################..##########..##############
0x0f, 0xff, 0xcf, 0xfe, 0xef, 0xff, //....##############..###########.###.############
0x00, 0x38, 0x3f, 0xf9, 0x57, 0xff, //..........###.....###########..#.#.#.###########
0x07, 0x83, 0xff, 0xea, 0xab, 0xff, //.....####.....#############.#.#.#.#.#.##########
0x01, 0xff, 0xfe, 0x15, 0x55, 0xff, //.......################....#.#.#.#.#.#.#########
0x00, 0xff, 0xf0, 0x0a, 0xaa, 0xff, //........############........#.#.#.#.#.#.########
0x00, 0x3f, 0xc0, 0x05, 0x55, 0x5f, //..........########...........#.#.#.#.#.#.#.#####
0x00, 0x00, 0x00, 0x02, 0xaa, 0xaf, //..............................#.#.#.#.#.#.#.####
0x00, 0x00, 0x00, 0x05, 0x55, 0x57, //.............................#.#.#.#.#.#.#.#.###
0x00, 0x00, 0x00, 0x02, 0xaa, 0xab, //..............................#.#.#.#.#.#.#.#.##
0x00, 0x00, 0x00, 0x01, 0x55, 0x55, //...............................#.#.#.#.#.#.#.#.#
0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, //................................#.#.#.#.#.#.#.#.
0x00, 0x00, 0x00, 0x00, 0x55, 0x55, //.................................#.#.#.#.#.#.#.#
0x00, 0x00, 0x00, 0x00, 0x0a, 0xaa, //....................................#.#.#.#.#.#.
0x00, 0x00, 0x00, 0x00, 0x01, 0x55, //.......................................#.#.#.#.#
};
//const unsigned char apple0 [] PROGMEM = {
const unsigned char apple [] PROGMEM = { //24x24
0x00, 0x01, 0xf0, //...............#####....
0x00, 0x07, 0xe0, //.............######.....
0x00, 0x0f, 0xe0, //............#######.....
0x3f, 0x1f, 0xc0, //..######...#######......
0x00, 0xdf, 0x80, //........##.######.......
0x00, 0x20, 0x00, //..........#.............
0x0f, 0xd7, 0xf0, //....######.#.#######....
0x3f, 0xff, 0xfc, //..####################..
0x7f, 0xff, 0xfe, //.######################.
0x78, 0xff, 0xfe, //.####...###############.
0xf0, 0x7f, 0xff, //.###.....###############
0xe0, 0x7f, 0xff, //.##......###############
0xe0, 0xff, 0xff, //.##.....################
0xf1, 0xff, 0xff, //.###...#################
0xff, 0xff, 0xff, //.#######################
0xff, 0xff, 0xff, //.#######################
0xff, 0xff, 0xff, //.#######################
0xff, 0xff, 0xff, //.#######################
0x7f, 0xff, 0xfe, //.######################.
0x7f, 0xff, 0xfe, //.######################.
0x3f, 0xff, 0xfc, //..####################..
0x1f, 0xff, 0xf8, //...##################...
0x0f, 0xff, 0xf0, //....################....
0x07, 0xc3, 0xe0, //.....#####....#####.....
};
const unsigned char steak [] PROGMEM = { //24x24
0x0f, 0xe0, 0x00, //....#######.............
0x3f, 0xf8, 0x00, //..###########...........
0x0f, 0xe0, 0x00, //....#######.............
0x3f, 0xf8, 0x00, //..###########...........
0x31, 0xfe, 0x00, //..##...########.........
0x6e, 0x7f, 0x00, //.##.###..#######........
0xd1, 0x7f, 0x80, //.#.#...#.########.......
0xa0, 0xbf, 0x80, //..#.....#.#######.......
0xa0, 0xbf, 0xc0, //..#.....#.########......
0xa0, 0xbf, 0xc0, //..#.....#.########......
0xd1, 0x3f, 0xc0, //.#.#...#..########......
0xae, 0xff, 0xe0, //..#.###.###########.....
0xd1, 0xff, 0xe0, //.#.#...############.....
0xef, 0xff, 0xe0, //.##.###############.....
0x77, 0xff, 0xf0, //.###.###############....
0x7b, 0xff, 0xd0, //.####.############.#....
0x3d, 0xff, 0x78, //..####.#########.####...
0x1e, 0xf9, 0xfe, //...####.#####..########.
0x0f, 0x67, 0xff, //....####.##..###########
0x07, 0x7f, 0xff, //.....###.###############
0x03, 0x9f, 0xfc, //......###..###########..
0x03, 0xc3, 0xf9, //......####....#######..#
0x01, 0xf8, 0xc3, //.......######...##....##
0x00, 0xff, 0x1e, //........########...####.
0x00, 0x1f, 0xfe, //...........############.
0x00, 0x01, 0xfc, //...............#######..
};
*/
#define WALKSIZE 6
const unsigned char* const dinoWalk[WALKSIZE] PROGMEM = {
//const unsigned char* dinoWalk[WALKSIZE] = {
dinoWalk0, dinoWalk1, dinoWalk2, dinoWalk3, dinoWalk4, dinoWalk5
};
int8_t walkPos = 0;
int walkXPos = 0;
bool walkAnimReverse = false;
bool walkRight = false;
uint8_t walkDirOffset = 2;
const unsigned char* const eating[4] PROGMEM = {
eating1, eating2, eating3, eating2
};
//ground
int grassXPos = 0;
//float treesXPos = -20;
//sky
//float couldsXPos = 0;
const int sunRadius = 3;
bool sunOrMoon = false;
const int moonShadow = 2;
//float sunXPos = -2 * sunRadius;
//clouds
const int cloud1Width = 32;
//float cloud1XPos = displayWidth + cloud1Width;
uint8_t stars [6][2];
// menus
bool menuOpened = false;
uint8_t menu = 0;
uint8_t subMenu = 1;
bool menuDepth = false;
bool justOpened = false;
#define MENUSIZE 8
//#define STRING_SIZE 11
/*
const char mainMenu[MENUSIZE][8][STRING_SIZE] PROGMEM = {
{"food", "apple", "steak", "water", NULL},
{"game", NULL},
{"sleep", NULL},
{"clean", NULL},
{"doctor", NULL},
{"discipline", NULL},
{"stats", "hunger", "happiness", "health", "discipline", "weight", "age", NULL},
{"settings", "sound", "save", NULL},
};
*/
const char t_age[] PROGMEM = "age";
const char t_apple[] PROGMEM = "apple";
const char t_clean[] PROGMEM = "clean";
const char t_discipline[] PROGMEM = "discipline";
const char t_doctor[] PROGMEM = "doctor";
const char t_food[] PROGMEM = "food";
const char t_game[] PROGMEM = "game";
const char t_happiness[] PROGMEM = "happiness";
const char t_health[] PROGMEM = "health";
const char t_hunger[] PROGMEM = "hunger";
const char t_save[] PROGMEM = "save";
const char t_settings[] PROGMEM = "settings";
const char t_sleep[] PROGMEM = "sleep";
const char t_sound[] PROGMEM = "sound";
const char t_stats[] PROGMEM = "stats";
const char t_steak[] PROGMEM = "steak";
const char t_water[] PROGMEM = "water";
const char t_weight[] PROGMEM = "weight";
const char* const mainMenu[MENUSIZE][8] PROGMEM = {
{t_food, t_apple, t_steak, t_water, NULL, NULL, NULL, NULL},
{t_game, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
{t_sleep, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
{t_clean, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
{t_doctor, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
{t_discipline, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
{t_stats, t_hunger, t_happiness, t_health, t_discipline, t_weight, t_age, NULL},
{t_settings, t_sound, t_save, NULL, NULL, NULL, NULL, NULL},
};
/* ------- PET STATS ------- */
//float hunger = 100; // = EEPROM.read(hunger_address);
//float happiness = 100; // = EEPROM.read(happiness_address);
//float health = 100; // = EEPROM.read(health_address);
//float discipline = 100; // = EEPROM.read(discipline_address);
//float weight = 1; // = EEPROM.read(weight_address);
//float age = 0; // = EEPROM.read(age_address);
//settings
bool soundEnabled = true;
int action = 0;
int setting = 0;
bool notification = false;
int notificationBlink = 0;
bool dead = false;
bool sleeping = false;
//game
bool game = false;
bool paused = false;
bool gameOver = false;
int score = 0;
int hiScore = 0; //// = EEPROM.read(hi_address);
int level = 0;
bool newHiScore = false;
bool jumping = false;
bool jumpUp = true;
int jumpPos = 0;
bool obstacle1show = false;
bool obstacle2show = false;
int obstacle1XPos = 0;
int obstacle2XPos = 0;
//float poopometer = 0;
uint8_t poops [3] = {
0, 0, 0,
};
#define ACTIVATED LOW
// #############################
struct petStats {
long hunger; //in hundred thousandths
long happiness; //in hundred thousandths
long health; //in hundred thousandths
long discipline; //in hundred thousandths
long weight; //in hundred thousandths
long age; //in millionths
} pet;
const int pet_address = 20;
long poopometerL; //in hundred thousandths
int treesXPosI; //in tenths
int sunXPosI; //in tenths
int cloud1XPosI; //in tenths
void initData() {
//set variables to initial values
//used in setup and when game is reset
////EEPROM.get(pet_address, pet);
pet.hunger = 10000000L;
pet.happiness = 10000000L;
pet.health = 10000000L;
pet.discipline = 10000000L;
pet.weight = 100000L;
pet.age = 0;
poopometerL = 0;
treesXPosI = -200;
sunXPosI = -2 * sunRadius * 10;
cloud1XPosI = 10 * (displayWidth + cloud1Width);
}
// #############################
void setup() {
Serial.begin(115200);
pinMode(button1Pin, INPUT_PULLUP);
pinMode(button2Pin, INPUT_PULLUP);
pinMode(button3Pin, INPUT_PULLUP);
pinMode(soundPin, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
randomSeed(analogRead(0));
initData();
//display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.begin();
display.setBitmapMode(1);
display.setFontMode(1);
//display.setFont(u8g2_font_glcdfont_x1_tr);
display.setFont(u8g2_font_5x7_tr);
// splash
display.clearDisplay();
display.setDrawColor(1);
display.setCursor(0, 0 + yOffset);
display.print(F(" jakobdesign presents"));
display.drawXBMP(15, 25, 48, 24, splash1 );
display.drawXBMP(48, 24, 80, 40, splash2 );
display.sendBuffer();
//splash tone
tone(soundPin, 500, 200);
delay(200);
tone(soundPin, 1000, 200);
delay(400);
tone(soundPin, 700, 200);
delay(200);
tone(soundPin, 1100, 200);
delay(2200);
// end splash
display.clearBuffer();
}
//temp buffer to store incoming data structure
byte buff[sizeof(pet)];
int recvIndx = 0;
unsigned long timer_odesilani = 0;
void loop() {
while (Serial.available()) {
buff[recvIndx] = Serial.read();
recvIndx++;
if (recvIndx = sizeof(buff)) {
memcpy(&pet, &buff, sizeof(pet));
memset(buff, 0, sizeof(buff));
recvIndx = 0;
}
}
if (millis() - timer_odesilani >= 10000) {
Serial.write((uint8_t *)&pet, sizeof(pet));
timer_odesilani = millis();
}
button1State = digitalRead(button1Pin);
button2State = digitalRead(button2Pin);
button3State = digitalRead(button3Pin);
if (!dead) {
/* -------- MODIFY PET STATS -------- */
// TODO: different gradients regarding to age
if (sleeping) {
pet.hunger -= 5;
poopometerL += 5;
if (pet.happiness - 10 > 0) {
pet.happiness -= 10;
}
pet.health -= 5 + countPoops() * 10;
if ((pet.discipline - 10) > 0) {
pet.discipline -= 10;
}
} else {
pet.hunger -= 25;
poopometerL += 25;
if (pet.happiness - 20 > 0) {
pet.happiness -= 20;
}
pet.health -= (10 + countPoops() * 10);
if ((pet.discipline - 20) > 0) {
pet.discipline -= 20;
}
}
pet.age += 25;
////EEPROM.write(age_address, age);
//diarrhea :) for testing
//poopometer+=0.005;
//health-=1;
//health-=countPoops()*0.0001;
//health-=countPoops()*0.05;
if (poopometerL >= 1000000) {
poopometerL = countPoops() * 100000;
poops[(poopometerL + 50000) / 100000] = random(20, displayWidth + 32);
// !!!! check for index out of range
if (soundEnabled) {
tone(soundPin, 200, 50);
}
poopometerL = 0;
}
if (((pet.hunger > 1999975) && (pet.hunger < 2000025)) || ((pet.happiness > 1999980) && (pet.happiness < 2000020)) || (pet.health > 1999990 && pet.health < 2000010)) {
if (soundEnabled) {
tone(soundPin, 200, 50);
}
}
if ((pet.hunger <= 2000000) || (countPoops() > 0) || (pet.happiness <= 2000000) || (pet.health <= 2000000)) {
notification = true;
} else { // ((pet.hunger > 2000000) && countPoops() == 0 && (pet.happiness > 2000000) && pet.health > 2000000) {
notification = false;
digitalWrite(13, LOW);
}
if ((pet.hunger <= 0) || (pet.health <= 0) || (pet.happiness <= 0)) {
dead = true;
if (soundEnabled) {
tone(soundPin, 500, 500);
delay(550);
tone(soundPin, 400, 500);
delay(550);
tone(soundPin, 300, 600);
}
}
display.clearBuffer();
display.setCursor(0, 0 + yOffset);
/* ------- BUTTON PRESS ACTIONS ------- */
/* ------- BUTTON 1 - MENU ------- */
if (button1State == ACTIVATED) {
// JUMP IN GAME
if (game) {
if (!jumping && !paused) {
if (soundEnabled) {
tone(soundPin, 200, 50);
}
jumping = true;
}
} else {
// MENU
if (soundEnabled) {
tone(soundPin, 300, 80);
}
if (!menuOpened) {
menuOpened = true;
} else {
if (menuDepth) {
if ((const char*)pgm_read_ptr(&(mainMenu[menu][subMenu + 1])) == NULL) {
subMenu = 1;
} else {
++subMenu;
}
} else {
if (menu == MENUSIZE - 1) {
menu = 0;
} else {
++menu;
}
if ((const char*)pgm_read_ptr(&(mainMenu[menu][1])) != NULL) {
subMenu = 1;
justOpened = true;
}
}
setting = 100 * (menu + 1) + subMenu;
}
delay(60);
}
}
/* ------- BUTTON 2 - SELECT ------- */
if (button2State == ACTIVATED) {
if (game) {
if (!gameOver) {
paused = !paused;
if (soundEnabled) {
tone(soundPin, 600, 80);
}
delay(60);
}
} else {
if (soundEnabled) {
tone(soundPin, 600, 80);
}
if (menuOpened) {
if ((subMenu != 1) && ((const char*)pgm_read_ptr(&(mainMenu[menu][1])) != NULL)) {
action = 100 * (menu + 1) + subMenu;
}
if ((subMenu == 1) && ((const char*)pgm_read_ptr(&(mainMenu[menu][1])) == NULL)) {
action = 100 * (menu + 1) + subMenu;
}
if ((subMenu == 1) && ((const char*)pgm_read_ptr(&(mainMenu[menu][1])) != NULL) && menuDepth) {
action = 100 * (menu + 1) + subMenu;
}
if ((const char*)pgm_read_ptr(&(mainMenu[menu][1])) != NULL) {
setting = 100 * (menu + 1) + subMenu;
menuDepth = true;
}
//############################## test code
// if ((const char*)pgm_read_ptr(&(mainMenu[menu][1])) == NULL) {
// if (subMenu == 1) {
// action = 100 * (menu + 1) + subMenu;
// }
// } else {
// if (subMenu == 1) {
// if (menuDepth){
// action = 100 * (menu + 1) + subMenu;
// }
// } else {
// action = 100 * (menu + 1) + subMenu;
// }
// setting = 100 * (menu + 1) + subMenu;
// menuDepth = true;
// }
//##############################
} else {
////action = NULL;
menuOpened = true;
menuDepth = true;
subMenu = 1;
menu = 6;
action = 701;
setting = 701;
}
justOpened = false;
delay(60);
}
}
/* ------- BUTTON 3 - BACK ------- */
if (button3State == ACTIVATED) {
if (soundEnabled) {
tone(soundPin, 1000, 80);
}
if (game || gameOver) {
walkPos = 0;
walkXPos = 0;
walkAnimReverse = false;
walkRight = true;
walkDirOffset = 0;
treesXPosI = -200;
grassXPos = 0;
obstacle1show = false;
obstacle2show = false;
jumping = false;
jumpPos = 0;
jumpUp = true;
game = false;
score = 0;
newHiScore = false;
gameOver = false;
level = 0;
paused = false;
} else {
if (!menuDepth) {
menuOpened = false;
menu = 0;
setting = 0;
} else {
menuDepth = false;
setting = 100 * (menu + 1) + 1;
}
////action = NULL;
action = 0;
subMenu = 1;
}
delay(60);
}
/* ------- SCENERY AND WALKING ------- */
//draw sun
sunXPosI += 1;
if (sunXPosI > (10 * (displayWidth + 2 * sunRadius))) {
sunXPosI = -2 * sunRadius * 10;
sunOrMoon = !sunOrMoon;
}
if (sleeping) {
sunOrMoon = true;
}
display.drawDisc((sunXPosI / 10), 2 * sunRadius, sunRadius);
if (sunOrMoon) {
display.setDrawColor(0);
display.drawDisc((sunXPosI / 10 - moonShadow), 2 * sunRadius, sunRadius);
display.setDrawColor(1);
if ( ((cloud1XPosI + 5) / 10) % 5 == 0) {
for (int i = 0; i < 6; i++) {
stars[i][0] = random(0, displayWidth);
stars[i][1] = random(0, 10);
}
} else {
for (int i = 0; i < 6; i++) {
display.drawPixel(stars[i][0], stars[i][1]);
}
}
}
//cloud 1
cloud1XPosI -= 3;
if (cloud1XPosI < (-cloud1Width * 10)) {
cloud1XPosI = 10 * (displayWidth + cloud1Width);
}
display.drawXBMP((cloud1XPosI / 10), 5, cloud1Width, 5, cloud2 );
//mountains
display.drawXBMP(0, 7, 128, 16, mountains );
//walk and move ground perspective
if (game) {
/* ------ GAME -----*/
level = round(score / 10);
if (jumping && !gameOver && !paused) {
if (jumpUp) {
jumpPos = jumpPos + 1 + level;
if (jumpPos >= 12) {
jumpUp = false;
}
} else {
jumpPos = jumpPos - 1 - level;
if (jumpPos <= 0) {
jumpUp = true;
jumping = false;
if (soundEnabled) {
tone(soundPin, 100, 50);
}
score += 1;
}
}
}
if (!gameOver && !paused) {
if (walkAnimReverse) {
walkPos -= 1;
if (walkPos == -1) {
walkPos = 0;
walkAnimReverse = false;
}
} else {
walkPos += 1;
if (walkPos == 3) {
walkPos = 2;
walkAnimReverse = true;
}
}
walkXPos += 2;
grassXPos += 4;
treesXPosI = treesXPosI + 10 + level * 10;
obstacle1XPos = obstacle1XPos + 2 + level;
obstacle2XPos = obstacle2XPos + 2 + level;
if (!jumping &&
(
(obstacle1show && displayWidth - obstacle1XPos >= 20 && displayWidth - obstacle1XPos <= 46)
||
(obstacle2show && displayWidth - obstacle2XPos >= 20 && displayWidth - obstacle2XPos <= 46)
)
) {
gameOver = true;
jumping = true;
jumpPos = -2;
if (soundEnabled) {
tone(soundPin, 500, 40);
delay(50);
tone(soundPin, 350, 40);
delay(50);
tone(soundPin, 200, 60);
}
if (score > hiScore) {
hiScore = score;
////EEPROM.write(hi_address, hiScore);
newHiScore = true;
}
if ((pet.happiness + 1500000) < 10000000) {
pet.happiness += 1500000;
} else {
pet.happiness = 10000000;
}
pet.health -= 100000;
if ((pet.weight - score * 250) > 500000) {
pet.weight -= score * 250;
////EEPROM.write(weight_address, weight);
}
}
}
if (walkXPos == displayWidth) {
walkXPos = 0;
}
if (grassXPos == displayWidth) {
grassXPos = 0;
}
if (treesXPosI >= (displayWidth * 10)) {
treesXPosI = -1280;
}
if (jumping) {
display.drawXBMP(18, 41 - jumpPos, 32, 9, dinoJump );
} else {
display.drawXBMP(18, 41, 32, 9, (const unsigned char*)pgm_read_ptr(&dinoWalk[walkPos]) );
}
for (int i = 0; i < displayWidth / 4 + 1; i++) {
display.drawXBMP(-walkXPos + i * 8, 50, 8, 6, grass );
}
// obstacles 1
if (obstacle1XPos - 16 >= displayWidth) {
obstacle1XPos = 0;
obstacle1show = false;
}
if (!obstacle1show && random(1, 10) == 1 && obstacle2XPos > 40) {
obstacle1show = true;
obstacle1XPos = 0;
}
if (obstacle1show) {
display.drawXBMP(displayWidth - obstacle1XPos, 44, 16, 6, obstacle1 );
}
// obstacles 2
if (obstacle2XPos - 16 >= displayWidth) {
obstacle2XPos = 0;
obstacle2show = false;
}
if (!obstacle2show && random(1, 10) == 1 && obstacle1XPos > 40) {
obstacle2show = true;
obstacle2XPos = 0;
}
if (obstacle2show) {
display.drawXBMP(displayWidth - obstacle2XPos, 44, 16, 6, obstacle2 );
}
//draw front grass
for (int i = 0; i < displayWidth / 16 + 1; i++) {
display.drawXBMP(-grassXPos + i * 32, 60, 32, 8, grass_front );
}
//draw trees
display.drawXBMP((-treesXPosI / 10), 23, 112, 20, trees );
if (!gameOver) {
display.setCursor(0, 56 + yOffset);
display.setDrawColor(1);
display.print(F("lvl: "));
display.print(level);
display.setCursor(64, 56 + yOffset);
display.setDrawColor(1);
display.print(F("pts: "));
display.print(score);
}
if (paused && ((((cloud1XPosI + 5) / 10) % 2) == 0)) {
display.setDrawColor(0);
display.drawBox(24, 11, 80, 15);
display.setDrawColor(1);
display.drawBox(25, 12, 78, 13);
display.setCursor(47, 15 + yOffset);
display.setDrawColor(0);
display.println(F("PAUSED"));
}
/* ---------- END GAME ----------*/
} else {
/* ------ NO GAME -----*/
if (!sleeping) {
display.drawXBMP(walkXPos + 8, 41, 32, 9, (const unsigned char*)pgm_read_ptr(&dinoWalk[walkPos + walkDirOffset]) );
} else {
display.drawXBMP(walkXPos + 8, 44, 32, 9, (const unsigned char*)pgm_read_ptr(&dinoWalk[walkPos + walkDirOffset]) );
if (walkRight) {
if ((((cloud1XPosI + 5) / 10) % 3) == 0) {
display.setCursor(walkXPos + 48, 36 + yOffset);
display.print(F("Z"));
} else {
display.setCursor(walkXPos + 46, 38 + yOffset);
display.print(F("z"));
}
} else {
if ((((cloud1XPosI + 5) / 10) % 3) == 0) {
display.setCursor(walkXPos - 4, 36 + yOffset);
display.print(F("Z"));
} else {
display.setCursor(walkXPos - 2, 38 + yOffset);
display.print(F("z"));
}
}
}
if (walkRight) {
if (!sleeping) {
walkXPos += 1;
grassXPos += 2;
treesXPosI += 5;
}
if (walkXPos > 80) {
walkRight = false;
walkDirOffset = 3;
}
} else {
if (!sleeping) {
walkXPos -= 1;
grassXPos -= 2;
treesXPosI -= 5;
}
if (walkXPos < 0) {
walkRight = true;
walkDirOffset = 0;
}
}
//draw grass (ground)
for (int i = 0; i < 2 * displayWidth / 4; i++) {
display.drawXBMP(-walkXPos + i * 8, 50, 8, 6, grass );
}
// draw poops
for (int i = 0; i < 3; i++) {
if (poops[i] > 0) {
display.drawXBMP(-walkXPos + poops[i], 44, 16, 6, poop );
}
}
//draw front grass
for (int i = 0; i < 2 * displayWidth / 16; i++) {
display.drawXBMP(-grassXPos + i * 32, 56, 32, 8, grass_front );
}
//draw trees
display.drawXBMP((-treesXPosI / 10), 23, 112, 20, trees );
if (!sleeping) {
if (walkAnimReverse) {
--walkPos;
if (walkPos == -1) {
walkPos = 0;
walkAnimReverse = false;
}
} else {
++walkPos;
if (walkPos == 3) {
walkPos = 2;
walkAnimReverse = true;
}
}
}
}
/* ------- MENUS AND ACTIONS ------- */
//render menu
if (menuOpened and !game) {
display.setDrawColor(0);
display.drawBox(0, 0, displayWidth, 30);
display.setDrawColor(1);
display.drawFrame(0, 0, displayWidth, 29);
display.setDrawColor(0);
display.drawBox(1, 1, displayWidth - 2, 27);
display.setDrawColor(1);
display.drawFrame(0, 0, displayWidth, 12);
display.setCursor(8, 2 + yOffset);
//display.setTextSize(1);
if (menuDepth) {
display.drawBox(0, 0, displayWidth, 12);
display.drawBox(1, 18, 1, 5);
display.drawBox(2, 19, 1, 3);
display.drawBox(3, 20, 1, 1);
////display.setTextColor(BLACK, WHITE);
} else {
display.drawBox(1, 3, 1, 5);
display.drawBox(2, 4, 1, 3);
display.drawBox(3, 5, 1, 1);
display.setDrawColor(1);
}
display.print((__FlashStringHelper*)pgm_read_ptr(&mainMenu[menu][0]));
if (subMenu) {
display.setDrawColor(1);
display.setCursor(8, 16 + yOffset);
// ############ this if statement is a tempory workaround for a program error
// ############ original code always prints submenu
// ############ with original mainMenu array null characters prevented actually printing anything
// ############ the current mainMenu array actually contains a NULL pointer, which causes random printing
if (pgm_read_ptr(&mainMenu[menu][subMenu]) != NULL){
display.print((__FlashStringHelper*)pgm_read_ptr(&mainMenu[menu][subMenu]));
}
}
}
//do actions
if (action > 0) {
if ( ((action == 101) || (action == 102) || (action == 103)) && (!sleeping) && (random(1, (11 - ((pet.discipline + 500000) / 1000000))) == 1) ) {
//if ((action == 101 || action == 102 || action == 103) && !sleeping && random(1, (11 - round(discipline / 10))) == 1 ) {
//95-100 discipline = 100% chance to feed
//85-95 discipline = 50% chance
//75-85 discipline = 33.33% chance
//65-75 discipline = 25% chance
//55-65 discipline = 20% chance
//45-55 discipline = 16.67% chance
//35-45 discipline = 14.28% chance
//25-35 discipline = 12.5% chance
//15-25 discipline = 12.5% chance
//5-15 discipline = 10% chance
//0-5 discipline = 9% chance
//animate eating
display.setDrawColor(0);
display.drawBox(0, 0, displayWidth, displayHeight);
display.setDrawColor(1);
for (int j = 0; j < 3; j++) {
for (int i = 0; i < 4; i++) {
display.clearBuffer();
switch (action) {
case 101:
//apple
display.drawXBMP(50, 40, 24, 24, apple);
display.setDrawColor(0);
if (j > 0) display.drawDisc(76, 54, 12);
if (j == 2) display.drawDisc(47, 55, 12);
display.setDrawColor(1);
break;
case 102:
//steak
display.drawXBMP(50, 40, 24, 24, steak);
display.setDrawColor(0);
if (j > 0) display.drawDisc(76, 59, 13);
if (j == 2) display.drawDisc(60, 63, 13);
display.setDrawColor(1);
break;
case 103:
//water ripples
display.drawCircle(80, 55, 1 + 1 * i);
display.drawCircle(80, 55, 5 + 2 * i);
display.drawCircle(80, 55, 10 + 4 * i);
break;
}
display.drawXBMP(80, 25, 48, 21, eatingTop);
display.drawXBMP(80, 46, 48, 18, (const unsigned char*)pgm_read_ptr(&eating[i]));
delay(150);
display.sendBuffer();
}
}
switch (action) {
//apple
case 101:
if ((pet.hunger + 1000000) > 10000000) {
pet.hunger = 10000000;
pet.weight += 100000;
} else {
pet.hunger += 1000000;
}
if ((pet.health + 100000) <= 10000000) {
pet.health += 100000;
}
poopometerL += 2000;
break;
//steak
case 102:
if (pet.hunger + 2000000 > 10000000) {
pet.hunger = 10000000;
pet.weight += 200000;
} else {
pet.hunger += 2000000;
pet.weight += 100000;
}
if ((pet.health - 100000) > 0) {
pet.health -= 100000;
}
poopometerL += 5000;
break;
//water
case 103:
if (pet.hunger + 500000 <= 10000000) {
pet.hunger += 500000;
}
poopometerL += 1000;
break;
}
} else {
if (action == 101 || action == 102 || action == 103) {
if (soundEnabled) {
tone(soundPin, 500, 200);
delay(250);
}
}
}
switch (action) {
case 201:
//game
if (!sleeping && (pet.health > 2000000)) {
game = true;
walkPos = 0;
walkXPos = 0;
walkAnimReverse = false;
walkRight = false;
walkDirOffset = 2;
treesXPosI = -200;
grassXPos = 0;
}
break;
case 301:
//sleep
sleeping = !sleeping;
if (!sleeping) {
sunOrMoon = false;
} else {
for (int i = 0; i < 6; i++) {
stars[i][0] = random(0, displayWidth);
stars[i][1] = random(0, 10);
}
}
break;
case 401:
//bath
resetPoops();
break;
case 501:
//doctor
if (pet.health < 6000000) {
pet.health = 10000000;
for (int i = 0; i < 5; i++) {
display.clearBuffer();
if (i % 2 != 0) {
display.drawBox(32, 23, 64, 16);
display.drawBox(56, 0, 16, 64);
}
display.sendBuffer();
////EEPROM.write(health_address, health);
delay(300);
}
}
break;
case 601:
//discipline
if (action == 601 && !sleeping) {
if ((pet.discipline + 1200000) <= 10000000) {
pet.discipline += 1200000;
} else {
pet.discipline = 10000000;
}
if ((pet.happiness - 300000) > 0) {
pet.happiness -= 300000;
}
delay(150);
////EEPROM.write(happiness_address, happiness);
for (int i = 0; i < 5; i++) {
if (soundEnabled) {
tone(soundPin, 200 * i, 100);
}
display.setCursor(100 + 3 * i, 32 + yOffset);
display.print(F("!"));
display.sendBuffer();
delay(150);
}
}
break;
case 801:
soundEnabled = !soundEnabled;
break;
case 802:
////EEPROM.put(age_address, age);
////EEPROM.put(weight_address, (weight));
////EEPROM.write(hunger_address, hunger);
////EEPROM.write(discipline_address, discipline);
////EEPROM.write(happiness_address, happiness);
////EEPROM.write(health_address, health);
break;
}
action = 0;
}
//display settings
if (setting > 0 and !game) {
display.setCursor(8, 16 + yOffset);
if (setting == 201) {
display.println(F("increase happiness"));
}
if (setting == 301) {
display.println(F("get some rest"));
}
if (setting == 401) {
display.println(F("keep it healthy"));
}
if (setting == 501) {
display.println(F("when health is bad"));
}
if (setting == 601) {
display.println(F("get smarter"));
}
if (setting == 701 || setting == 702 || setting == 703 || setting == 704) {
display.drawFrame(70, 17, 52, 7);
}
if (setting == 701) {
drawBar(pet.hunger);
}
if (setting == 702) {
drawBar(pet.happiness);
}
if (setting == 703) {
drawBar(pet.health);
}
if (setting == 704) {
drawBar(pet.discipline);
}
if (setting == 705 || setting == 706 || setting == 801) {
display.setCursor(80, 16 + yOffset);
}
if (setting == 705) {
display.print(pet.weight / 10000);
display.print('.');
display.print((pet.weight / 1000) % 10);
// !!!! check to see if print() rounds a float
display.println(F(" t"));
}
if (setting == 706) {
display.print(pet.age / 1000000);
display.print('.');
display.print((pet.age / 100000) % 10);
// !!!! check to see if print() rounds floats
display.println(F(" y."));
////EEPROM.write(age_address, age);
}
if (setting == 801) {
if (soundEnabled) {
display.println(F("on"));
} else {
display.println(F("off"));
}
}
if (setting == 802) {
}
}
//display notification
if (notification) {
++notificationBlink;
if (notificationBlink == 10) {
notificationBlink = 0;
}
if (notificationBlink != 1) {
display.drawFrame(117, 28, 11, 11);
display.setDrawColor(1);
digitalWrite(13, LOW);
} else {
display.drawBox(117, 28, 11, 11);
display.setDrawColor(0);
digitalWrite(13, HIGH);
}
display.setCursor(120, 30 + yOffset);
display.println(F("!"));
if (dead) {
digitalWrite(13, LOW);
}
}
// GAME OVER
if (gameOver) {
display.setDrawColor(0);
display.drawBox(15, 11, 98, 43);
display.setDrawColor(1);
display.drawFrame(16, 12, 96, 41);
display.drawBox(16, 12, 96, 13);
display.setCursor(36, 15 + yOffset);
display.setDrawColor(0);
display.println(F("GAME OVER"));
display.setDrawColor(1);
display.setCursor(21, 29 + yOffset);
if (newHiScore) {
display.println(F("NEW HI-SCORE!"));
display.setCursor(21, 40 + yOffset);
} else {
display.println(F("SCORE:"));
display.setCursor(21, 40 + yOffset);
}
display.println(score);
}
display.sendBuffer();
} else {
//dead...
display.clearBuffer();
display.setCursor(0, 0 + yOffset);
display.setDrawColor(1);
display.println(F("Pet died...\n\nPress button 1\nto restart"));
display.sendBuffer();
if (button1State == HIGH) {
if (soundEnabled) {
tone(soundPin, 300, 80);
delay(200);
}
noTone(soundPin);
asm volatile (" jmp 0");
}
}
}
void drawBar(long value) {
//value is number in hundred thousandths
int barWidth = (48 * value / 100000) / 100;
display.drawBox(72, 19, barWidth, 3);
}
int countPoops() {
int poopsCnt = 0;
for (int i = 0; i < 3; i++) {
if (poops[i] > 0) {
++poopsCnt;
}
}
return poopsCnt;
}
void resetPoops() {
for (int i = 0; i < 3; i++) {
poops[i] = 0;
}
}