Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.88 KB | None | 0 0
  1. ypos=100
  2. xpos=200
  3. down=1
  4. right=1
  5. go=0
  6. y_speed = 0
  7.  
  8. gravity = 0.98
  9. minusgravity = -0.98
  10.  
  11. def setup():
  12.     size(1500,500)
  13.     noFill()
  14.     strokeWeight(1)    
  15.     background('#000000')
  16.     stroke(250,250,250)
  17.     rect(175,75,1150,350)
  18.    
  19.    
  20.    
  21.  
  22.  
  23. def draw():
  24.  
  25.     global ypos
  26.     global xpos
  27.     global down
  28.     global right
  29.     global go
  30.     global gravity
  31.     global minusgravity
  32.     global y_speed
  33.    
  34.    
  35.     if mousePressed == True:
  36.             xpos=mouseX
  37.             ypos=mouseY
  38.             go= go + 1
  39.     else:
  40.    
  41.         if down==1:
  42.             ypos +=1
  43.         else:
  44.             ypos=ypos-1
  45.    
  46.         if right==1:
  47.             xpos +=1
  48.         else:
  49.             xpos=xpos-1
  50.        
  51.    
  52.         if ypos >=425:
  53.             ypos += 1
  54.       xpos = 200
  55. ypos = 100
  56. down = 1
  57. right = 1
  58. xspeed = random(-6, 10)
  59. yspeed = random(-6, 10)
  60.  
  61. def setup():
  62.     size(1500,500)
  63.     xpos = width/2
  64.     ypos = height/2
  65.     noFill()
  66.     stroke( random(255), random(255), random(255), random(255))
  67.     strokeWeight(1)
  68.     background('#000000')
  69.    
  70.  
  71. def draw():
  72.     global xpos
  73.     global ypos
  74.     global down
  75.     global right
  76.     global xspeed
  77.     global yspeed
  78.  
  79.    
  80.     xpos = xpos + xspeed
  81.     ypos = ypos + yspeed
  82.    
  83.     if xpos > 1325 or xpos < 175:
  84.         xspeed = xspeed * -1
  85.        
  86.     if ypos > 425 or ypos < 75:
  87.         yspeed = yspeed * -1
  88.    
  89.     if down==1:
  90.         ypos +=3
  91.     else:
  92.         ypos = ypos - 4
  93.    
  94.     if right==1:
  95.         xpos +=3
  96.     else:
  97.         xpos = xpos-4
  98.    
  99.     if ypos>=400:
  100.         down=0
  101.     elif ypos<=100:
  102.         down=1
  103.        
  104.     if xpos>=1300:
  105.         right=0
  106.     elif xpos<=200:
  107.         right=1
  108.  
  109.     rect(175,75,1150,350)
  110.     if mousePressed == True:
  111.         ellipse(xpos,ypos,50,50)
  112.     else:
  113.         rect(175,75,1150,350)
  114.         background('#000000')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement