Su 200943147

Dependencies:   Gamepad N5110 mbed

Committer:
GS00
Date:
Sat Apr 29 13:10:21 2017 +0000
Revision:
3:9dd35424cdfe
Parent:
2:84e6975dd4b2
Child:
4:1faa216ac5cd
Child:
5:afa6592a4ba5
Version 4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GS00 0:444b4d0a113d 1 #include "Shape.h"
GS00 0:444b4d0a113d 2
GS00 0:444b4d0a113d 3
GS00 3:9dd35424cdfe 4 Shape::Shape()
GS00 0:444b4d0a113d 5 {
GS00 0:444b4d0a113d 6 }
GS00 0:444b4d0a113d 7
GS00 3:9dd35424cdfe 8 void Shape::Init()
GS00 0:444b4d0a113d 9 {
GS00 3:9dd35424cdfe 10 srand(time(NULL));
GS00 3:9dd35424cdfe 11 RandomNumber=rand()%7;
GS00 2:84e6975dd4b2 12
GS00 3:9dd35424cdfe 13 if(RandomNumber==0) {
GS00 3:9dd35424cdfe 14 T_Shape();
GS00 3:9dd35424cdfe 15 RandomNumber=10;
GS00 3:9dd35424cdfe 16 } else if(RandomNumber==1) {
GS00 3:9dd35424cdfe 17 J_Shape();
GS00 3:9dd35424cdfe 18 RandomNumber=10;
GS00 3:9dd35424cdfe 19 } else if(RandomNumber==2) {
GS00 3:9dd35424cdfe 20 L_Shape();
GS00 3:9dd35424cdfe 21 RandomNumber=10;
GS00 3:9dd35424cdfe 22 } else if(RandomNumber==3) {
GS00 3:9dd35424cdfe 23 O_Shape();
GS00 3:9dd35424cdfe 24 RandomNumber=10;
GS00 3:9dd35424cdfe 25 } else if(RandomNumber==4) {
GS00 3:9dd35424cdfe 26 I_Shape();
GS00 3:9dd35424cdfe 27 RandomNumber=10;
GS00 3:9dd35424cdfe 28 } else if(RandomNumber==5) {
GS00 3:9dd35424cdfe 29 S_Shape();
GS00 3:9dd35424cdfe 30 RandomNumber=10;
GS00 3:9dd35424cdfe 31 } else if(RandomNumber==6) {
GS00 3:9dd35424cdfe 32 Z_Shape();
GS00 3:9dd35424cdfe 33 RandomNumber=10;
GS00 3:9dd35424cdfe 34 }
GS00 0:444b4d0a113d 35 }
GS00 0:444b4d0a113d 36
GS00 3:9dd35424cdfe 37 void Shape::L_Shape()
GS00 0:444b4d0a113d 38 {
GS00 3:9dd35424cdfe 39 ShapeInit[l+1][k+1]=0;
GS00 3:9dd35424cdfe 40 ShapeInit[l+2][k+1]=1;
GS00 3:9dd35424cdfe 41 ShapeInit[l+3][k+1]=0;
GS00 3:9dd35424cdfe 42 ShapeInit[l+4][k+1]=0;
GS00 2:84e6975dd4b2 43
GS00 3:9dd35424cdfe 44 ShapeInit[l+1][k+2]=0;
GS00 3:9dd35424cdfe 45 ShapeInit[l+2][k+2]=1;
GS00 3:9dd35424cdfe 46 ShapeInit[l+3][k+2]=0;
GS00 3:9dd35424cdfe 47 ShapeInit[l+4][k+2]=0;
GS00 3:9dd35424cdfe 48
GS00 3:9dd35424cdfe 49 ShapeInit[l+1][k+3]=0;
GS00 3:9dd35424cdfe 50 ShapeInit[l+2][k+3]=1;
GS00 3:9dd35424cdfe 51 ShapeInit[l+3][k+3]=1;
GS00 3:9dd35424cdfe 52 ShapeInit[l+4][k+3]=0;
GS00 3:9dd35424cdfe 53
GS00 3:9dd35424cdfe 54 ShapeInit[l+1][k+4]=0;
GS00 3:9dd35424cdfe 55 ShapeInit[l+2][k+4]=0;
GS00 3:9dd35424cdfe 56 ShapeInit[l+3][k+4]=0;
GS00 3:9dd35424cdfe 57 ShapeInit[l+4][k+4]=0;
GS00 0:444b4d0a113d 58 }
GS00 0:444b4d0a113d 59
GS00 3:9dd35424cdfe 60 void Shape::O_Shape()
GS00 3:9dd35424cdfe 61 {
GS00 3:9dd35424cdfe 62 ShapeInit[l+1][k+2]=0;
GS00 3:9dd35424cdfe 63 ShapeInit[l+2][k+2]=1;
GS00 3:9dd35424cdfe 64 ShapeInit[l+3][k+2]=1;
GS00 3:9dd35424cdfe 65 ShapeInit[l+4][k+2]=0;
GS00 3:9dd35424cdfe 66
GS00 3:9dd35424cdfe 67 ShapeInit[l+1][k+3]=0;
GS00 3:9dd35424cdfe 68 ShapeInit[l+2][k+3]=1;
GS00 3:9dd35424cdfe 69 ShapeInit[l+3][k+3]=1;
GS00 3:9dd35424cdfe 70 ShapeInit[l+4][k+3]=0;
GS00 3:9dd35424cdfe 71
GS00 3:9dd35424cdfe 72 ShapeInit[l+1][k+4]=0;
GS00 3:9dd35424cdfe 73 ShapeInit[l+2][k+4]=0;
GS00 3:9dd35424cdfe 74 ShapeInit[l+3][k+4]=0;
GS00 3:9dd35424cdfe 75 ShapeInit[l+4][k+4]=0;
GS00 3:9dd35424cdfe 76 }
GS00 3:9dd35424cdfe 77
GS00 3:9dd35424cdfe 78 void Shape::S_Shape()
GS00 0:444b4d0a113d 79 {
GS00 3:9dd35424cdfe 80 ShapeInit[l+1][k+1]=0;
GS00 3:9dd35424cdfe 81 ShapeInit[l+2][k+1]=0;
GS00 3:9dd35424cdfe 82 ShapeInit[l+3][k+1]=0;
GS00 3:9dd35424cdfe 83 ShapeInit[l+4][k+1]=0;
GS00 3:9dd35424cdfe 84
GS00 3:9dd35424cdfe 85 ShapeInit[l+1][k+2]=0;
GS00 3:9dd35424cdfe 86 ShapeInit[l+2][k+2]=1;
GS00 3:9dd35424cdfe 87 ShapeInit[l+3][k+2]=1;
GS00 3:9dd35424cdfe 88 ShapeInit[l+4][k+2]=0;
GS00 3:9dd35424cdfe 89
GS00 3:9dd35424cdfe 90 ShapeInit[l+1][k+3]=1;
GS00 3:9dd35424cdfe 91 ShapeInit[l+2][k+3]=1;
GS00 3:9dd35424cdfe 92 ShapeInit[l+3][k+3]=0;
GS00 3:9dd35424cdfe 93 ShapeInit[l+4][k+3]=0;
GS00 3:9dd35424cdfe 94
GS00 3:9dd35424cdfe 95 ShapeInit[l+1][k+4]=0;
GS00 3:9dd35424cdfe 96 ShapeInit[l+2][k+4]=0;
GS00 3:9dd35424cdfe 97 ShapeInit[l+3][k+4]=0;
GS00 3:9dd35424cdfe 98 ShapeInit[l+4][k+4]=0;
GS00 0:444b4d0a113d 99 }
GS00 0:444b4d0a113d 100
GS00 3:9dd35424cdfe 101 void Shape::Z_Shape()
GS00 0:444b4d0a113d 102 {
GS00 3:9dd35424cdfe 103 ShapeInit[l+1][k+2]=1;
GS00 3:9dd35424cdfe 104 ShapeInit[l+2][k+2]=1;
GS00 3:9dd35424cdfe 105 ShapeInit[l+3][k+2]=0;
GS00 3:9dd35424cdfe 106 ShapeInit[l+4][k+2]=0;
GS00 3:9dd35424cdfe 107
GS00 3:9dd35424cdfe 108 ShapeInit[l+1][k+3]=0;
GS00 3:9dd35424cdfe 109 ShapeInit[l+2][k+3]=1;
GS00 3:9dd35424cdfe 110 ShapeInit[l+3][k+3]=1;
GS00 3:9dd35424cdfe 111 ShapeInit[l+4][k+3]=0;
GS00 3:9dd35424cdfe 112
GS00 3:9dd35424cdfe 113 ShapeInit[l+1][k+4]=0;
GS00 3:9dd35424cdfe 114 ShapeInit[l+2][k+4]=0;
GS00 3:9dd35424cdfe 115 ShapeInit[l+3][k+4]=0;
GS00 3:9dd35424cdfe 116 ShapeInit[l+4][k+4]=0;
GS00 0:444b4d0a113d 117 }
GS00 3:9dd35424cdfe 118 void Shape::I_Shape()
GS00 0:444b4d0a113d 119 {
GS00 3:9dd35424cdfe 120 ShapeInit[l+1][k+1]=0;
GS00 3:9dd35424cdfe 121 ShapeInit[l+2][k+1]=1;
GS00 3:9dd35424cdfe 122 ShapeInit[l+3][k+1]=0;
GS00 3:9dd35424cdfe 123 ShapeInit[l+4][k+1]=0;
GS00 3:9dd35424cdfe 124
GS00 3:9dd35424cdfe 125 ShapeInit[l+1][k+2]=0;
GS00 3:9dd35424cdfe 126 ShapeInit[l+2][k+2]=1;
GS00 3:9dd35424cdfe 127 ShapeInit[l+3][k+2]=0;
GS00 3:9dd35424cdfe 128 ShapeInit[l+4][k+2]=0;
GS00 3:9dd35424cdfe 129
GS00 3:9dd35424cdfe 130 ShapeInit[l+1][k+3]=0;
GS00 3:9dd35424cdfe 131 ShapeInit[l+2][k+3]=1;
GS00 3:9dd35424cdfe 132 ShapeInit[l+3][k+3]=0;
GS00 3:9dd35424cdfe 133 ShapeInit[l+4][k+3]=0;
GS00 3:9dd35424cdfe 134
GS00 3:9dd35424cdfe 135 ShapeInit[l+1][k+4]=0;
GS00 3:9dd35424cdfe 136 ShapeInit[l+2][k+4]=1;
GS00 3:9dd35424cdfe 137 ShapeInit[l+3][k+4]=0;
GS00 3:9dd35424cdfe 138 ShapeInit[l+4][k+4]=0;
GS00 0:444b4d0a113d 139 }
GS00 3:9dd35424cdfe 140 void Shape::J_Shape()
GS00 0:444b4d0a113d 141 {
GS00 3:9dd35424cdfe 142 ShapeInit[l+1][k+1]=0;
GS00 3:9dd35424cdfe 143 ShapeInit[l+2][k+1]=0;
GS00 3:9dd35424cdfe 144 ShapeInit[l+3][k+1]=1;
GS00 3:9dd35424cdfe 145 ShapeInit[l+4][k+1]=0;
GS00 3:9dd35424cdfe 146
GS00 3:9dd35424cdfe 147 ShapeInit[l+1][k+2]=0;
GS00 3:9dd35424cdfe 148 ShapeInit[l+2][k+2]=0;
GS00 3:9dd35424cdfe 149 ShapeInit[l+3][k+2]=1;
GS00 3:9dd35424cdfe 150 ShapeInit[l+4][k+2]=0;
GS00 3:9dd35424cdfe 151
GS00 3:9dd35424cdfe 152 ShapeInit[l+1][k+3]=0;
GS00 3:9dd35424cdfe 153 ShapeInit[l+2][k+3]=1;
GS00 3:9dd35424cdfe 154 ShapeInit[l+3][k+3]=1;
GS00 3:9dd35424cdfe 155 ShapeInit[l+4][k+3]=0;
GS00 3:9dd35424cdfe 156
GS00 3:9dd35424cdfe 157 ShapeInit[l+1][k+4]=0;
GS00 3:9dd35424cdfe 158 ShapeInit[l+2][k+4]=0;
GS00 3:9dd35424cdfe 159 ShapeInit[l+3][k+4]=0;
GS00 3:9dd35424cdfe 160 ShapeInit[l+4][k+4]=0;
GS00 3:9dd35424cdfe 161 }
GS00 3:9dd35424cdfe 162 void Shape::T_Shape()
GS00 3:9dd35424cdfe 163 {
GS00 3:9dd35424cdfe 164 ShapeInit[l+1][k+2]=1;
GS00 3:9dd35424cdfe 165 ShapeInit[l+2][k+2]=1;
GS00 3:9dd35424cdfe 166 ShapeInit[l+3][k+2]=1;
GS00 3:9dd35424cdfe 167 ShapeInit[l+4][k+2]=0;
GS00 3:9dd35424cdfe 168
GS00 3:9dd35424cdfe 169 ShapeInit[l+1][k+3]=0;
GS00 3:9dd35424cdfe 170 ShapeInit[l+2][k+3]=1;
GS00 3:9dd35424cdfe 171 ShapeInit[l+3][k+3]=0;
GS00 3:9dd35424cdfe 172 ShapeInit[l+4][k+3]=0;
GS00 3:9dd35424cdfe 173
GS00 3:9dd35424cdfe 174 ShapeInit[l+1][k+4]=0;
GS00 3:9dd35424cdfe 175 ShapeInit[l+2][k+4]=0;
GS00 3:9dd35424cdfe 176 ShapeInit[l+3][k+4]=0;
GS00 3:9dd35424cdfe 177 ShapeInit[l+4][k+4]=0;
GS00 0:444b4d0a113d 178 }
GS00 3:9dd35424cdfe 179
GS00 3:9dd35424cdfe 180 void Shape::Update()
GS00 0:444b4d0a113d 181 {
GS00 3:9dd35424cdfe 182 int n=14;
GS00 3:9dd35424cdfe 183 ShapeArray[x+n][y]=0;
GS00 3:9dd35424cdfe 184 ShapeArray[x+1+n][y]=0;
GS00 3:9dd35424cdfe 185 ShapeArray[x+2+n][y]=0;
GS00 3:9dd35424cdfe 186 ShapeArray[x+3+n][y]=0;
GS00 3:9dd35424cdfe 187 ShapeArray[x+4+n][y]=0;
GS00 3:9dd35424cdfe 188 ShapeArray[x+5+n][y]=0;
GS00 3:9dd35424cdfe 189
GS00 3:9dd35424cdfe 190 ShapeArray[x+n][y+1]=0;
GS00 3:9dd35424cdfe 191 ShapeArray[x+1+n][y+1]=ShapeInit[l+1][k+1];
GS00 3:9dd35424cdfe 192 ShapeArray[x+2+n][y+1]=ShapeInit[l+2][k+1];
GS00 3:9dd35424cdfe 193 ShapeArray[x+3+n][y+1]=ShapeInit[l+3][k+1];
GS00 3:9dd35424cdfe 194 ShapeArray[x+4+n][y+1]=ShapeInit[l+4][k+1];
GS00 3:9dd35424cdfe 195 ShapeArray[x+5+n][y+1]=0;
GS00 3:9dd35424cdfe 196
GS00 3:9dd35424cdfe 197 ShapeArray[x+n][y+2]=0;
GS00 3:9dd35424cdfe 198 ShapeArray[x+1+n][y+2]=ShapeInit[l+1][k+2];
GS00 3:9dd35424cdfe 199 ShapeArray[x+2+n][y+2]=ShapeInit[l+2][k+2];
GS00 3:9dd35424cdfe 200 ShapeArray[x+3+n][y+2]=ShapeInit[l+3][k+2];
GS00 3:9dd35424cdfe 201 ShapeArray[x+4+n][y+2]=ShapeInit[l+4][k+2];
GS00 3:9dd35424cdfe 202 ShapeArray[x+5+n][y+2]=0;
GS00 3:9dd35424cdfe 203
GS00 3:9dd35424cdfe 204 ShapeArray[x+n][y+3]=0;
GS00 3:9dd35424cdfe 205 ShapeArray[x+1+n][y+3]=ShapeInit[l+1][k+3];
GS00 3:9dd35424cdfe 206 ShapeArray[x+2+n][y+3]=ShapeInit[l+2][k+3];
GS00 3:9dd35424cdfe 207 ShapeArray[x+3+n][y+3]=ShapeInit[l+3][k+3];
GS00 3:9dd35424cdfe 208 ShapeArray[x+4+n][y+3]=ShapeInit[l+4][k+3];
GS00 3:9dd35424cdfe 209 ShapeArray[x+5+n][y+3]=0;
GS00 3:9dd35424cdfe 210
GS00 3:9dd35424cdfe 211 ShapeArray[x+n][y+4]=0;
GS00 3:9dd35424cdfe 212 ShapeArray[x+1+n][y+4]=ShapeInit[l+1][k+4];
GS00 3:9dd35424cdfe 213 ShapeArray[x+2+n][y+4]=ShapeInit[l+2][k+4];
GS00 3:9dd35424cdfe 214 ShapeArray[x+3+n][y+4]=ShapeInit[l+3][k+4];
GS00 3:9dd35424cdfe 215 ShapeArray[x+4+n][y+4]=ShapeInit[l+4][k+4];
GS00 3:9dd35424cdfe 216 ShapeArray[x+5+n][y+4]=0;
GS00 0:444b4d0a113d 217 }
GS00 0:444b4d0a113d 218
GS00 0:444b4d0a113d 219
GS00 3:9dd35424cdfe 220
GS00 3:9dd35424cdfe 221
GS00 3:9dd35424cdfe 222
GS00 3:9dd35424cdfe 223
GS00 3:9dd35424cdfe 224
GS00 3:9dd35424cdfe 225
GS00 3:9dd35424cdfe 226