update Stick Man

GameStickMan
CalisJI 2024-08-14 14:56:43 +07:00
parent 300e50e281
commit 02223a7c77
2 changed files with 382 additions and 183 deletions

43
src/index.html Normal file
View File

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<style>
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #f0f0f0;
}
.container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.checkbox-group {
margin-bottom: 20px;
display: flex;
flex-direction: row;
}
.checkbox-group label {
display: block;
margin-bottom: 10px;
}
</style>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Checkbox Example</title>
</head>
<body>
<div class="container">
<div class="checkbox-group">
<label><input type="checkbox" id="auto" onchange="updateCheckbox('auto')"> Mode</label>
</div>
</div>
</body>
</html>

View File

@ -55,139 +55,143 @@ bool gen_moi = false;
unsigned long period_time = millis(); unsigned long period_time = millis();
const char CAT_bits[] PROGMEM = { const char CAT_bits[] PROGMEM = {
0xc8, 0x7c, 0x7c, 0x00, 0xc8, 0x7c, 0x7c, 0x00, 0xc8, 0x7c, 0x7c, 0x00, 0xc8, 0x7c, 0x7c, 0x00, 0xc8, 0x7c, 0x7c, 0x00, 0xc8, 0x7c, 0x7c, 0x00, 0xc8, 0x7c, 0x7c, 0x00, 0xc8, 0x7c, 0x7c, 0x00,
0x88, 0xfc, 0x3c, 0x00, 0x70, 0xbc, 0x5c, 0x00, 0x70, 0xbc, 0x5c, 0x00, 0x08, 0x7c, 0x3c, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0x70, 0xbc, 0x5c, 0x00, 0x70, 0xbc, 0x5c, 0x00, 0x08, 0x7c, 0x3c, 0x00,
0x88, 0xfc, 0x3c, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0x88, 0xf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0x70, 0xbc, 0x5c, 0x00, 0xff, 0x2f, 0xef, 0x00, 0x01, 0x8d, 0xb9, 0x00, 0x3f, 0xcf, 0x9f, 0x00, 0x70, 0xbc, 0x5c, 0x00,
0x68, 0xfc, 0xfc, 0x00, 0x68, 0x02, 0x02, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0x02, 0x02, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00,
0x48, 0xbc, 0xbc, 0x00, 0x68, 0x02, 0x02, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0xa8, 0x02, 0x02, 0x00, 0x48, 0xbc, 0xbc, 0x00, 0x68, 0x02, 0x02, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0xa8, 0x02, 0x02, 0x00,
0x28, 0xfc, 0xfc, 0x00, 0x51, 0x59, 0x79, 0x00, 0xb3, 0x39, 0x02, 0x00, 0xfd, 0x99, 0xda, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0x51, 0x59, 0x79, 0x00, 0xb3, 0x39, 0x02, 0x00, 0xfd, 0x99, 0xda, 0x00,
0xfe, 0x15, 0xd9, 0x00, 0xdd, 0x33, 0xa3, 0x00, 0xdd, 0x33, 0xa3, 0x00, 0x03, 0xd3, 0x13, 0x00, 0xfe, 0x15, 0xd9, 0x00, 0xdd, 0x33, 0xa3, 0x00, 0xdd, 0x33, 0xa3, 0x00, 0x03, 0xd3, 0x13, 0x00,
0x93, 0x15, 0x86, 0x00, 0xe3, 0x41, 0x44, 0x00, 0xff, 0x8f, 0x9f, 0x00, 0x48, 0xbc, 0xbc, 0x00, 0x93, 0x15, 0x86, 0x00, 0xe3, 0x41, 0x44, 0x00, 0xff, 0x8f, 0x9f, 0x00, 0x48, 0xbc, 0xbc, 0x00,
0x28, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0xa8, 0x3c, 0xbc, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0xa8, 0x3c, 0xbc, 0x00,
0x48, 0xbc, 0xbc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0x48, 0xbc, 0xbc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0xfc, 0xfc, 0x00,
0xa8, 0x02, 0x02, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0x25, 0x47, 0x0f, 0x00, 0x01, 0x95, 0x39, 0x00, 0xa8, 0x02, 0x02, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0x25, 0x47, 0x0f, 0x00, 0x01, 0x95, 0x39, 0x00,
0x41, 0x15, 0xb9, 0x00, 0x21, 0x95, 0xf9, 0x00, 0x21, 0x55, 0xb9, 0x00, 0x21, 0x55, 0xb9, 0x00, 0x41, 0x15, 0xb9, 0x00, 0x21, 0x95, 0xf9, 0x00, 0x21, 0x55, 0xb9, 0x00, 0x21, 0x55, 0xb9, 0x00,
0x61, 0xd5, 0x39, 0x00, 0x95, 0x93, 0x23, 0x00, 0x08, 0xbc, 0x5c, 0x00, 0x28, 0x3c, 0xbc, 0x00, 0x61, 0xd5, 0x39, 0x00, 0x95, 0x93, 0x23, 0x00, 0x08, 0xbc, 0x5c, 0x00, 0x28, 0x3c, 0xbc, 0x00,
0xa8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00,
0x48, 0xbc, 0xbc, 0x00, 0x28, 0x7c, 0x82, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x02, 0x02, 0x00, 0x48, 0xbc, 0xbc, 0x00, 0x28, 0x7c, 0x82, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x02, 0x02, 0x00,
0x68, 0xfc, 0xfc, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0x08, 0xdc, 0x9c, 0x00, 0xc1, 0x95, 0x79, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0x08, 0xdc, 0x9c, 0x00, 0xc1, 0x95, 0x79, 0x00,
0x61, 0x35, 0x85, 0x00, 0x61, 0x35, 0x85, 0x00, 0x91, 0xf5, 0x25, 0x00, 0x61, 0x35, 0x85, 0x00, 0x61, 0x35, 0x85, 0x00, 0x61, 0x35, 0x85, 0x00, 0x91, 0xf5, 0x25, 0x00, 0x61, 0x35, 0x85, 0x00,
0x61, 0xd5, 0x79, 0x00, 0x90, 0x9c, 0x1c, 0x00, 0x08, 0xbc, 0x5c, 0x00, 0xc8, 0x7c, 0x7c, 0x00, 0x61, 0xd5, 0x79, 0x00, 0x90, 0x9c, 0x1c, 0x00, 0x08, 0xbc, 0x5c, 0x00, 0xc8, 0x7c, 0x7c, 0x00,
0x28, 0xfc, 0xfc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00,
0x48, 0xbc, 0xbc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0x48, 0xbc, 0xbc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x28, 0xfc, 0xfc, 0x00,
0x28, 0x7c, 0x82, 0x00, 0x88, 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6a, 0x90, 0x00, 0x70, 0x70, 0x70, 0x00,
0x90, 0xe0, 0x20, 0x00, 0xf9, 0x89, 0x75, 0x00, 0x88, 0x02, 0x3c, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0x90, 0xe0, 0x20, 0x00, 0xf9, 0x89, 0x75, 0x00, 0x88, 0x02, 0x3c, 0x00, 0x28, 0xfc, 0xfc, 0x00,
0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0x3c, 0xbc, 0x00, 0x28, 0x3c, 0xbc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0x3c, 0xbc, 0x00, 0x28, 0x3c, 0xbc, 0x00,
0x48, 0xbc, 0xbc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x48, 0xbc, 0xbc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00,
0x68, 0x42, 0x82, 0x00, 0xc8, 0x82, 0x02, 0x00, 0x08, 0x82, 0xbc, 0x00, 0x50, 0xbc, 0x1c, 0x00, 0x68, 0x42, 0x82, 0x00, 0xc8, 0x82, 0x02, 0x00, 0x08, 0x82, 0xbc, 0x00, 0x50, 0xbc, 0x1c, 0x00,
0x77, 0x77, 0xb7, 0x00, 0x2f, 0xb7, 0x17, 0x00, 0x8f, 0xb7, 0xa7, 0x00, 0x4f, 0x37, 0xd7, 0x00, 0x77, 0x77, 0xb7, 0x00, 0x2f, 0xb7, 0x17, 0x00, 0x8f, 0xb7, 0xa7, 0x00, 0x4f, 0x37, 0xd7, 0x00,
0x70, 0xc2, 0xbc, 0x00, 0x70, 0x82, 0xbc, 0x00, 0xc8, 0x82, 0x02, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0x70, 0xc2, 0xbc, 0x00, 0x70, 0x82, 0xbc, 0x00, 0xc8, 0x82, 0x02, 0x00, 0x28, 0xfc, 0xfc, 0x00,
0xa8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0xa8, 0x7c, 0x7c, 0x00,
0x48, 0xbc, 0xbc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x02, 0x02, 0x00, 0xa8, 0x02, 0x02, 0x00, 0x48, 0xbc, 0xbc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x02, 0x02, 0x00, 0xa8, 0x02, 0x02, 0x00,
0xa8, 0x02, 0x02, 0x00, 0x88, 0x42, 0xfc, 0x00, 0xf0, 0x02, 0x3c, 0x00, 0xb1, 0x7c, 0x60, 0x00, 0xa8, 0x02, 0x02, 0x00, 0x88, 0x42, 0xfc, 0x00, 0xf0, 0x02, 0x3c, 0x00, 0xb1, 0x7c, 0x60, 0x00,
0x1c, 0xba, 0x79, 0x00, 0x99, 0x82, 0x40, 0x00, 0xd9, 0x82, 0x00, 0x00, 0x0c, 0xea, 0x59, 0x00, 0x1c, 0xba, 0x79, 0x00, 0x99, 0x82, 0x40, 0x00, 0xd9, 0x82, 0x00, 0x00, 0x0c, 0xea, 0x59, 0x00,
0xc9, 0x7c, 0xa0, 0x00, 0x70, 0x82, 0xbc, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0xa8, 0x02, 0x02, 0x00, 0xc9, 0x7c, 0xa0, 0x00, 0x70, 0x82, 0xbc, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0xa8, 0x02, 0x02, 0x00,
0xa8, 0x7c, 0x7c, 0x00, 0x28, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x28, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00,
0x48, 0xbc, 0xbc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0x02, 0x7c, 0x00, 0xa8, 0x02, 0x02, 0x00, 0x48, 0xbc, 0xbc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0x02, 0x7c, 0x00, 0xa8, 0x02, 0x02, 0x00,
0x28, 0x7c, 0x82, 0x00, 0x88, 0x7c, 0x7c, 0x00, 0x1f, 0x2f, 0xef, 0x00, 0x44, 0x58, 0x6c, 0x00, 0x28, 0x7c, 0x82, 0x00, 0x88, 0x7c, 0x7c, 0x00, 0x1f, 0x2f, 0xef, 0x00, 0x44, 0x58, 0x6c, 0x00,
0x74, 0x2a, 0x99, 0x00, 0x99, 0x82, 0x40, 0x00, 0x99, 0x82, 0x40, 0x00, 0x8f, 0xcf, 0xaf, 0x00, 0x74, 0x2a, 0x99, 0x00, 0x99, 0x82, 0x40, 0x00, 0x99, 0x82, 0x40, 0x00, 0x8f, 0xcf, 0xaf, 0x00,
0x44, 0x58, 0xac, 0x00, 0x7f, 0x5f, 0xbf, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x44, 0x58, 0xac, 0x00, 0x7f, 0x5f, 0xbf, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0xa8, 0x7c, 0x7c, 0x00,
0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00,
0x48, 0xbc, 0xbc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0xa8, 0x02, 0x02, 0x00, 0x48, 0xbc, 0xbc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0xa8, 0x02, 0x02, 0x00,
0x88, 0xfc, 0x3c, 0x00, 0xf0, 0x02, 0x3c, 0x00, 0xa0, 0x60, 0x80, 0x00, 0xef, 0xcf, 0x4f, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0xf0, 0x02, 0x3c, 0x00, 0xa0, 0x60, 0x80, 0x00, 0xef, 0xcf, 0x4f, 0x00,
0xa7, 0xb7, 0x57, 0x00, 0x99, 0x82, 0x40, 0x00, 0x39, 0x42, 0x80, 0x00, 0x34, 0x2a, 0x59, 0x00, 0xa7, 0xb7, 0x57, 0x00, 0x99, 0x82, 0x40, 0x00, 0x39, 0x42, 0x80, 0x00, 0x34, 0x2a, 0x59, 0x00,
0x59, 0xc9, 0x6d, 0x00, 0x60, 0x80, 0xc0, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0x48, 0xbc, 0xbc, 0x00, 0x59, 0xc9, 0x6d, 0x00, 0x60, 0x80, 0xc0, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0x48, 0xbc, 0xbc, 0x00,
0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00,
0x48, 0xbc, 0xbc, 0x00, 0xa8, 0x02, 0x02, 0x00, 0xa8, 0x02, 0x02, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0x48, 0xbc, 0xbc, 0x00, 0xa8, 0x02, 0x02, 0x00, 0xa8, 0x02, 0x02, 0x00, 0x28, 0xfc, 0xfc, 0x00,
0x88, 0xfc, 0x3c, 0x00, 0x7d, 0x8b, 0x63, 0x00, 0x1d, 0x8b, 0xc3, 0x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 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00,
0x48, 0xbc, 0xbc, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0xa8, 0x02, 0x02, 0x00, 0xa8, 0x02, 0x02, 0x00, 0x48, 0xbc, 0xbc, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0xa8, 0x02, 0x02, 0x00, 0xa8, 0x02, 0x02, 0x00,
0xc8, 0x82, 0x02, 0x00, 0x28, 0x82, 0x02, 0x00, 0x48, 0x42, 0xfc, 0x00, 0x33, 0x2b, 0x27, 0x00, 0xc8, 0x82, 0x02, 0x00, 0x28, 0x82, 0x02, 0x00, 0x48, 0x42, 0xfc, 0x00, 0x33, 0x2b, 0x27, 0x00,
0x33, 0xf5, 0x81, 0x00, 0xa8, 0xe2, 0xbc, 0x00, 0x98, 0xe2, 0x42, 0x00, 0xd9, 0xc9, 0x6a, 0x00, 0x33, 0xf5, 0x81, 0x00, 0xa8, 0xe2, 0xbc, 0x00, 0x98, 0xe2, 0x42, 0x00, 0xd9, 0xc9, 0x6a, 0x00,
0x47, 0x8f, 0x37, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0xc8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x47, 0x8f, 0x37, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0xc8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00,
0xa8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x28, 0x3c, 0xbc, 0x00,
0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x02, 0x02, 0x00, 0xa8, 0x02, 0x02, 0x00, 0xa8, 0x02, 0x02, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0xa8, 0x02, 0x02, 0x00, 0xa8, 0x02, 0x02, 0x00, 0xa8, 0x02, 0x02, 0x00,
0x68, 0x42, 0x82, 0x00, 0xc8, 0x42, 0xfc, 0x00, 0x70, 0x82, 0xbc, 0x00, 0x46, 0x82, 0x98, 0x00, 0x68, 0x42, 0x82, 0x00, 0xc8, 0x42, 0xfc, 0x00, 0x70, 0x82, 0xbc, 0x00, 0x46, 0x82, 0x98, 0x00,
0xf1, 0x1d, 0x25, 0x00, 0x58, 0xe2, 0x42, 0x00, 0xe8, 0x12, 0x22, 0x00, 0xa9, 0x83, 0xa5, 0x00, 0xf1, 0x1d, 0x25, 0x00, 0x58, 0xe2, 0x42, 0x00, 0xe8, 0x12, 0x22, 0x00, 0xa9, 0x83, 0xa5, 0x00,
0xc6, 0x82, 0x98, 0x00, 0x48, 0x02, 0xbc, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0xc6, 0x82, 0x98, 0x00, 0x48, 0x02, 0xbc, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0x68, 0xfc, 0xfc, 0x00,
0x68, 0xfc, 0xfc, 0x00, 0x68, 0x02, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0x3c, 0xbc, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0x02, 0x7c, 0x00, 0x68, 0xfc, 0xfc, 0x00, 0x68, 0x3c, 0xbc, 0x00,
0x48, 0xbc, 0xbc, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0x88, 0xfc, 0x3c, 0x00, 0x48, 0xbc, 0xbc, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0x88, 0xfc, 0x3c, 0x00,
0x28, 0xfc, 0xfc, 0x00, 0xc8, 0x82, 0x02, 0x00, 0x30, 0xc2, 0xfc, 0x00, 0xff, 0x5f, 0x7f, 0x00, 0x28, 0xfc, 0xfc, 0x00, 0xc8, 0x82, 0x02, 0x00, 0x30, 0xc2, 0xfc, 0x00, 0xff, 0x5f, 0x7f, 0x00,
0xc8, 0x22, 0x82, 0x00, 0xe8, 0xe2, 0x62, 0x00, 0xe8, 0xe2, 0x62, 0x00, 0xa8, 0xa2, 0xfc, 0x00, 0xc8, 0x22, 0x82, 0x00, 0xe8, 0xe2, 0x62, 0x00, 0xe8, 0xe2, 0x62, 0x00, 0xa8, 0xa2, 0xfc, 0x00,
0x7f, 0x3f, 0xbf, 0x00, 0x08, 0x82, 0xbc, 0x00, 0xc8, 0x82, 0x02, 0x00, 0xa8, 0x7c, 0x7c, 0x00, 0x7f, 0x3f, 0xbf, 0x00, 0x08, 0x82, 0xbc, 0x00, 0xc8, 0x82, 0x02, 0x00, 0xa8, 0x7c, 0x7c, 0x00,
0xc8, 0x7c, 0x7c, 0x00, 0xc8, 0x7c, 0x7c, 0x00, 0x28, 0x3c, 0x7c, 0x00, 0x28, 0x3c, 0xbc, 0x00 0xc8, 0x7c, 0x7c, 0x00, 0xc8, 0x7c, 0x7c, 0x00, 0x28, 0x3c, 0x7c, 0x00, 0x28, 0x3c, 0xbc, 0x00};
}; uint32_t rgb565_to_rgb888(uint16_t rgb565)
uint32_t rgb565_to_rgb888(uint16_t rgb565) { {
// Tách các kênh màu từ giá trị RGB565 // Tách các kênh màu từ giá trị RGB565
uint8_t r = (rgb565 >> 11) & 0x1F; // 5 bit cho đỏ uint8_t r = (rgb565 >> 11) & 0x1F; // 5 bit cho đỏ
uint8_t g = (rgb565 >> 5) & 0x3F; // 6 bit cho xanh lục uint8_t g = (rgb565 >> 5) & 0x3F; // 6 bit cho xanh lục
uint8_t b = rgb565 & 0x1F; // 5 bit cho xanh dương uint8_t b = rgb565 & 0x1F; // 5 bit cho xanh dương
// Chuyển đổi các kênh màu từ 5/6 bit sang 8 bit // Chuyển đổi các kênh màu từ 5/6 bit sang 8 bit
r = (r * 255 + 15) / 31; // Chuyển đổi từ 5 bit sang 8 bit r = (r * 255 + 15) / 31; // Chuyển đổi từ 5 bit sang 8 bit
g = (g * 255 + 31) / 63; // Chuyển đổi từ 6 bit sang 8 bit g = (g * 255 + 31) / 63; // Chuyển đổi từ 6 bit sang 8 bit
b = (b * 255 + 15) / 31; // Chuyển đổi từ 5 bit sang 8 bit b = (b * 255 + 15) / 31; // Chuyển đổi từ 5 bit sang 8 bit
// Ghép các giá trị RGB888 thành một giá trị 32 bit // Ghép các giá trị RGB888 thành một giá trị 32 bit
return (r << 16) | (g << 8) | b; return (r << 16) | (g << 8) | b;
} }
void drawXbm565(int x, int y, int width, int height, const char *xbm, uint16_t color = 0xffff) void drawXbm565(int x, int y, int width, int height, const char *xbm, uint16_t color = 0xffff)
{ {
if (width % 8 != 0) { if (width % 8 != 0)
width = ((width / 8) + 1) * 8; {
width = ((width / 8) + 1) * 8;
} }
for (int i = 0; i < width * height / 8; i++ ) { for (int i = 0; i < width * height / 8; i++)
unsigned char charColumn = pgm_read_byte(xbm + i); {
for (int j = 0; j < 8; j++) { unsigned char charColumn = pgm_read_byte(xbm + i);
int targetX = (i * 8 + j) % width + x; for (int j = 0; j < 8; j++)
int targetY = (8 * i / (width)) + y; {
if (bitRead(charColumn, j)) { int targetX = (i * 8 + j) % width + x;
dma_display->drawPixel(targetX, targetY, color); int targetY = (8 * i / (width)) + y;
} if (bitRead(charColumn, j))
{
dma_display->drawPixel(targetX, targetY, color);
} }
} }
}
} }
void draw_cat(int x_start, int y_start,int width, int height) void draw_cat(int x_start, int y_start, int width, int height)
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
@ -199,11 +203,11 @@ void draw_cat(int x_start, int y_start,int width, int height)
uint8_t r = (rgb888 >> 16) & 0xFF; // Kênh đỏ uint8_t r = (rgb888 >> 16) & 0xFF; // Kênh đỏ
uint8_t g = (rgb888 >> 8) & 0xFF; // Kênh xanh lục uint8_t g = (rgb888 >> 8) & 0xFF; // Kênh xanh lục
uint8_t b = rgb888 & 0xFF; // Kênh xanh dương uint8_t b = rgb888 & 0xFF; // Kênh xanh dương
//dma_display->drawPixel(x, y, color); // dma_display->drawPixel(x, y, color);
if (y <= 31) if (y <= 31)
dma_display->drawPixelRGB888(x+x_start, y+y_start, r, g, b); dma_display->drawPixelRGB888(x + x_start, y + y_start, r, g, b);
else else
dma_display->drawPixelRGB888(x+x_start, y+y_start, r, b, g); dma_display->drawPixelRGB888(x + x_start, y + y_start, r, b, g);
} }
} }
} }
@ -289,11 +293,10 @@ void Drawbar(int x)
{ {
// measure x dimension // measure x dimension
int dodai = 16; int dodai = 16;
MinX_bar = x-dodai/2; MinX_bar = x - dodai / 2;
MaxX_bar = x+dodai/2; MaxX_bar = x + dodai / 2;
dma_display->drawLine(MinX_bar,MinY_bar-1,MaxX_bar,MinY_bar-1,dma_display->color333(3,3,3)); dma_display->drawLine(MinX_bar, MinY_bar - 1, MaxX_bar, MinY_bar - 1, dma_display->color333(3, 3, 3));
dma_display->drawLine(MinX_bar,MinY_bar,MaxX_bar,MinY_bar,dma_display->color333(3,3,3)); dma_display->drawLine(MinX_bar, MinY_bar, MaxX_bar, MinY_bar, dma_display->color333(3, 3, 3));
} }
bool created = false; bool created = false;
@ -301,18 +304,18 @@ int X_vat = 20;
int Y_vat = 2; int Y_vat = 2;
int lastpoint[2]; int lastpoint[2];
int r = 2; int r = 2;
int speed = 500; int speed = 150;
void DrawObject(bool deleted = false) void DrawObject(bool deleted = false)
{ {
// measure x dimension // measure x dimension
unsigned long now = millis(); unsigned long now = millis();
if (!created) if (!created)
{ {
lastpoint[0]=X_vat; lastpoint[0] = X_vat;
lastpoint[1]=Y_vat; lastpoint[1] = Y_vat;
dma_display->fillCircle(X_vat,Y_vat,r,dma_display->color333(0,0,0)); dma_display->fillCircle(X_vat, Y_vat, r, dma_display->color333(0, 0, 0));
dma_display->drawLine(MinX_bar,MinY_bar-1,MaxX_bar,MinY_bar-1,dma_display->color333(3,3,3)); dma_display->drawLine(MinX_bar, MinY_bar - 1, MaxX_bar, MinY_bar - 1, dma_display->color333(3, 3, 3));
dma_display->drawLine(MinX_bar,MinY_bar,MaxX_bar,MinY_bar,dma_display->color333(3,3,3)); dma_display->drawLine(MinX_bar, MinY_bar, MaxX_bar, MinY_bar, dma_display->color333(3, 3, 3));
X_vat = random(20, 109); // random(min, max), max không bao gồm X_vat = random(20, 109); // random(min, max), max không bao gồm
Y_vat = 2; Y_vat = 2;
@ -320,16 +323,18 @@ void DrawObject(bool deleted = false)
} }
else else
{ {
if(now-period_time>=speed){ if (now - period_time >= speed)
dma_display->fillCircle(X_vat,Y_vat,r,dma_display->color333(0,0,0)); {
dma_display->fillCircle(X_vat, Y_vat, r, dma_display->color333(0, 0, 0));
Y_vat += 1; Y_vat += 1;
if (Y_vat > 52)created = false; if (Y_vat > 52)
created = false;
period_time = now; period_time = now;
} }
} }
//dma_display->drawCircle(X_vat,Y_vat,1,dma_display->color333(7,0,0)); // dma_display->drawCircle(X_vat,Y_vat,1,dma_display->color333(7,0,0));
dma_display->fillCircle(X_vat,Y_vat,r,dma_display->color333(7,0,0)); dma_display->fillCircle(X_vat, Y_vat, r, dma_display->color333(7, 0, 0));
} }
int score = 0; int score = 0;
@ -337,11 +342,11 @@ int score = 0;
#define COLOR_WHITE dma_display->color333(7, 7, 7) #define COLOR_WHITE dma_display->color333(7, 7, 7)
void HeldObject() void HeldObject()
{ {
if (Y_vat+r >= MinY_bar-1 && X_vat >= MinX_bar-r && X_vat <= MaxX_bar+r) if (Y_vat + r >= MinY_bar - 1 && X_vat >= MinX_bar - r && X_vat <= MaxX_bar + r)
{ {
Serial.println("Created"); Serial.println("Created");
created = false; created = false;
//DrawObject(true); // DrawObject(true);
DrawObject(); DrawObject();
dma_display->setTextColor(COLOR_BLACK); dma_display->setTextColor(COLOR_BLACK);
@ -354,7 +359,8 @@ void HeldObject()
dma_display->setCursor(2, 11); dma_display->setCursor(2, 11);
dma_display->printf("%d", score); dma_display->printf("%d", score);
} }
else{ else
{
dma_display->setFont(&FreeMono9pt7b); // Change to the desired font size dma_display->setFont(&FreeMono9pt7b); // Change to the desired font size
dma_display->setTextColor(COLOR_WHITE); dma_display->setTextColor(COLOR_WHITE);
dma_display->setCursor(2, 11); dma_display->setCursor(2, 11);
@ -367,19 +373,20 @@ void HeldObject()
int X_shot = 0; int X_shot = 0;
int Y_shot = 32; int Y_shot = 32;
bool created_shot = false; bool created_shot = false;
bool direction = false;
bool direction = false; // false = left, true = right;
int lastpoint_shot[2]; int lastpoint_shot[2];
unsigned long period_shot = millis(); unsigned long period_shot = millis();
int speed_shot = 300; int speed_shot = 100;
void Drawbullet(bool deleted = false) void Drawbullet(bool deleted = false)
{ {
// measure x dimension // measure x dimension
unsigned long now = millis(); unsigned long now = millis();
if (!created_shot) if (!created_shot)
{ {
lastpoint_shot[0]=X_shot; lastpoint_shot[0] = X_shot;
lastpoint_shot[1]=Y_shot; lastpoint_shot[1] = Y_shot;
dma_display->fillCircle(X_shot,Y_shot,1,dma_display->color333(0,0,0)); dma_display->fillCircle(X_shot, Y_shot, 1, dma_display->color333(0, 0, 0));
int ran = random(1, 3); int ran = random(1, 3);
if (ran == 1) if (ran == 1)
{ {
@ -392,13 +399,14 @@ void Drawbullet(bool deleted = false)
direction = true; direction = true;
} }
created_shot = true; created_shot = true;
dma_display->fillCircle(X_shot,Y_shot,1,dma_display->color333(5,0,0)); dma_display->clearScreen();
dma_display->fillCircle(X_shot, Y_shot, 1, dma_display->color333(5, 0, 0));
} }
else else
{ {
if(now-period_shot>=speed_shot){ if (now - period_shot >= speed_shot)
dma_display->fillCircle(lastpoint_shot[0],lastpoint_shot[1],1,dma_display->color333(0,0,0)); {
dma_display->fillCircle(lastpoint_shot[0], lastpoint_shot[1], 1, dma_display->color333(0, 0, 0));
if (direction == false) if (direction == false)
{ {
@ -406,22 +414,31 @@ void Drawbullet(bool deleted = false)
if (X_shot >= 126) if (X_shot >= 126)
created_shot = false; created_shot = false;
} }
else{ else
{
X_shot -= 1; X_shot -= 1;
if (X_shot <= 2) if (X_shot <= 2)
created_shot = false; created_shot = false;
} }
lastpoint_shot[0]=X_shot; lastpoint_shot[0] = X_shot;
lastpoint_shot[1]=Y_shot; lastpoint_shot[1] = Y_shot;
dma_display->fillCircle(X_shot,Y_shot,1,dma_display->color333(5,0,0)); dma_display->fillCircle(X_shot, Y_shot, 1, dma_display->color333(5, 0, 0));
period_shot = now; period_shot = now;
} }
} }
//dma_display->drawCircle(X_vat,Y_vat,1,dma_display->color333(7,0,0)); // dma_display->fillCircle(X_shot,Y_shot,1,dma_display->color333(5,0,0));
dma_display->fillCircle(X_vat,Y_vat,r,dma_display->color333(7,0,0));
// dma_display->drawCircle(X_vat,Y_vat,1,dma_display->color333(7,0,0));
} }
void drawStickMan(int x, int y)
int current_sheildX = 0;
int current_sheildY = 0;
int length_shield = 11;
int current_stickmanX = 0;
int current_stickmanY = 0;
int Shield_open = 0;
unsigned long period_gameover = millis();
void drawStickMan(int x, int y, int defend = 0)
{ {
// Vẽ đầu // Vẽ đầu
dma_display->drawCircle(x, y, 2, rgbToUint16(255, 0, 0, false)); // Đầu stick man dma_display->drawCircle(x, y, 2, rgbToUint16(255, 0, 0, false)); // Đầu stick man
@ -434,20 +451,120 @@ void drawStickMan(int x, int y)
// Vẽ chân // Vẽ chân
dma_display->drawLine(x, y + 7, x - 3, y + 10, rgbToUint16(255, 0, 0, false)); // Chân trái dma_display->drawLine(x, y + 7, x - 3, y + 10, rgbToUint16(255, 0, 0, false)); // Chân trái
dma_display->drawLine(x, y + 7, x + 3, y + 10, rgbToUint16(255, 0, 0, false)); // Chân phải dma_display->drawLine(x, y + 7, x + 3, y + 10, rgbToUint16(255, 0, 0, false)); // Chân phải
current_stickmanX = x;
current_stickmanY = y;
if (defend == 2)
{
dma_display->drawLine(x - 4, y - 1, x - 4, y + 10, rgbToUint16(255, 0, 0, false));
dma_display->drawLine(x - 5, y - 1, x - 5, y + 10, rgbToUint16(255, 0, 0, false));
current_sheildX = x - 5;
current_sheildY = y - 1;
length_shield = 11;
}
else if (defend == 1)
{
dma_display->drawLine(x + 4, y - 1, x + 4, y + 10, rgbToUint16(255, 0, 0, false));
dma_display->drawLine(x + 5, y - 1, x + 5, y + 10, rgbToUint16(255, 0, 0, false));
current_sheildX = x + 5;
current_sheildY = y - 1;
length_shield = 11;
}
else
{
current_sheildX = 0;
current_sheildY = 0;
}
}
bool game_over = false;
void Defend()
{
if (!direction)
{
// Do duoc ben trai
if (current_sheildX != 0)
{
// co khien trai
if (current_sheildX == current_stickmanX - 5)
{
if (X_shot >= current_sheildX)
{
created_shot = false;
}
else
{
// do nothing
}
}
// ko co khien trai
else
{
if (X_shot >= current_stickmanX - 5)
{
game_over = true;
dma_display->setFont(&FreeMono9pt7b); // Change to the desired font size
dma_display->setTextColor(COLOR_WHITE);
dma_display->setCursor(2 + 16, 11 + 20);
dma_display->print("GAME OVER");
period_gameover = millis();
}
else
{
// do nothing
}
}
}
}
else
{
if (current_sheildX != 0)
{
// co khien phai
if (current_sheildX == current_stickmanX + 5)
{
if (X_shot <= current_sheildX)
{
created_shot = false;
}
else
{
// do nothing
created_shot = true;
}
}
// ko co khien trai
else
{
if (X_shot <= current_stickmanX + 5)
{
game_over = true;
dma_display->setFont(&FreeMono9pt7b); // Change to the desired font size
dma_display->setTextColor(COLOR_WHITE);
dma_display->setCursor(2 + 16, 11 + 20);
dma_display->print("GAME OVER");
period_gameover = millis();
}
else
{
// do nothing
}
}
}
}
} }
void setup() void setup()
{ {
Serial.begin(115200 * 2); // Đảm bảo baud rate khớp với baud rate của Python Serial.begin(115200 * 2); // Đảm bảo baud rate khớp với baud rate của Python
dma_display = new MatrixPanel_I2S_DMA(mxconfig); dma_display = new MatrixPanel_I2S_DMA(mxconfig);
dma_display->begin(); // setup the LED matrix dma_display->begin(); // setup the LED matrix
dma_display->setBrightness8(50); // 0-255 dma_display->setBrightness8(200); // 0-255
dma_display->clearScreen(); dma_display->clearScreen();
//draw_cat(10,10,20,20); // draw_cat(10,10,20,20);
//drawXbm565(10,10,20,20,CAT_bits,dma_display->color565(100,0,0)); // drawXbm565(10,10,20,20,CAT_bits,dma_display->color565(100,0,0));
} }
bool mode = false; bool mode = false;
int reset_stickman = 2000;
bool Mode_game = false;
void loop() void loop()
{ {
// server.handleClient(); // server.handleClient();
@ -474,10 +591,20 @@ void loop()
memcpy(&numRows, buffer, sizeof(int)); memcpy(&numRows, buffer, sizeof(int));
memcpy(&numCols, buffer + sizeof(int), sizeof(int)); memcpy(&numCols, buffer + sizeof(int), sizeof(int));
if (numRows == 1 && numCols == 0)
{
Mode_game = true;
//dma_display->clearScreen();
// Serial.println("Stick Man");
}
else if (numRows == 0 && numCols == 0)
{
Mode_game = false;
// Serial.println("HungVat");
//dma_display->clearScreen();
}
int expectedSize = numRows * numCols * floatSize; int expectedSize = numRows * numCols * floatSize;
if (bufferIndex >= (2 * sizeof(int) + expectedSize)) if (bufferIndex >= (2 * sizeof(int) + expectedSize))
{ {
dma_display->clearScreen(); dma_display->clearScreen();
@ -493,17 +620,46 @@ void loop()
} }
} }
Drawbar(int(data[0][0])); if (!Mode_game)
{
Drawbar(int(data[0][0]));
}
else
{
if (!game_over)
drawStickMan(int(data[0][0]), int(data[0][1]), int(data[0][2]));
}
// Reset chỉ số chỉ mục sau khi xử lý // Reset chỉ số chỉ mục sau khi xử lý
bufferIndex = 0;
}
bufferIndex = 0;
}
if (Mode_game)
{
if (game_over)
{
if (millis() - period_gameover >= reset_stickman)
{
game_over = false;
dma_display->clearScreen();
}
} }
} }
//DrawObject(true);
DrawObject(); // Stickman region
HeldObject(); if (Mode_game)
{
Drawbullet();
Defend();
}
else // Hung Vat
{
DrawObject(true);
DrawObject();
HeldObject();
}
#pragma endregion #pragma endregion
// readDataFromSerial(); // readDataFromSerial();