Skip to content

Commit 22119c2

Browse files
author
Lucas CHARVOLIN
committed
patch tetris
1 parent e0bf64c commit 22119c2

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

tetris/js/tools.io

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
n random_color()
3+
{
4+
var alea = get_alea(0,8);
5+
if (alea == 1)
6+
return("color1");
7+
else if (alea == 2)
8+
return("color2");
9+
else if (alea == 3)
10+
return("color3");
11+
else if (alea == 4)
12+
return("color4");
13+
else if (alea == 5)
14+
return("color5");
15+
else if (alea == 6)
16+
return("color6");
17+
else if (alea == 7)
18+
return("color7");
19+
else if (alea == 8)
20+
return("color8");
21+
}
22+
23+
functiondraw_title(nb_piece)
24+
{
25+
var nb_piece_on_line = nb _piece / 5;
26+
var pieces = document.getElementsByClassName('relative_piece');
27+
var i = 0;
28+
console.log(nb_piece);
29+
while (i < pieces.length)
30+
{
31+
if ((i >= 5 && i <= 7) || i == (6 + nb_piece_on_line))
32+
pieces[i].className = "relative_piece low_opacity color10";
33+
i++;
34+
}
35+
}
36+
37+
function draw_background_title()
38+
{
39+
var title_contner = document.getElementById('title_contner');
40+
var i = 0;
41+
title_contner.innerHTML = "";
42+
while (i < ((window.innerWidth / 25) * 5))
43+
{
44+
var rand_color = random_color();
45+
title_contner.innerHTML += "<div class=\"relative_piece low_opacity " + rand_color + "\">";
46+
i++;
47+
}
48+
// draw_title(i);
49+
}
50+
draw_background_title()
51+
window.onresize = function(){
52+
53+
draw_background_title();
54+
}

tetris/js/tools.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
n random_color()
3+
{
4+
var alea = get_alea(0,8);
5+
if (alea == 1)
6+
return("color1");
7+
else if (alea == 2)
8+
return("color2");
9+
else if (alea == 3)
10+
return("color3");
11+
else if (alea == 4)
12+
return("color4");
13+
else if (alea == 5)
14+
return("color5");
15+
else if (alea == 6)
16+
return("color6");
17+
else if (alea == 7)
18+
return("color7");
19+
else if (alea == 8)
20+
return("color8");
21+
}
22+
23+
functiondraw_title(nb_piece)
24+
{
25+
var nb_piece_on_line = nb _piece / 5;
26+
var pieces = document.getElementsByClassName('relative_piece');
27+
var i = 0;
28+
console.log(nb_piece);
29+
while (i < pieces.length)
30+
{
31+
if ((i >= 5 && i <= 7) || i == (6 + nb_piece_on_line))
32+
pieces[i].className = "relative_piece low_opacity color10";
33+
i++;
34+
}
35+
}
36+
37+
function draw_background_title()
38+
{
39+
var title_contner = document.getElementById('title_contner');
40+
var i = 0;
41+
title_contner.innerHTML = "";
42+
while (i < ((window.innerWidth / 25) * 5))
43+
{
44+
var rand_color = random_color();
45+
title_contner.innerHTML += "<div class=\"relative_piece low_opacity " + rand_color + "\">";
46+
i++;
47+
}
48+
// draw_title(i);
49+
// }
50+
// draw_background_title()
51+
// window.onresize = function(){
52+
//
53+
// draw_background_title();
54+
// }

0 commit comments

Comments
 (0)