• isabellerieken

Shoot for the Stars

Updated: Jan 17

Preview: https://editor.p5js.org/izzy_rieken/present/mIjun13yf

Editor: https://editor.p5js.org/izzy_rieken/sketches/mIjun13yf


let y = 0; let x = 0; let count = 0 let star = [50]; let starCount = 0 let numstar = 50 function setup() { createCanvas(500, 800); } function draw() { background('#1D4B5B'); rocketship(x,0); button1();//power up button2();//power down fill(250) if (count%10 === 0){ star[starCount] = new Star(); starCount +=1 starCount=starCount%numstar } for (let i = 0; i < star.length; i++) { star[i].move(); star[i].display(); } count += 1; if (keyIsDown(RIGHT_ARROW)) { x += 5; } if (keyIsDown(LEFT_ARROW)) { x -= 5; } } function button1(){ var button; button = createButton('power up'); button.position(19, 19); button.mousePressed(loop); } function button2(){ var button; button = createButton('power down'); button.position(19, 39); button.mousePressed(noLoop); } function movers(x,y) { let xspeed = 5; let yspeed = 2; rocketship(x, y) x += xspeed; y += yspeed; if (x > width - r || x < r) { xspeed = -xspeed; } if (y > height - r || y < r) { yspeed = -yspeed; } } function rocketship(x,y) { background('#1D4B5B'); noStroke() fill('#F18805') ellipse(x+250,y+400,60,120)//outerflame fill('#F0A202') ellipse(x+250,y+400,30,80)//innerflame fill('#d1432a') triangle(x+250,y+160,x+295,y+250,x+205,y+250); //tip fill('#b0b8b7') rect (x+218,y+250,65,130);//body fill('#50A2A7') triangle(x+218,y+380,x+195,y+380,x+218,y+330);//fin1 fill('#50A2A7') triangle(x+283,y+380,x+306,y+380,x+283,y+330);//fin2 strokeWeight(4) stroke('#dedede') fill('#83c5c9') ellipse(x+250,y+280,32,32)//window1 ellipse(x+250,y+330,32,32)//window2 noStroke() fill('#7C8483') rect(x+218,y+380,65,20)//exhaustrect triangle(x+218,y+380,x+210,y+400,x+218,y+400)//exhausttri1 triangle(x+283,y+380,x+291,y+400,x+283,y+400)//exhausttri2 } // Jitter class of stars class Star { constructor() { this.x = random(width); this.y = 0; this.diameter = random(1, 4); this.speed = 10; } move() { //this.x += random(-this.speed, this.speed); this.y += this.speed; } display() { ellipse(this.x, this.y, this.diameter, this.diameter); } }