forked from JJFigpad/Tetris_2020-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch_200826b.pde
89 lines (85 loc) · 1.66 KB
/
sketch_200826b.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//Variables generales
final int col = 10;
final int fil = 20;
int last = 0;
int c = 0;
int c_c = 0;
int x = 0;
int y = 0; //579
int temph = 0;
int tempc = 0;
boolean cp = true;
boolean pe = false;
//Variables para puntos y niveles
int score = 0;
int nivel = 0;
int vel = 0;
void setup() {
size(610, 620, P2D);
Tablero();
textSize(20);
}
void draw() {
background(0);
if (Final() == false) {
Extras();
displayT();
drawP();
} else {
Extras();
displayT();
push();
textSize(55);
fill(255);
text("Game Over", 160, 320);
pop();
}
}
void keyPressed() {
if (key == CODED) {
if (keyCode == UP && c < 19) {
if ((tRotation == tR1 && x+hor*30 == block1) || (tRotation == tR2 && x+hor*30 == block2) || (RotV() == false)) {
tRotation+=0;
} else {
tRotation ++;
}
}
tRotation = tRotation < 0 ? 3 : tRotation % 4;
if (keyCode == DOWN && y+30*c < 579 && (limyP() == true)) {
c++;
score ++;
}
if (keyCode == LEFT && (270+hor*30) >= lim1 && (limxiP() == true)) {
hor--;
} else if (keyCode == RIGHT && (270+hor*30) <= lim2 && (limxdP() == true)) {
hor++;
}
}
}
void Extras() {
push();
textSize(40);
fill(255,0,0);
text("TETRIS", 465, 115);
pop();
push();
fill(255,0,0);
//text("Estadisticas: ", 480, 370);
text("Lineas:", 30, 230);
text("Puntaje:", 30, 360);
text("Nivel:", 480, 300);
fill(255);
text((nivel+1), 500, 330);
text(ct1, 50, 260);
text(score, 50, 390);
pop();
push();
fill(0);
rect(151, 0, 300, 10);
pop();
}
Boolean Final() {
if ((c < 1 || tempc <= 1) && tablero[temph][c_c] != 0)
return true;
return false;
}