Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- posX = 200
- posY = 200
- contadorMousePressed = 0
- def setup():
- size(500, 500)
- def draw():
- global posX, posY
- # pintamos el fondo
- colorDeFondo(posX, posY)
- fill(0)
- square(450, 450, 50)
- # Fondo color rojo para visualizar el área que queremos utilizar
- fill(255, 0, 0)
- rect(0, 450, 450, 500)
- # Fondo color verde para visualizar el área que queremos utilizar
- fill(0, 255, 0)
- rect(450, 0, 500, 450)
- # Cuadritos para el scroll horizontal y vertical
- fill(128)
- square(posX, 450, 50)
- square(450, posY, 50)
- # if mousePressed:
- # if mouseY > 450 and mouseX < 450:
- # posX = mouseX - 25 # modificar la variable global posX
- # if posX <= 0: # Límites
- # posX = 0
- # elif posX >= 400:
- # posX = 400
- # elif mouseX > 450 and mouseY < 450:
- # posY = mouseY - 25 # modificar la variable global posY
- # if posY <= 0: # Límites
- # posY = 0
- # elif posY >= 400:
- # posY = 400
- def colorDeFondo(var0, var1):
- color1 = map(var0, 0, 400, 0, 255)
- color2 = map(var1, 0, 400, 255, 0)
- background(0, color2, color1)
- #####################################
- # Debuggeo de coordenadas
- #####################################
- # print(mouseX, mouseY)
- # print(posX)
- # print(posY)
- # 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 contadorMousePressed
- contadorMousePressed += 1
- print(contadorMousePressed)
- checkMouse()
- def mouseDragged():
- print("Dragged")
- checkMouse()
- def checkMouse():
- global posX, posY
- if mouseY > 450 and mouseX < 450:
- posX = mouseX - 25
- if posX <= 0:
- posX = 0
- elif posX >= 400:
- posX = 400
- elif mouseX > 450 and mouseY < 450:
- posY = mouseY - 25
- if posY <= 0:
- posY = 0
- elif posY >= 400:
- posY = 400
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement