xxxxxxxxxx
239
let gif_array= [];
let name_arr = ["1.gif","2.gif","3.gif"]
let array_size = 0;
let song;
let curr, curr2;
let testl;
let game_start = false;
function preload(){
song = loadSound("song.mp3");
gif_array[0] = loadImage("https://i.imgur.com/9vlihy0.gif")
gif_array[1] = loadImage("https://i.imgur.com/S3lqwcU.gif")
gif_array[2] = loadImage("https://i.imgur.com/0zLb3U7.gif")
gif_array[3] = loadImage("https://i.imgur.com/pWolqZJ.gif")
gif_array[4] = loadImage("https://i.imgur.com/Etj7qYD.gif")
gif_array[5] = loadImage("https://i.imgur.com/FRGSXIw.gif")
gif_array[6] = loadImage("https://i.imgur.com/JSE7z9R.gif")
gif_array[7]= loadImage("https://i.imgur.com/NEE5Gwo.gif")
gif_array[8] = loadImage("https://i.imgur.com/0QcU3lw.gif")
gif_array[9] = loadImage("https://i.imgur.com/pwARPjJ.gif")
gif_array[10] = loadImage("https://i.imgur.com/z00YGX5.gif")
//test = loadImage("3.gif");
}
function setup() {
createCanvas(1200, 1200);
for(let i in gif_array){
array_size+=1;
}
img_size = width/count;
curr = gif_array[0];
curr2 = gif_array[1];
r= random(255)
g= random(100,200)
b= random(100)
}
let count = 1;
let arr_choice = 0;
let img_size;
let r,g,b;
let type_choice = 0;
let type_choice_max = 4;
// let color_choice = 0
// let color_choice_max =
let num = 255
let frame_start = 0
function draw() {
if (game_start == false){
textSize(40);
text("controls:",40,40)
text("w-> increase amount",40,80)
text("e-> decrease amount",40,120)
text("u-> change gifs",40,160)
text("i-> change pattern",40,200)
text("o-> change background color",40,240)
text("try changing things to the beat!",100,300)
text("press S in order to start",120,340)
textSize(30)
text("(if the window size is to large",80,500)
text("change the canvas size in the source code)",80,530)
return;
}
frame_start+=1;
background(220);
fill(r,g,b)
rect(0,0,width,height)
for (let i=0;i<count; i++){
for (let j=0;j<count;j++){
fill(r ,g ,b )
rect(img_size*i,img_size*j,img_size,img_size)
}
}
for (let i=0;i<count; i++){
for (let j=0;j<count;j++){
switch (type_choice){
case 0:
image(curr,img_size*i,img_size*j,img_size,img_size);
break;
case 1:
if (i%2==0){
image(curr,img_size*i,img_size*j,img_size,img_size);
}else{
image(curr2,img_size*i,img_size*j,img_size,img_size);
}
break;
case 2:
if (i%2==1){
image(curr,img_size*i,img_size*j,img_size,img_size);
}else{
image(curr2,img_size*i,img_size*j,img_size,img_size);
}
break;
case 3:
if ((i+j)%2==0){
image(curr,img_size*i,img_size*j,img_size,img_size);
}else{
image(curr2,img_size*i,img_size*j,img_size,img_size);
}
break;
case 4:
if ((i+j)%2==1){
image(curr,img_size*i,img_size*j,img_size,img_size);
}else{
image(curr2,img_size*i,img_size*j,img_size,img_size);
}
break;
// case 5:
// if ((i+j)%==0){
// image(curr,img_size*i,img_size*j,img_size,img_size);
// }else{
// image(curr2,img_size*i,img_size*j,img_size,img_size);
// }
// break;
default:
break;
}
}
}
background(color(255,255,255,num));
if (frame_start%370==0){
num = 0;
}
}
function random_color(){
r= random(255)
g= random(100,200)
b= random(100)
//tint(r,g,b)
}
function update_paramaters(){
img_size = width/count;
}
let save1=0;
let save2=1;
function keyPressed(){
if (key == 's' && keyIsPressed && game_start == false){
song.play()
game_start = true;
}
if (game_start == false){
return
}
if(key == 'w' && keyIsPressed){
if (count < 64){
count *= 2;
}
// if (count == 1){
// count = 4;
// }
update_paramaters()
}
if(key == 'o' && keyIsPressed){
random_color()
}
if(key == 'e' && keyIsPressed){
if (count==1){
}else{
count /= 2;
update_paramaters()
}
}
if(key == 'u' && keyIsPressed){
//curr1
while(true){
arr_choice = floor(random(0,array_size))
if ((arr_choice != save1)){
if(arr_choice!=save2){
break;
}
}
}
save1 = arr_choice
curr = gif_array[arr_choice]
//curr2
temp = save2
while(true){
arr_choice = floor(random(0,array_size))
if ((arr_choice != save1)){
if(arr_choice!=save2){
break;
}
}
}
save2 = arr_choice
curr2 = gif_array[arr_choice]
}
if(key == 'i' && keyIsPressed){
let temp = type_choice
while(true){
type_choice = floor(random(0,type_choice_max+1))
if (type_choice != temp){
break;
}
}
}
}