Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame, random
- class Target(pygame.sprite.Sprite):
- def __init__(self):
- super().__init__()
- self.image = pygame.Surface((45,45))
- self.image.fill((255,255,0))
- self.rect = self.image.get_rect()
- self.x = random.randrange(20, 1004)
- self.y = random.randrange(20, 748)
- self.rect.center = (self.x, self.y)
- class crosshair(pygame.sprite.Sprite):
- def __init__(self):
- super().__init__()
- self.image = pygame.Surface((10,10))
- self.image.fill((255,0,0))
- self.rect = self.image.get_rect()
- self.rect.center = (0, 0)
- def update(self):
- position = pygame.mouse.get_pos()
- self.rect.center = position
- pygame.init()
- window = pygame.display.set_mode((1024, 768))
- run = True
- pygame.mouse.set_visible(False)
- aim = crosshair()
- sprites = pygame.sprite.Group()
- sprites.add(aim)
- while run:
- window.fill((0,0,0))
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- run = False
- sprites.update()
- sprites.draw(window)
- pygame.display.update()
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement