#imports from libraries import pygame,sys from pygame import * from sys import * from random import randint #set up colors WHITE = (255, 255, 255) BLUE = ( 0, 0, 255) GREEN = ( 0, 255, 0) RED = (255, 0, 0) TEXTCOLOR = ( 0, 0, 0) NEWCOLO= (0,15,15) backo = NEWCOLO bkg = WHITE clr = (0, 0, 0) squ = (8, 11, 134) #localisation x = 400 y = 300 #aims loc xc1 = randint(180,400) yc1 = randint(120,300) xc2 = randint(400,620) yc2 = randint(300,455) xc3 = randint(180,400) yc3 = randint(300,455) xc4 = randint(400,620) yc4 = randint(120,300) co1=[xc1,yc1] co2=[xc2,yc2] co3=[xc3,yc3] co4=[xc4,yc4] #aims size aimExt=17 aimInt=12 #weapon value aim=0 #window/font set up pygame.init() size = (800, 600) screen = pygame.display.set_mode(size) pygame.display.set_caption("Bloxy") pygame.key.set_repeat(1, 1) font = pygame.font.SysFont("Stencil", 20) clock = pygame.time.Clock() while True: #window management for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() #key pos/activation keys_pressed = pygame.key.get_pressed() if keys_pressed[pygame.K_LEFT]: x -= 5 if keys_pressed[pygame.K_RIGHT]: x += 5 if keys_pressed[pygame.K_UP]: y -= 5 if keys_pressed[pygame.K_DOWN]: y += 5 if event.type==pygame.KEYDOWN: if event.key==pygame.K_RETURN: aim = 1 if x > 800: x = 0 if x < 0: x = 800 if y > 600: y = 0 if y < 0: y = 600 #collisions (WIP) #else: # colliding=z1.colliderect(z) screen.fill(backo) #aims and circle set up cont=pygame.draw.circle(screen, BLUE, [400 , 300 ], 298) pygame.draw.circle(screen, bkg, [400 , 300 ], 278) pygame.draw.circle(screen, RED, co1, aimExt) aim1=pygame.draw.circle(screen, bkg, co1, aimInt) pygame.draw.circle(screen, RED, co2, aimExt) aim2=pygame.draw.circle(screen, bkg, co2, aimInt) pygame.draw.circle(screen, RED, co3, aimExt) aim3=pygame.draw.circle(screen, bkg, co3, aimInt) pygame.draw.circle(screen, RED, co4, aimExt) aim4=pygame.draw.circle(screen, bkg, co4, aimInt) #pos of user text = font.render('(' + str(x) + ',' + str(y) + ')', True, clr) screen.blit(text, [10, 10]) #pygame.draw.rect(screen, squ, [x - 10, y - 10, 20, 20]) user=pygame.draw.circle( screen, GREEN, [x , y ], 10) #Borders ct=pygame.Rect(cont) a1=pygame.Rect(aim1) a2=pygame.Rect(aim2) a3=pygame.Rect(aim3) a4=pygame.Rect(aim4) u=pygame.Rect(user) #distance print(DM) aim=0 pygame.display.flip() clock.tick(30)