![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
My ELEC2645 joystick project Tetris Game NAME: JIANWEI CHEN SID: 200879849
Dependencies: N5110 SDFileSystem mbed
Diff: main.cpp
- Revision:
- 3:5494a0fb3a33
- Parent:
- 2:f427089e2bfa
- Child:
- 4:463abe5f5135
--- a/main.cpp Tue Apr 26 00:14:57 2016 +0000 +++ b/main.cpp Sun May 01 23:09:33 2016 +0000 @@ -96,13 +96,10 @@ lcd.normalMode(); // normal colour mode lcd.setBrightness(1.0); // put LED backlight on 100% init_game(); - game.attach(&game_isr,0.4); + game.attach(&game_isr,0.2); lcd.refresh(); - - calibrateJoystick(); - while (1) { if(g_game_flag==1) { @@ -152,20 +149,12 @@ break; case RIGHT: right_collisionDetect(); - /* - for (int i=0; i<=5; i++) { - for (int j=0; j<=5; j++) { - if(right_boundary[i][j] ==1) { - lcd.setPixel(i,j); - } - } - } - */ if( right_collision_flag == 0) { pos.x +=2; drawPattern(pos.type,pos.rotation,pos.x,pos.y,1); } else { drawPattern(pos.type,pos.rotation,pos.x,pos.y,1); + right_collision_flag = 0; } break; case LEFT: @@ -175,7 +164,9 @@ drawPattern(pos.type,pos.rotation,pos.x,pos.y,1); } else { drawPattern(pos.type,pos.rotation,pos.x,pos.y,1); + left_collision_flag = 0; } + break; case CENTRE: drawPattern(pos.type,pos.rotation,pos.x,pos.y,1); @@ -478,7 +469,7 @@ for(int j=y+5; j >= y; j--) { if (j>=-1) { if(bot_boundary[i-x][j-y]==1) { - if(j >= 47) { + if(j >= 42) { fastmove_bottom_collision_flag = 1; break; } else if (lcd.getPixel(i,j+4)) {