Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame,random,sys
- pygame.init()
- ball = "C:\ws\Testing ground\ball.ogg"
- bounce = pygame.mixer.Sound(ball)
- font = pygame.font.SysFont("timesnewroman", 20)
- white = (255,255,255)
- black = (0,0,0)
- red = (255,0,0)
- blue = (0,0,255)
- green = (0,255,0)
- # ODREĐUJE DIMENZIJE ZASLONA
- x = 600
- y = 700
- z = [x,y]
- win = pygame.display
- # ODREĐUJE POKRETANJE TIPKI
- move_x, move_y = 0,0
- change_x, change_y = 0,0
- # DAJE NASLOV ZASLONA
- win.set_caption("IGRA RIJEČI!")
- # POVRŠINA ZASLONA
- surface = win.set_mode(z)
- python = pygame.image.load("C:\ws\Testing ground\lol.jpg")
- window = True
- #python_x,python_y = 200,200
- clock = pygame.time.Clock()
- click = 0
- colors = [white,red,blue,green]
- fill = white
- text_color = black
- circle_x, circle_y = x//2,y//2
- while window:
- font = pygame.font.SysFont("timesnewroman", 20)
- text = font.render("Start", 0, text_color)
- for event in pygame.event.get():
- c_x,c_y = pygame.mouse.get_pos()
- if event.type == pygame.QUIT:
- pygame.quit()
- sys.exit()
- # window = False
- #surface.fill(white)
- #surface.blit(python,(python_x,python_y))
- # Tipke za pokret.
- if event.type == pygame.MOUSEBUTTONDOWN:
- #python_x,python_y = random.randint(100,500),random.randint(100,600)
- if ((300-c_x)**2+(400-c_y)**2) < 2500:
- text_color = white
- move_x,move_y = random.randint(-20,20),random.randint(-20,20)
- #fill = random.choice(colors)
- circle_x += move_x
- circle_y += move_y
- # if event.type == pygame.KEYDOWN:
- # if event.key == pygame.K_LEFT:
- # change_x -= 5
- # if event.key == pygame.K_RIGHT:
- # change_x += 5
- # if event.key == pygame.K_UP:
- # change_y -= 5
- # if event.key == pygame.K_DOWN:
- # change_y += 5
- # if event.type == pygame.KEYUP:
- # if event.key == pygame.K_DOWN or event.key == pygame.K_UP:
- # change_y = 0
- # if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
- # change_x = 0
- # Izrada za odbijanje od stranice
- if circle_x < 55 or circle_x > 545:
- move_x = -move_x
- if circle_y < 55 or circle_y > 645:
- move_y = -move_y
- #move_x += change_x
- #move_y += change_y
- surface.fill(fill)
- surface.blit(text,(x//2-19,y//2-12))
- pygame.draw.rect(surface,black,(5,5,590,690),3)
- pygame.draw.circle(surface,black,(circle_x,circle_y),50,1)
- movement = pygame.mouse.get_pos()
- #surface.blit(python,(move_x,move_y))
- win.update()
- clock.tick(10)
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement