<html>
<head>
<script src="https://cdn.jsdelivr.net/gh/bmoren/p5.collide2D@0.6/p5.collide2d.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/addons/p5.dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/addons/p5.sound.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/addons/p5.sound.min.js"></script>
<script src="p5.collide2d.min.js"></script>
<script src="player.js"></script>
<script src="obstacle.js"></script>
<script src="sketch.js"></script>
</head>
<body>
<script>
let words = ["Year 10 Digitech", "Schmerl Presents", "Coding is Fun"]
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
// expected output: 0, 1 or 2
let myNumber = getRandomInt(3);
let word = words[myNumber];
let index = 0;
function setup() {
createCanvas(400, 400);
frameRate(1);
}
function draw() {
background(220);
textSize(10);
fill(0);
text("Word :: " + word.toUpperCase(), 20,15);
text("Word Length :: " + word.length, 170,15);
text("Index :: " + " " + index + " = " + word[index], 320,15);
for(let i = 0; i< word.length; i++){
if(i == index){
fill(255,0,0);
textSize(15);
}
else{
fill(0);
textSize(10);
}
text(word[i], random(width-50)+25, random(height-70)+50);
text(word[i], width/4 + 12*i, 40);
}
index++;
if(index >= word.length){
index = 0;
}
}
</script>
</body>
</html>