/
7cell_brief2.py
54 lines (48 loc) · 1.5 KB
/
7cell_brief2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import pygame, sys
from time import sleep
from pygame.locals import *
from random import shuffle
clock = pygame.time.Clock()
FPS = 30
playtime = 0.0
counter = 0
pygame.font.init()
font = pygame.font.Font(None, 30)
batch_size = 7
tiles = {}
pygame.init()
sizex=1920
sizey=1080
xdivision = 16
ydivision = 9
xshuf = [i for i in range(xdivision*ydivision)]
unitx = sizex/xdivision
unity = sizey/ydivision
screen = pygame.display.set_mode((sizex, sizey))
background = pygame.image.load('data/plastic_reality.png')
im2= pygame.Surface(screen.get_size())
#im2.fill((0, 0, 0))
im2 = pygame.image.load('data/excavation.jpg')
pygame.display.flip()
while True:
milliseconds = clock.tick(FPS)
playtime += milliseconds / 1000.0
shuffle(xshuf)
for i in range(0,7):
random_value = xshuf[i]
randomx,randomy = divmod(random_value, ydivision)
randomx *= unitx
randomy *= unity
# print ("%f,%f" % (randomx,randomy))
screen.blit(background, (randomx, randomy), pygame.Rect(randomx, randomy, unitx, unity))
text_surface = font.render("FPS: %f Playtime: %f " % (clock.get_fps(),playtime), True, (255,255,255))
screen.blit(text_surface, (10, 10))
pygame.display.flip()
sleep(1)
for i in range(0,7):
random_value = xshuf[i]
randomx,randomy = divmod(random_value, ydivision)
randomx *= unitx
randomy *= unity
screen.blit(im2, (randomx, randomy), pygame.Rect(randomx, randomy, unitx, unity))
pygame.display.flip()