Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- from pygame import Vector2, Rect
- from pygame.locals import *
- class control:
- def __init__(s, px, py):
- global PDR
- pos = Vector2(px * PDR.w, py * PDR.h)
- s.r = Rect(pos - (100, 100), (200, 200))
- pygame.init()
- PDS = pygame.display.set_mode()
- PDR = PDS.get_rect()
- BLACK = (0, 0, 0)
- WHITE = (255, 255, 255)
- controls = {}
- while True:
- events = pygame.event.get()
- for e in events:
- if e.type == FINGERDOWN:
- controls[e.finger_id] = control(e.x, e.y)
- if e.type == FINGERUP:
- del controls[e.finger_id]
- PDS.fill(BLACK)
- for fid, c in controls.items():
- pygame.draw.rect(PDS, WHITE, c.r)
- pygame.display.update()
- pygame.time.Clock().tick(60)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement