xxxxxxxxxx
let oscar2_y
var oscar1
var oscar2
var room
var ocean
function preload(){
oscar1 = loadImage ("oscar1.png")
oscar2 = loadImage ("oscar2.gif")
room = loadImage ("room.jpg")
ocean = loadSound ("ocean.m4a")
}//end preload
function setup() {
createCanvas(600, 600);
imageMode(CENTER)
ocean.play()
image_number = 1
oscar1_x = 100
oscar1_y = 190
}//end setup
function draw() {
drawBackground()
drawoscar1()
} //end draw
function drawoscar1(){
if(image_number==1){
image(oscar1,oscar1_x,oscar1_y,70,70)
textSize(20);
fill(0);
stroke(255, 255, 255);
strokeWeight(8);
text('Help Oscar find Bea. Use the "w,a,s,d" keys to move Oscar.', 60, 140)
}//end if 1
if(image_number==2){
image(oscar2,300,300,350,300)
}//end if 2
}//end drawoscar1
function drawBackground(){
image(room,250, 300,700, 400)
}//end drawBackground
function keyPressed(){
if(key =='a'){
oscar1_x-=10
}
if(key =='d'){
oscar1_x+=10
}
if(key =='w'){
oscar1_y-=10
}
if(key =='s'){
oscar1_y+=10
}
if(oscar1_x==350){
image_number=2
}
print(oscar1_x)
}//end keyPressed
function keyTyped(){
if(key== "1"){
image_number =1
}//end if 1
if(key== "2"){
image_number =2
}//end if 2
}//end keyTyped