Add files via upload

This commit is contained in:
2023-05-04 11:41:43 +03:00
parent 990f492c99
commit 171324f2b9

73
main.py
View File

@ -1,6 +1,6 @@
# imports # imports
# import keyboard as kb # import keyboard as kb
# import time import time
import random import random
import pygame as pg import pygame as pg
@ -9,36 +9,81 @@ pg.init()
# variables # variables
sw = 960 # screen width sw = 1280 # screen width
sh = 540 # screen height sh = 720 # screen height
PINK = (255, 120, 220) PINK = (255, 120, 220)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
ez_font = pg.font.SysFont('Comic Sans MS', 15)
# functions # functions
def draw(n): def draw(n):
pass pass
# main
screen = pg.display.set_mode([sw, sh]) # first is x. Second - y.
running = True
c = 0
while running:
circlex = random.randint(50, sw - 50)
circley = random.randint(50, sh - 50)
# main
screen = pg.display.set_mode([sw, sh]) # first is x. Second - y.
running = True
cc = 0
pc = 0
radius = 60
circlex = random.randint(100, sw - 50)
circley = random.randint(80, sh - 50)
while running:
screen.fill((0, 0, 0)) screen.fill((0, 0, 0))
if cc != 0 or pc != 0:
radius = 60 * (1.4 - round(cc/(cc+pc), 3))
else:
radius = 60
objcounter = 0 objcounter = 0
for i in range(objcounter): for i in range(objcounter):
draw(i) draw(i)
pg.draw.circle(screen, PINK, (circlex, circley), 50)
pg.draw.circle(screen, BLUE, (circlex, circley), radius)
pg.display.set_caption('AimBee')
information_line1 = 'Circles popped ' + str(cc)
information_line2 = 'Shots missed ' + str(pc)
information_line3 = 'Shots made ' + str(cc + pc)
if cc != 0 or pc != 0:
information_line4 = 'Percentage ' + str(round(cc/(cc+pc)*100, 3)) + '%'
else:
information_line4 = 'Percentage ' + '-' + '%'
text_surface1 = ez_font.render(information_line1, True, WHITE)
text_surface2 = ez_font.render(information_line2, True, WHITE)
text_surface3 = ez_font.render(information_line3, True, WHITE)
text_surface4 = ez_font.render(information_line4, True, WHITE)
screen.blit(text_surface1, (10, 10))
screen.blit(text_surface2, (10, 30))
screen.blit(text_surface3, (10, 50))
screen.blit(text_surface4, (1140, 10))
for event in pg.event.get(): for event in pg.event.get():
if event.type == pg.QUIT: if event.type == pg.QUIT:
running = False running = False
if event.type == pg.MOUSEBUTTONDOWN and event.pos == (circlex, circley): if event.type == pg.MOUSEBUTTONDOWN and ((circlex-radius < event.pos[0] < circlex+radius) and (circley-radius < event.pos[1] < circley+radius)):
c += 1 print(event.pos)
print(c) circlex = random.randint(100, sw - 50)
circley = random.randint(80, sh - 50)
cc += 1
print(cc)
elif event.type == pg.MOUSEBUTTONDOWN:
pc += 1
pg.display.flip() pg.display.flip()