Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from math import fabs
- import pygame
- import random
- from pygame.locals import *
- pygame.init()
- pygame.font.init()
- cell = []
- def randomize(m, n):
- k = random.randint(m, n)
- if (k not in cell) & (k != None):
- cell.append(k)
- return k
- else:
- randomize(m, n)
- for i in range(4):
- randomize(0,3)
- randomize(4,7)
- randomize(8,11)
- randomize(12,15)
- WHITE = [255, 255, 255]
- screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
- pygame.display.set_caption("Hello my darling. This is only for you")
- gameIcon = pygame.image.load('Heart.png')
- pygame.display.set_icon(gameIcon)
- heart = pygame.image.load(os.path.join("Heart.png"))
- heart.convert()
- hearts_positioning = []
- for i in range(12):
- x = random.randrange((cell[i]%4)*400, ((cell[i]%4)+1)*400)
- y = random.randrange(((cell[i]//4)*(-300)-300) , (cell[i]//4)*(-300))
- s = random.randint(2,4)
- if s > 2:
- z = random.randint(-1,1)
- hearts_positioning.append([x, y, s, z])
- else:
- hearts_positioning.append([x, y, s, 0])
- clock = pygame.time.Clock()
- done = False
- while not done:
- for event in pygame.event.get():
- if event.type == pygame.locals.KEYDOWN:
- if (event.key == K_ESCAPE):
- done = True
- screen.fill(WHITE)
- for i in range(len(hearts_positioning)):
- screen.blit(heart, (hearts_positioning[i][0], hearts_positioning[i][1]))
- hearts_positioning[i][1] += hearts_positioning[i][2]
- hearts_positioning[i][0] += hearts_positioning[i][3]
- if hearts_positioning[i][1] > 1080:
- y = random.randrange(((cell[i]//4)*(-300)-300) , (cell[i]//4)*(-300))-300
- hearts_positioning[i][1] = y
- x = random.randrange((cell[i]%4)*400, ((cell[i]%4)+1)*400)
- hearts_positioning[i][0] = x
- s = random.randint(2, 4)
- hearts_positioning[i][2] = s
- if s > 2:
- z = random.randint(-1, 1)
- hearts_positioning[i][3]= z
- else:
- hearts_positioning[i][3]= 0
- pygame.display.flip()
- clock.tick(60)
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement