Left Arrow = moves character left Right Arrow = moves character right Enter = changes costume color Backspace = stops music Shift = plays music back "S" Key = changes color of sky
xxxxxxxxxx
//character customs
let bobble_x
let bobble_y
let neck_x
let neck_y
let leg1_x
let leg1_y
let leg2_x
let leg2_y
let cost_x
let costume_ch
let costume_ch2
let costume_ch3
//world custom
let music
let music_rate
let sky_r
function preload(){
music = loadSound ("music.mp3")
}
function setup() {
createCanvas(800, 400);
music.play()
bobble_x = 220
bobble_y = 320
neck_x = 215
neck_y = 335
leg1_x = 205
leg1_y = 350
leg2_x = 225
leg2_y = 370
cost_x = 202
cost_y = 350
costume_ch = 4
costume_ch2 = 34
costume_ch3 = 34
sky_r = 173
}
function draw() {
background(sky_r,216,230);
fill(31,62,0)
ellipse(410,800,1100)
//cloud #1
noStroke()
fill(220)
ellipse(100,110,45)
ellipse(113,87,40)
ellipse(132,110,40)
//cloud #2
ellipse(700,110,45)
ellipse(713,87,40)
ellipse(732,110,40)
//orange building
fill(250,153,23)
rect(2,150,100,300)
noStroke()
fill(0)
square(12,160,20)
square(12,210,20)
square(12,260,20)
square(12,310,20)
square(66,160,20)
square(66,210,20)
square(66,260,20)
square(66,310,20)
rect(34,350,24,64)
//house
fill(255,87,51)
rect(345,250,150,200)
fill(132,65,82)
triangle(345,250,415,125,495,250)
fill(0)
square(355,260,34)
square(450,260,34)
fill(90,55,10)
rect(395,340,44,74)
//building
fill(21,54,78)
rect(695,150,100,300)
fill(0)
square(712,160,20)
square(712,210,20)
square(712,260,20)
square(712,310,20)
square(766,160,20)
square(766,210,20)
square(766,260,20)
square(766,310,20)
rect(734,350,24,64)
//character body
fill(70,20,0)
circle(bobble_x,bobble_y,40)
rect(neck_x,neck_y,12,22)
rect(leg2_x,leg2_y,12,30)
rect(leg1_x,leg1_y,12,62)
//character costume
fill(costume_ch, costume_ch2, costume_ch3)
rect(cost_x,cost_y,40,30)
//text
fill(255)
textSize(52)
text('Start Game',260,100)
}
function keyPressed(){
if(keyCode == LEFT_ARROW){
bobble_x -= 10
neck_x -= 10
leg1_x -= 10
leg2_x -= 10
cost_x -= 10
}
if(keyCode == RIGHT_ARROW){
bobble_x += 10
neck_x += 10
leg1_x += 10
leg2_x += 10
cost_x += 10
}
if(keyCode == ENTER){
costume_ch +=24
costume_ch2 +=34
costume_ch3 +=54
}
if(keyCode == BACKSPACE){
music.stop()
}
if(keyCode == SHIFT){
music.play()
}
}
function keyTyped(){
if (key == 's'){
sky_r += 45
}
}