7
7
8
8
def blitRotate (surf , image , pos , originPos , angle ):
9
9
# offset from pivot to center
10
- image_rect = image .get_rect (topleft = (pos [0 ] - originPos [0 ], pos [1 ] - originPos [1 ]))
10
+ image_rect = image .get_rect (
11
+ topleft = (
12
+ pos [0 ] -
13
+ originPos [0 ],
14
+ pos [1 ] -
15
+ originPos [1 ]))
11
16
offset_center_to_pivot = pygame .math .Vector2 (pos ) - image_rect .center
12
17
13
18
# roatated offset from pivot to center
14
19
rotated_offset = offset_center_to_pivot .rotate (- angle )
15
20
16
21
# roatetd image center
17
- rotated_image_center = (pos [0 ] - rotated_offset .x , pos [1 ] - rotated_offset .y )
22
+ rotated_image_center = (
23
+ pos [0 ] - rotated_offset .x ,
24
+ pos [1 ] - rotated_offset .y )
18
25
19
26
# get a rotated image
20
27
rotated_image = pygame .transform .rotate (image , angle )
@@ -26,21 +33,25 @@ def blitRotate(surf, image, pos, originPos, angle):
26
33
27
34
def blitRotate2 (surf , image , topleft , angle ):
28
35
rotated_image = pygame .transform .rotate (image , angle )
29
- new_rect = rotated_image .get_rect (center = image .get_rect (topleft = topleft ).center )
36
+ new_rect = rotated_image .get_rect (
37
+ center = image .get_rect (
38
+ topleft = topleft ).center )
30
39
31
40
surf .blit (rotated_image , new_rect .topleft )
32
41
pygame .draw .rect (surf , (255 , 0 , 0 ), new_rect , 2 )
33
42
43
+
34
44
def mainLoop (airplaneX , airplaneY ):
35
45
sw , sh = scrn .get_size ()
36
46
iw , ih = (sw * 1.9 , sh * 1.9 )
37
- plane = pygame .image .load ('imagesDirectory/privateJETblue.png' ).convert_alpha ()
47
+ plane = pygame .image .load (
48
+ 'imagesDirectory/privateJETblue.png' ).convert_alpha ()
38
49
planeFlip = pygame .transform .flip (plane , True , False )
39
50
img = pygame .image .load ('imagesDirectory/SpringInYosemite.jpeg' ).convert ()
40
- backgroundImage = pygame .transform .scale (img , (iw ,ih ))
51
+ backgroundImage = pygame .transform .scale (img , (iw , ih ))
41
52
crashed = False
42
- width = 700
43
- height = 300
53
+ width = 700
54
+ height = 300
44
55
rotationAngle = 0
45
56
while not crashed :
46
57
for event in pygame .event .get ():
@@ -55,16 +66,17 @@ def mainLoop(airplaneX, airplaneY):
55
66
if keys [pygame .K_RIGHT ]:
56
67
width = width * 0.999
57
68
height = height * 0.999
58
- airplaneX = airplaneX + 1
69
+ airplaneX = airplaneX + 1
59
70
if keys [pygame .K_LEFT ]:
60
71
width = width * 1.001
61
72
height = height * 1.001
62
- airplaneX = airplaneX - 1
73
+ airplaneX = airplaneX - 1
63
74
if keys [pygame .K_c ]:
64
75
img = pygame .image .load ('imagesDirectory/ct.jpeg' ).convert ()
65
76
backgroundImage = pygame .transform .scale (img , (iw , ih ))
66
77
if keys [pygame .K_g ]:
67
- img = pygame .image .load ('imagesDirectory/SpringInYosemite.jpeg' ).convert ()
78
+ img = pygame .image .load (
79
+ 'imagesDirectory/SpringInYosemite.jpeg' ).convert ()
68
80
backgroundImage = pygame .transform .scale (img , (iw , ih ))
69
81
if keys [pygame .K_y ]:
70
82
img = pygame .image .load ('imagesDirectory/vf.jpeg' ).convert ()
@@ -76,10 +88,12 @@ def mainLoop(airplaneX, airplaneY):
76
88
plane = pygame .image .load ('imagesDirectory/j2.png' ).convert_alpha ()
77
89
planeFlip = pygame .transform .flip (plane , True , False )
78
90
if keys [pygame .K_2 ]:
79
- plane = pygame .image .load ('imagesDirectory/privateJETblue.png' ).convert_alpha ()
91
+ plane = pygame .image .load (
92
+ 'imagesDirectory/privateJETblue.png' ).convert_alpha ()
80
93
planeFlip = pygame .transform .flip (plane , True , False )
81
94
if keys [pygame .K_4 ]:
82
- plane = pygame .image .load ('imagesDirectory/A380.png' ).convert_alpha ()
95
+ plane = pygame .image .load (
96
+ 'imagesDirectory/A380.png' ).convert_alpha ()
83
97
planeFlip = pygame .transform .flip (plane , True , False )
84
98
if keys [pygame .K_a ]:
85
99
img = pygame .image .load ('imagesDirectory/ap.jpeg' ).convert ()
@@ -91,25 +105,24 @@ def mainLoop(airplaneX, airplaneY):
91
105
img = pygame .image .load ('imagesDirectory/a2.jpeg' ).convert ()
92
106
backgroundImage = pygame .transform .scale (img , (iw , ih ))
93
107
if keys [pygame .K_r ]:
94
- rotationAngle = rotationAngle + 1
108
+ rotationAngle = rotationAngle + 1
95
109
backgroundImage = pygame .transform .scale (img , (iw , ih ))
96
- blitRotate (scrn , backgroundImage , (sw / 2 , sh / 2 ), (iw / 2 , ih / 2 ), rotationAngle )
110
+ blitRotate (scrn , backgroundImage , (sw / 2 , sh / 2 ),
111
+ (iw / 2 , ih / 2 ), rotationAngle )
97
112
planeScaled = pygame .transform .scale (planeFlip , (width , height ))
98
- scrn .blit (planeScaled , (airplaneX ,airplaneY ))
113
+ scrn .blit (planeScaled , (airplaneX , airplaneY ))
99
114
pygame .display .flip ()
100
115
101
- pygame .init ()
102
- x = 1792
103
- y = 1080
104
-
105
- scrn = pygame .display .set_mode ((x ,y ))
106
116
107
- pygame .display .set_caption ( 'panorama' )
117
+ pygame .init ()
118
+ x = 1792
119
+ y = 1080
108
120
121
+ scrn = pygame .display .set_mode ((x , y ))
109
122
123
+ pygame .display .set_caption ('panorama' )
110
124
111
125
112
- mainLoop (500 ,500 )
126
+ mainLoop (500 , 500 )
113
127
pygame .quit ()
114
128
quit ()
115
-
0 commit comments