xxxxxxxxxx
let stars = []
let colours = [
'white',
'grey',
'black',
'yellow',
'red']
function createStars() {
for (let i = 1; i < 1000; i++) {
let star = {
x: random(0, windowWidth),
y: random(0, windowHeight),
x1: random(5,10),
speed: random(1,5),
colour: random(colours)
}
stars.push(star)
}
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
createStars()
}
function draw() { //called 60 times per second
background('navy')
for (let star of stars) {
drawStar(star)
}
for (let star of stars) {
moveStar(star)
}
}
function drawStar(star) {
stroke(star.colour)
line(star.x, star.y, star.x + mouseY/100*(star.speed),star.y);
fill('white')
textSize(star.x1)
text('K', star.x, star.y)
}
function moveStar(star) {
let speedScaling = mouseY/100; //0-1000
star.x += speedScaling*(star.speed)
if (star.x >= width) {
star.x = -20
}
}
//TASKS: get lines to be longer as they get faster, bubbles going up (outline of bubble)