I’m having some trouble. I’m trying to create a function where you place the sprite on a red rectangle (or the weighted cube on the button), the door function should be set to true. But this is only working on my second level where this function is first used. Here is my code.
function level2()
background(50, 61, 130, 255)
level2Paint()
if zx>ex and ey<zy and dx>sx-20 and dx<sx+20 and dy>sy-20 and dy<sy+20 then
sx = vx
sy = vy
lv=lv+1
end
sprite("Documents:Cube",zx,zy,50,50)
--in Portal?
if dx>sx+20 and dx<sx+20 and dy>sy-20 and dy<sy+20 then
sx = vx
sy = vy
--in case xport elipse overlaps portals
moved=true
moved1=true
end
end
-- when character and object are in the portal at the same time moved variables get messed
function level3Paint()
pushMatrix()
fill(255, 255, 255, 255)
stroke(0, 0, 0, 255)
strokeWidth(3)
rect(0,50,2000,15)
popMatrix()
pushMatrix()
fill(255, 255, 255, 255)
stroke(0, 0, 0, 255)
strokeWidth(3)
rect(0,370,2000,15)
popMatrix()
pushMatrix()
rotate(90)
fill(255, 255, 255, 255)
stroke(0, 0, 0, 255)
strokeWidth(3)
rect(50, -500,2000,15)
popMatrix()
pushMatrix()
fill(181, 141, 64, 255)
stroke(255, 105, 0, 255)
strokeWidth(2)
ellipse(px,py,60,120)
fill(64, 76, 181, 255)
stroke(0, 17, 255, 255)
strokeWidth(2)
ellipse(hx,hy,60,120)
fill(47, 47, 47, 255)
stroke(255, 255, 255, 255)
strokeWidth(2)
ellipse(dx,dy,120,120)
popMatrix()
pushMatrix()
fill(255, 0, 0, 255)
stroke(0, 0, 0, 255)
strokeWidth(1)
rect(lx,ly,80,15)
popMatrix()
pushMatrix()
end
function level3()
background(66, 78, 120, 255)
level3Paint()
if fx<lx and ly>fy and dx<sx-20 and dx>sx+20 and dy<sy-20 and dy>sy+20 then
sx = vx
sy = vy
lv=lv+1
end
sprite("Documents:Cube",fx,fy,50,50)
end