i deployed p5.widget on http://118.24.137.218/pw.html
and i paste some code which could run on my windows 10 chrome browser through vscode live server extension just live below:
var colors = ['red', 'blue', 'green', 'black'];
var tip_color = '';
var tip = '';
var score = 0;
function random_index(){
return Math.floor(Math.random() * colors.length);
}
function setup(){
var p = createCanvas(300, 400);
p.parent('canvas')
tip = colors[random_index()]
tip_color = colors[random_index()]
// print(random_index())
}
function draw(){
background(200);
textSize(50)
fill(tip_color)
text(tip, 80, 200)
fill('black');
textSize(30)
text('Wrong', 50, 380)
text('Right', 180, 380)
text(str(score), 50,50)
textSize(10)
text('Special For vicia',0, 395)
}
function mouseClicked(){
console.log(tip)
console.log(tip_color)
if(mouseX>150){
if(tip == tip_color){
score += 1;
}else{
score -= 1;
}
}else{
if(tip == tip_color){
score -= 1;
}else{
score += 1;
}
}
tip = colors[random_index()]
tip_color = colors[random_index()]
}
but a got an error
i could not figure out anything wrong for it's too dificullt for me .
i deployed p5.widget on http://118.24.137.218/pw.html and i paste some code which could run on my windows 10 chrome browser through vscode live server extension just live below:
but a got an error i could not figure out anything wrong for it's too dificullt for me .