-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest_file.py
More file actions
74 lines (59 loc) · 2.01 KB
/
Test_file.py
File metadata and controls
74 lines (59 loc) · 2.01 KB
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
import pygame as pg
import sys
import os
FPS = 30
def terminate():
pg.quit()
sys.exit()
def load_image(name, colorkey=None):
path = os.path.join('logo and icon', name)
if not os.path.isfile(path):
terminate()
image = pg.image.load(path)
if colorkey is not None:
image = image.convert()
if colorkey == -1:
colorkey = image.get_at((0, 0))
image.set_colorkey(colorkey)
else:
image = image.convert_alpha()
return image
class AnimatedSprite(pg.sprite.Sprite):
def __init__(self, right, top, width, height, image, *group):
super().__init__(*group)
self.image = pg.transform.scale(load_image(image), (width, height))
self.rect = self.image.get_rect(right=right, top=top)
def movement_1(self):
print(self.rect)
self.rect = self.rect.move(5, 0)
def movement_2(self):
pass
class Intro:
def __init__(self, width, height, sprite_width, sprite_height):
pg.init()
self.size = self.width, self.height = width, height
self.screen = pg.display.set_mode(self.size)
self.clock = pg.time.Clock()
self.all_sprites = pg.sprite.Group()
self.sprite = AnimatedSprite(0, height // 2, sprite_width, sprite_height,
'logo.png', self.all_sprites)
self.main_cycle()
def main_cycle(self):
cur_frame = 0
while True:
for event in pg.event.get():
if event.type == pg.QUIT:
terminate()
self.clock.tick(FPS)
self.screen.fill((255, 255, 255))
if cur_frame > 59:
self.all_sprites.update()
self.all_sprites.draw(self.screen)
if self.sprite.rect.centerx < self.width // 2:
self.sprite.movement_1()
else:
# create_particles()
pass
cur_frame += 1
pg.display.flip()
intro = Intro(800, 700, 300, 50)