-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSatisfying.py
99 lines (84 loc) · 2.09 KB
/
Satisfying.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import pygame, random
pygame.init()
screen = pygame.display.set_mode((1820, 980))
pygame.display.set_caption("Satisfying")
clock = pygame.time.Clock()
x = random.randint(0, 1820)
y = random.randint(0, 980)
startingX = x
startingY = y
xChange = -1
yChange = -1
xChanged = 0
yChanged = 0
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
FPS = 1000
running = True
while running:
xChanged = 0
yChanged = 0
rec = pygame.Rect(x, y, 5, 5)
pygame.draw.rect(screen, (r, g, b), rec)
#x += xChange
#y += yChange
if xChange < 0:
while xChange < xChanged:
x -= 1
xChanged -= 1
rec = pygame.Rect(x, y, 5, 5)
if yChange < 0:
y -= 1
yChanged -= 1
rec = pygame.Rect(x, y, 5, 5)
pygame.draw.rect(screen, (r, g, b), rec)
elif yChange > 0:
y += 1
yChanged += 1
rec = pygame.Rect(x, y, 5, 5)
pygame.draw.rect(screen, (r, g, b), rec)
elif xChange > 0:
while xChange > xChanged:
x += 1
xChanged += 1
rec = pygame.Rect(x, y, 5, 5)
if yChange < 0:
y -= 1
yChanged -= 1
rec = pygame.Rect(x, y, 5, 5)
pygame.draw.rect(screen, (r, g, b), rec)
elif yChange > 0:
y += 1
yChanged += 1
rec = pygame.Rect(x, y, 5, 5)
pygame.draw.rect(screen, (r, g, b), rec)
if x <= 0 or x >= 1820:
xChange = -xChange
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
if y <= 0 or y >= 980:
yChange = -yChange
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
if x == startingX and y == startingY:
x += 5
startingX += 5
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
screen.fill((0, 0, 0))
x = random.randint(0, 1820)
y = random.randint(0, 980)
startingX = x
startingY = y
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
pygame.display.update()
clock.tick(FPS)
pygame.quit()