Su 200943147
Dependencies: Gamepad N5110 mbed
Diff: Shape/Shape.cpp
- Revision:
- 7:31dd8865cc44
- Parent:
- 6:e919a1fd1eed
- Child:
- 8:3899d883d329
diff -r e919a1fd1eed -r 31dd8865cc44 Shape/Shape.cpp --- a/Shape/Shape.cpp Wed May 03 08:42:22 2017 +0000 +++ b/Shape/Shape.cpp Wed May 03 21:52:52 2017 +0000 @@ -168,29 +168,7 @@ ShapeInit[l+3][k+4]=0; ShapeInit[l+4][k+4]=0; } -void Shape::RotateInit() -{ - for(int i=1; i<84; i++) { - for(int j=1; j<48; j++) { - ArrayRotate[i-1][j-1]=ShapeInit[i][j]; - } - } - int Temp; - for (int i=0; i<2; i++) { - for (int j=i; j<3-i; j++) { - Temp=ArrayRotate[i][j]; - ArrayRotate[i][j]=ArrayRotate[j][3-i]; - ArrayRotate[j][3-i]=ArrayRotate[3-i][3-j]; - ArrayRotate[3-i][3-j]=ArrayRotate[3-j][i]; - ArrayRotate[3-j][i]=Temp; - } - } - for(int i=1; i<5; i++) { - for(int j=1; j<5; j++) { - printf("%d\n",ArrayRotate[i][j]); - } - } -} + void Shape::Rotate(Gamepad &pad) { for(int i=1; i<84; i++) { @@ -213,56 +191,30 @@ printf("%d\n",ArrayRotate[i][j]); } } + printf("x=%d\n",x); + printf("y=%d\n",y); if(pad.check_event(Gamepad::A_PRESSED) == true) { for(int i=0; i<84; i++) { for(int j=0; j<48; j++) { ShapeInit[i][j]=0; + ShapeArray[i][j]=0; } } - for(int i=0; i<84; i++) { - for(int j=0; j<48; j++) { + printf("x1=%d\n",x); + printf("y1=%d\n",y); + for(int i=0; i<83; i++) { + for(int j=0; j<47; j++) { ShapeInit[i+1][j+1]=ArrayRotate[i][j]; } } + printf("x2=%d\n",x); + printf("y2=%d\n",y); } } void Shape::Update(Gamepad &pad) { int n=14; - for(int i=1; i<84; i++) { - for(int j=1; j<48; j++) { - ArrayRotate[i-1][j-1]=ShapeInit[i][j]; - } - } - int Temp; - for (int i=0; i<2; i++) { - for (int j=i; j<3-i; j++) { - Temp=ArrayRotate[i][j]; - ArrayRotate[i][j]=ArrayRotate[j][3-i]; - ArrayRotate[j][3-i]=ArrayRotate[3-i][3-j]; - ArrayRotate[3-i][3-j]=ArrayRotate[3-j][i]; - ArrayRotate[3-j][i]=Temp; - } - } - for(int i=1; i<5; i++) { - for(int j=1; j<5; j++) { - printf("%d\n",ArrayRotate[i][j]); - } - } - if(pad.check_event(Gamepad::A_PRESSED) == true) { - for(int i=0; i<84; i++) { - for(int j=0; j<48; j++) { - ShapeInit[i][j]=0; - } - } - for(int i=0; i<84; i++) { - for(int j=0; j<48; j++) { - ShapeInit[i+1][j+1]=ArrayRotate[i][j]; - } - } - } - ShapeArray[x+n][y]=0; ShapeArray[x+1+n][y]=0; ShapeArray[x+2+n][y]=0;