Last active
July 17, 2019 17:10
-
-
Save shikarunochi/a983427d583ce6576fd07731beee3488 to your computer and use it in GitHub Desktop.
おきらくごくらく
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <M5Stack.h> | |
TFT_eSprite img = TFT_eSprite(&M5.Lcd); | |
int cgData[]={CYAN,0,110,0,152,51,60,44,117,112,132,109,198,156,58,162,138,211,132,201,198,257,57,271,130,319,112,319,195,-1,-1, | |
GREEN,0,200,0,103,29,203,41,142,89,138,99,67,137,188,139,135,184,118,196,57,232,193,246,135,319,118,319,37,-1,-1, | |
GREEN,0,51,0,114,99,104,117,199,174,27,194,121,319,124,319,222,-1,-1, | |
DARKCYAN, 0,121,0,96,22,109,35,56,47,166,55,116,68,134,83,54,85,184,100,116,125,117,147,49,148,174,162,101,183,124,193,41,208,176,217,107,233,129,252,54,257,191,271,112,319,97,319,17,-1,-1, | |
WHITE,0,141,0,86,59,172,89,112,156,121,169,56,206,177,229,131,319,132,319,59,-1,-1, | |
GREEN,0,152,0,84,83,182,100,137,223,129,228,52,319,186,319,129,-1,-1, | |
OLIVE,0,124,0,86,23,112,29,69,51,132,53,94,87,110,87,68,119,122,127,94,157,106,159,68,185,118,187,94,219,98,223,58,245,126,259,94,287,110,289,74,319,130,319,106,-1,-1, | |
YELLOW,0,152,0,106,136,182,146,134,226,140,230,82,319,186,319,128,-1,-1, | |
RED,0,125,0,105,38,119,42,77,84,135,76,77,144,133,166,99,212,159,222,129,266,157,319,135,319,153,-1,-1, | |
WHITE,0,153,0,95,74,193,98,139,184,139,200,93,230,191,260,141,319,163,319,115,-1,-1, | |
RED,0,176,0,106,102,118,132,32,196,202,210,94,270,146,260,38,319,170,319,76,-1,-1, | |
PURPLE,0,129,0,73,96,145,100,101,158,97,178,73,248,101,238,81,292,87,294,59,319,99,319,71,-1,-1, | |
YELLOW,0,140,0,118,66,168,98,138,130,138,170,106,200,158,224,134,280,156,270,114,319,166,319,128,-999,-999 | |
}; | |
void setup() { | |
Serial.begin(115200); // SERIAL | |
M5.begin(); // M5STACK INITIALIZE | |
int delayMSEC = 10; | |
img.setColorDepth(8); | |
img.createSprite(320, 240); | |
img.fillSprite(TFT_BLUE); | |
img.pushSprite(0, 0); | |
delay(4000); | |
int x0 = -1; | |
int y0 = -1; | |
int x1 = -1; | |
int y1 = -1; | |
int x2 = -1; | |
int y2 = -1; | |
int color = 0; | |
int index = 0; | |
for(int count = 0;count <1;count++){ | |
while(1){ | |
img.fillSprite(TFT_BLUE); | |
//1つ目は色 | |
color = cgData[index];index++; | |
//0未満なら終わり | |
if(color < 0){break;} | |
//頂点1つ目 | |
x0 = cgData[index];index++; | |
y0 = cgData[index];index++; | |
//頂点2つ目 | |
x1 = cgData[index];index++; | |
y1 = cgData[index];index++; | |
while(1){ | |
//頂点0未満なら終わり | |
x2 = cgData[index];index++; | |
y2 = cgData[index];index++; | |
if(x2 < 0){ | |
break; | |
} | |
img.fillTriangle(x0, y0, x2, y2, x1, y1, color); | |
x0 = x1; | |
y0 = y1; | |
x1 = x2; | |
y1 = y2; | |
} | |
img.pushSprite(0, 0); | |
delay(20); | |
if(x2 < -100){ | |
break; | |
} | |
} | |
} | |
for(int y = 0; y <= 420; y = y + 60){ | |
drawInitialFace(y, 0, 0, 1); | |
delay(delayMSEC); | |
} | |
delay(delayMSEC * 10); | |
for(int y = 420; y >= 240; y = y - 60){ | |
drawInitialFace(y, 0, 20, 1); | |
delay(delayMSEC); | |
} | |
delay(delayMSEC * 10); | |
//素の表情 | |
drawFace(0, 0, 2); | |
delay(delayMSEC * 100); | |
drawFace(-20, 0, 1); | |
delay(delayMSEC * 200); | |
drawFace(-20, 0, 1); | |
drawFace(-10, 0, 0); | |
delay(100); | |
drawFace(10, 0, 0); | |
delay(100); | |
drawFace(0, 0, 1); | |
delay(100); | |
drawFace(0, 0, 0); | |
delay(100); | |
drawFace(-10, 0, 0); | |
delay(100); | |
drawFace(-10, 0, 0); | |
delay(100); | |
drawFace(0, 0, 1); | |
delay(100); | |
drawFace(0, 0, 1); | |
delay(100); | |
drawFace(-10, 0, 2); | |
delay(100); | |
drawFace(-10, 0, 2); | |
delay(100); | |
drawFace(20, 0, 0); | |
delay(1000); | |
drawFace(-20, 0, 1); | |
delay(1000); | |
drawFace(0, 0, 0); | |
drawFace(-10, 0, 0); | |
delay(100); | |
drawFace(10, 0, 0); | |
delay(100); | |
drawFace(0, 0, 1); | |
delay(100); | |
drawFace(0, 0, 0); | |
delay(100); | |
drawFace(-10, 0, 0); | |
delay(100); | |
drawFace(-10, 0, 0); | |
delay(100); | |
drawFace(0, 0, 1); | |
delay(100); | |
drawFace(0, 0, 1); | |
delay(100); | |
drawFace(0, 0, 2); | |
} | |
void drawInitialFace(int y,int blackEyeOffsetX,int blackEyeOffsetY, int mouthType){ | |
//mouthType: 0:普通 1:びっくり 2:素 | |
img.fillRect(0,0,320,y, BLUE); | |
//上の黒線 | |
img.fillRect(0,y - 240 - 30,320, 30, BLACK); | |
//下の黒線 | |
img.fillRect(0,y,320,30, BLACK); | |
//口を書く | |
switch(mouthType){ | |
case 0: | |
img.fillRect(122, 182, 73, 5, CYAN); | |
img.fillRect(118, 178, 4, 4, CYAN); | |
img.fillRect(195, 178, 4, 4, CYAN); | |
break; | |
case 1: | |
img.drawRoundRect(143, 145 + y - 240, 32, 68, 5, CYAN); | |
img.drawRoundRect(142, 144 + y - 240, 34, 70, 5, CYAN); | |
img.drawRoundRect(141, 143 + y - 240, 36, 72, 5, CYAN); | |
break; | |
case 2: | |
img.fillRect(122, 182, 73, 5, CYAN); | |
break; | |
} | |
//目 | |
img.fillCircle(84, 105 + y - 240, 44, WHITE); | |
img.fillCircle(236, 105 + y - 240, 44, WHITE); | |
img.fillCircle(84 + blackEyeOffsetX, 105 + y - 240 + blackEyeOffsetY, 17, BLACK); | |
img.fillCircle(236 + + blackEyeOffsetX, 105 + y - 240 + blackEyeOffsetY, 17, BLACK); | |
img.pushSprite(0, 0); | |
} | |
void drawFace(int blackEyeOffsetX,int blackEyeOffsetY, int mouthType){ | |
drawInitialFace(240, blackEyeOffsetX, blackEyeOffsetY, mouthType); | |
} | |
void loop(){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment