Difference between revisions of "Joypad-Game-Higher and Higher"
From Microduino Wiki
(Created page with "{| style="width: 800px;" |- | ==Outline== We adopt Microduino-Joypad-Game to play the game Higher and Higher, which can be controlled by gravity perception. ==Bill of Materi...") |
|||
(One intermediate revision by one other user not shown) | |||
Line 23: | Line 23: | ||
[[File: Microduino-Joypad-snake.jpg|600px|center|thumb]] | [[File: Microduino-Joypad-snake.jpg|600px|center|thumb]] | ||
==Download== | ==Download== | ||
− | TFT | + | TFT library: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Libraries/_01_Microduino_TFT_ST7735 |
− | Joypad lib | + | Joypad lib: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Libraries/_08_Microduino_Shield_Joypad |
− | 10DOF | + | 10DOF library: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Libraries/_05_Microduino_10DOF |
− | + | Code: | |
==Debugging== | ==Debugging== |
Latest revision as of 08:44, 13 September 2016
ContentsOutlineWe adopt Microduino-Joypad-Game to play the game Higher and Higher, which can be controlled by gravity perception. Bill of Material
DownloadTFT library: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Libraries/_01_Microduino_TFT_ST7735 Joypad lib: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Libraries/_08_Microduino_Shield_Joypad 10DOF library: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Libraries/_05_Microduino_10DOF Code: Debugging
void mpu6050()
{
accelgyro.getMotion6(&ax,&ay,&az,&gx,&gy,&gz);//Acquire the acceleration and the angular velocity of the x,y,z axis.
//======Below are the quantized values of the acceleration
Ax=ax/16384.00;
Ay=ay/16384.00;
Az=az/16384.00;
//==========Below are the angles between the three axes and the horizontal coordinate system.
// Angel_accX=atan(Ax/sqrt(Az*Az+Ay*Ay))*180/3.14;
Angel_accY=atan(Ay/sqrt(Ax*Ax+Az*Az))*180/3.14;
//Angel_accZ=atan(Az/sqrt(Ax*Ax+Ay*Ay))*180/3.14;
}
int acc_readX() {
if(Joypad.readButton(CH_SWITCH_L)&&Joypad.readButton(CH_SWITCH_R))
{
mpu6050();
val= constrain(Angel_accY, -64, 64); // use Y for orientation
}
else
val= -1 * constrain(Joypad.readJoystickX()/8, -64, 64); // use Y for orientation
return(val);
// Serial.println(val);
} Gravity induction control is the default setting by turning the left and the right switches to the top. So, the opposite operation is joystick control. Users can change the setting according to personal needs.
if(score > highscore){
if(score < 64000) {
EEPROM.write(0, score);
EEPROM.write(1, score>>8);
}
else { // bad value, zero out
EEPROM.write(0,0);
EEPROM.write(1,0);
}
//drawString(1, s_height+3, "HIGHSCORE!", p_color_default, 1);
// tft.drawString(1, s_height+3, "HIGHSCORE!", p_color_default, 1);
drawInt(score, 120, s_height+3, p_color_default, background);
highscore = score;
}
switch (b_onUseID){
case 0:
drawString(1, s_height+3, "Jet pack", b_colors[b_onUseID], 1);
// tft.drawString(1, s_height+3, "Jet pack", b_colors[b_onUseID], 1);
b_max = 100;
b_remaining = b_max;
break;
case 1:
drawString(1, s_height+3, "Frog legs", b_colors[b_onUseID], 1);
// tft.drawString(1, s_height+3, "Frog legs", b_colors[b_onUseID], 1);
b_max = 100;
b_remaining = b_max;
break;
case 2:
drawString(1, s_height+3, "Testosterone", b_colors[b_onUseID], 1);
// tft.drawString(1, s_height+3, "Testosterone", b_colors[b_onUseID], 1);
b_max = 1;
b_remaining = b_max;
break;
case 3:
drawString(1, s_height+3, "Low gravity", b_colors[b_onUseID], 1);
// tft.drawString(1, s_height+3, "Low gravity", b_colors[b_onUseID], 1);
b_max = 255;
b_remaining = b_max;
break;
}
|