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 *
- WHITE = 16777215
- BLACK = 0
- pygame.init()
- PDR = Rect(0, 0, 1280, 720)
- PDS = pygame.display.set_mode(PDR.size)
- boundry_pos = Vector2(PDR.center)
- boundry_radius = 200
- crosshair_pos = Vector2(PDR.center)
- exit_demo = False
- while not exit_demo:
- for e in pygame.event.get():
- if e.type == KEYUP and e.key == K_ESCAPE:
- exit_demo = False
- crosshair_pos = Vector2(pygame.mouse.get_pos())
- distance = boundry_pos.distance_to(crosshair_pos)
- if distance >= boundry_radius:
- degrees = Vector2().angle_to(crosshair_pos - boundry_pos)
- crosshair_pos = Vector2(PDR.center) + Vector2(1, 0).rotate(degrees) * boundry_radius
- PDS.fill(BLACK)
- pygame.draw.circle(PDS, WHITE, PDR.center, boundry_radius, 2)
- pygame.draw.line(PDS, WHITE, crosshair_pos - (0, 25), crosshair_pos + (0, 25))
- pygame.draw.line(PDS, WHITE, crosshair_pos - (25, 0), crosshair_pos + (25, 0))
- pygame.display.update()
- pygame.time.Clock().tick(120)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement