Advertisement
kekellner

Prueba

Mar 18th, 2021
1,369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.43 KB | None | 0 0
  1. posX = 200
  2.  
  3. def setup():
  4.     size(500,500)
  5.     background(0)
  6.     # fill(255)
  7.     # rect(0,450,450,500)
  8.  
  9.    
  10. def draw():
  11.     global posX
  12.     changeColor(posX)
  13.     # background(0)
  14.     fill(255)
  15.     rect(0,450,450,500)
  16.     # rect(450,0,500,450)
  17.     fill(128)    
  18.     square(posX, 450, 50)
  19.     # square (X, Y, size)
  20.    
  21.     #print(mouseX, mouseY)
  22.     #print(posX)
  23.    
  24.     if mousePressed:
  25.         if mouseY > 450:
  26.             posX = mouseX - 25
  27.             if posX <= 0:
  28.                 posX = 0
  29.             elif posX >= 400:
  30.                 posX = 400
  31.  
  32. #######################################################################
  33.  
  34. def changeColor(var0):
  35.     newColor = map(var0, 0, 400, 0, 255)
  36.     # print (var0, newColor)
  37.     background(newColor) # 0 - 255
  38.  
  39.  
  40.     # generalmente NO queremos dibujar dentro de estos eventos, porque
  41.     # no sabemos en qué momento exactamente el usuario va a mandar a
  42.     # llamar uno
  43. # def mousePressed():
  44. #     global posX
  45. #     print("mousePressed() se ejecuto una vez")
  46. #     if mouseY > 450:
  47. #         posX = mouseX - 25
  48. #         if posX <= 0:
  49. #             posX = 0
  50. #         elif posX >= 400:
  51. #             posX = 400
  52.            
  53. # def mouseDragged():
  54. #     global posX
  55. #     print("mouseDragged() se ejecuto una vez")
  56. #     if mouseY > 450:
  57. #         posX = mouseX - 25
  58. #         if posX <= 0:
  59. #             posX = 0
  60. #         elif posX >= 400:
  61. #             posX = 400
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement