Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- posX = 200
- def setup():
- size(500,500)
- background(0)
- # fill(255)
- # rect(0,450,450,500)
- def draw():
- global posX
- changeColor(posX)
- # background(0)
- fill(255)
- rect(0,450,450,500)
- # rect(450,0,500,450)
- fill(128)
- square(posX, 450, 50)
- # square (X, Y, size)
- #print(mouseX, mouseY)
- #print(posX)
- if mousePressed:
- if mouseY > 450:
- posX = mouseX - 25
- if posX <= 0:
- posX = 0
- elif posX >= 400:
- posX = 400
- #######################################################################
- def changeColor(var0):
- newColor = map(var0, 0, 400, 0, 255)
- # print (var0, newColor)
- background(newColor) # 0 - 255
- # generalmente NO queremos dibujar dentro de estos eventos, porque
- # no sabemos en qué momento exactamente el usuario va a mandar a
- # llamar uno
- # def mousePressed():
- # global posX
- # print("mousePressed() se ejecuto una vez")
- # if mouseY > 450:
- # posX = mouseX - 25
- # if posX <= 0:
- # posX = 0
- # elif posX >= 400:
- # posX = 400
- # def mouseDragged():
- # global posX
- # print("mouseDragged() se ejecuto una vez")
- # if mouseY > 450:
- # posX = mouseX - 25
- # if posX <= 0:
- # posX = 0
- # elif posX >= 400:
- # posX = 400
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement