User:Ozalp Eroz/pygame oz

From XPUB & Lens-Based wiki

import sys, pygame pygame.init()

width, height = (400, 400) screen = pygame.display.set_mode((width, height)) clock = pygame.time.Clock()

(rx, ry) = (0, 0) (dx, dy) = (0, 0)

def slide (start, end, slider): x= ((end-start)*slider)+start

       return x

while True:


   for event in pygame.event.get():
       if event.type == pygame.QUIT or \
         (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
           sys.exit()
   mx, my = pygame.mouse.get_pos()
  		
   mx, my = pygame.mouse.get_pos()
   
   xslider = float(mx) / width
   yslider = float(my) / height
   screen.fill((255, 255, 255))


   dx = (0.91 * dx) + (0.05 * (mx - rx))
   rx += dx
   dy = (0.91 * dy) + (0.05 * (my - ry))
   ry += dy
   ry = abs(ry)
   print ry
   
   if ry < 1:
       ry= 1
       
   if rx < 1:
       rx= 1
   
   if ry > 50: 
       pygame.draw.circle(screen, (0, 0, 0), (200, 200), (ry),1)
       pygame.draw.circle(screen, (0, 0, 0), (200, 200), (rx+15),1)
       pygame.draw.circle(screen, (0, 0, 0), (200, 200), (rx+45),1)
       pygame.draw.circle(screen, (0, 0, 0), (200, 200), (rx+100),1)
       pygame.draw.circle(screen, (0, 0, 0), (200, 200), (ry+15),1)
       pygame.draw.circle(screen, (0, 0, 0), (200, 200), (ry+30),1)
       pygame.draw.circle(screen, (0, 0, 0), (200, 200), (ry+45),1)
       
   
   p = int((1.0 - xslider) * (width - 50))


   pygame.display.flip()


   clock.tick(100)