Compare commits
2 Commits
9afc60eab5
...
1c40ff7081
Author | SHA1 | Date |
---|---|---|
valvin | 1c40ff7081 | |
valvin | 8474863782 |
27
README.md
27
README.md
|
@ -1,2 +1,27 @@
|
||||||
# carrot-game
|
# Carrot Game
|
||||||
|
|
||||||
|
Famous Carrot in [Pepper&Carrot webcomics](https://peppercarrot.com) is very hungry.
|
||||||
|
|
||||||
|
In this game he has to eat as fishes as possible.
|
||||||
|
|
||||||
|
Each eaten fish brings 10 points but same for those missed.
|
||||||
|
|
||||||
|
You can miss 5 fishes but you lose if you have no point left.
|
||||||
|
|
||||||
|
## Hardware
|
||||||
|
|
||||||
|
- Arduino Uno R3
|
||||||
|
- LCD 128x64 with DFRobot SPI module
|
||||||
|
- WiiChuck PCB to connect a Wii chuck
|
||||||
|
- Speaker
|
||||||
|
|
||||||
|
## Pin connection
|
||||||
|
|
||||||
|
- A2, A3, A4 and A5: WiiChuck
|
||||||
|
- D2 (CLK), D10 (DATA), D7 (CS): LCD SPI
|
||||||
|
- D8 Speaker +
|
||||||
|
|
||||||
|
## Libraries
|
||||||
|
|
||||||
|
- [U8g2](https://github.com/olikraus/u8g2/wiki) to manage LCD graphics
|
||||||
|
- ArdunoNunchuck by Gabriel Bianconi
|
|
@ -11,3 +11,7 @@ PROGMEM const unsigned char fish_reverse[] {
|
||||||
0x00, 0x00, 0x00, 0x04, 0x00, 0x06, 0xc0, 0x07, 0xe0, 0x07, 0xf8, 0x67,
|
0x00, 0x00, 0x00, 0x04, 0x00, 0x06, 0xc0, 0x07, 0xe0, 0x07, 0xf8, 0x67,
|
||||||
0xec, 0x7f, 0xfe, 0x3f, 0xfc, 0x3f, 0xf8, 0x77, 0xf0, 0x67, 0xe0, 0x07,
|
0xec, 0x7f, 0xfe, 0x3f, 0xfc, 0x3f, 0xf8, 0x77, 0xf0, 0x67, 0xe0, 0x07,
|
||||||
0x00, 0x0e, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00 };
|
0x00, 0x0e, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00 };
|
||||||
|
|
||||||
|
PROGMEM const unsigned char heart[]{
|
||||||
|
0x1b,0x1b,0x1f,0x1f,0x0e
|
||||||
|
};
|
|
@ -107,7 +107,7 @@ void display_welcome_page() {
|
||||||
void display_game() {
|
void display_game() {
|
||||||
u8g2.setFont(u8g2_font_4x6_tf);
|
u8g2.setFont(u8g2_font_4x6_tf);
|
||||||
u8g2.drawStr(108, 50, "SCORE:");
|
u8g2.drawStr(108, 50, "SCORE:");
|
||||||
u8g2.drawStr(108, 30, "LIVES:");
|
//u8g2.drawStr(108, 30, "LIVES:");
|
||||||
u8g2.drawStr(108, 10, "MAX:");
|
u8g2.drawStr(108, 10, "MAX:");
|
||||||
//draw score
|
//draw score
|
||||||
u8g2.setFont(u8g2_font_5x7_mf);
|
u8g2.setFont(u8g2_font_5x7_mf);
|
||||||
|
@ -116,8 +116,17 @@ void display_game() {
|
||||||
u8g2.drawStr(110, 62, num_str);
|
u8g2.drawStr(110, 62, num_str);
|
||||||
sprintf(num_str, "%03d", max_score);
|
sprintf(num_str, "%03d", max_score);
|
||||||
u8g2.drawStr(110, 20, num_str);
|
u8g2.drawStr(110, 20, num_str);
|
||||||
sprintf(num_str, "%03d", lives);
|
short y = 0;
|
||||||
u8g2.drawStr(110, 40, num_str);
|
short x = 0;
|
||||||
|
for(int i = 0; i < lives; i++){
|
||||||
|
if (i % 3 == 0){
|
||||||
|
y = y +1;
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
u8g2.drawXBMP(110 + 6 * x, 20 + 6 * y, 5, 5, heart);
|
||||||
|
x = x + 1;
|
||||||
|
}
|
||||||
|
|
||||||
//draw fishes
|
//draw fishes
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
if(fishes[i][0] != NULL){
|
if(fishes[i][0] != NULL){
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#define _width 5
|
||||||
|
#define _height 5
|
||||||
|
static char _bits[] = {
|
||||||
|
0x1b,0x1b,0x1f,0x1f,0x0e };
|
Loading…
Reference in New Issue