67 lines
1.3 KiB
Python
67 lines
1.3 KiB
Python
import pygame
|
|
import random
|
|
from domino import Domino
|
|
|
|
from pygame.locals import (
|
|
K_UP,
|
|
K_DOWN,
|
|
K_LEFT,
|
|
K_RIGHT,
|
|
K_ESCAPE,
|
|
KEYDOWN,
|
|
QUIT,
|
|
MOUSEBUTTONDOWN
|
|
)
|
|
|
|
pygame.init()
|
|
SCREEN_WIDTH = 800
|
|
SCREEN_HEIGHT = 600
|
|
# screen = pygame.display.set_mode((0,0),pygame.FULLSCREEN)
|
|
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
|
|
|
|
x = 100
|
|
y = 100
|
|
all_sprites = pygame.sprite.Group()
|
|
dominos = pygame.sprite.Group()
|
|
for i in range(6):
|
|
|
|
domino = Domino(x, y)
|
|
x += 110
|
|
|
|
dominos.add(domino)
|
|
all_sprites.add(domino)
|
|
|
|
|
|
|
|
pygame.display.flip()
|
|
run = True
|
|
while run:
|
|
|
|
for event in pygame.event.get():
|
|
# Did the user hit a key?
|
|
if event.type == KEYDOWN:
|
|
# Was it the Escape key? If so, stop the loop.
|
|
if event.key == K_ESCAPE:
|
|
run = False
|
|
|
|
# elif event.type == MOUSEBUTTONDOWN:
|
|
|
|
|
|
# Did the user click the window close button? If so, stop the loop.
|
|
elif event.type == QUIT:
|
|
run = False
|
|
|
|
for domino in dominos:
|
|
domino.update(pygame.mouse.get_pos()[0], pygame.mouse.get_pos()[1])
|
|
|
|
|
|
|
|
screen.fill((255, 255, 255))
|
|
|
|
for entity in all_sprites:
|
|
if entity.type == "domino":
|
|
entity.blit_domino(screen)
|
|
else:
|
|
screen.blit(entity.surf, entity.rect)
|
|
|
|
pygame.display.flip() |