Repository navigation
Expand file tree
/
Copy pathfirstGame.py
More file actions
1256 lines (991 loc) · 29.1 KB
/
Copy pathfirstGame.py
File metadata and controls
1256 lines (991 loc) · 29.1 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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""Space Invaders, adapted for macOS/Python 3.
Controls:
Left/Right or A/D: move
Space: start/shoot
R: return to menu after game over
Escape: quit
Optional: place the original assets/ folder next to this file.
"""
import os
from pathlib import Path
import random
os.environ.setdefault("SDL_VIDEO_CENTERED", "1")
import pygame
ASSET_DIR = Path(__file__).resolve().parent / "assets"
missing_assets = set()
pygame.mixer.pre_init(
frequency=44100,
size=-16,
channels=2,
buffer=512,
)
pygame.init()
if pygame.mixer.get_init():
pygame.mixer.set_num_channels(32)
win_height = 600
win_width = 800
win = pygame.display.set_mode((win_width, win_height))
pygame.display.set_caption("Pygame: Space Invaders")
def load_font(size):
path = ASSET_DIR / "fonts" / "unifont.ttf"
try:
return pygame.font.Font(str(path), size)
except (OSError, pygame.error):
missing_assets.add(str(path.relative_to(ASSET_DIR)))
return pygame.font.Font(None, size)
class SilentSound:
"""Keep the game working without sound files or an audio device."""
def play(self, *args, **kwargs):
return None
def stop(self):
pass
def set_volume(self, volume):
pass
def load_sound(filename):
if not pygame.mixer.get_init():
return SilentSound()
path = ASSET_DIR / "nSounds" / filename
try:
return pygame.mixer.Sound(str(path))
except (OSError, pygame.error):
missing_assets.add(str(path.relative_to(ASSET_DIR)))
return SilentSound()
def play_sound(sound, loops=0):
if isinstance(sound, SilentSound) or not pygame.mixer.get_init():
return
channel = pygame.mixer.find_channel()
if channel is not None:
channel.play(sound, loops=loops)
font = load_font(16)
big_font = load_font(64)
def fallback_image(filename):
"""Draw simple sprites when the original images are missing."""
if filename == "title.png":
surface = pygame.Surface((388, 150), pygame.SRCALPHA)
title_font = pygame.font.Font(None, 62)
for text, y in (("SPACE", 10), ("INVADERS", 70)):
label = title_font.render(text, True, (78, 255, 87))
surface.blit(
label,
((388 - label.get_width()) // 2, y),
)
return surface
if filename in ("Ship.png", "icon.png"):
surface = pygame.Surface((42, 21), pygame.SRCALPHA)
pygame.draw.polygon(
surface,
(78, 255, 87),
[
(0, 21),
(0, 13),
(15, 13),
(21, 0),
(27, 13),
(41, 13),
(41, 21),
],
)
return surface
if filename == "ufo.png":
surface = pygame.Surface((50, 22), pygame.SRCALPHA)
pygame.draw.ellipse(
surface, (237, 28, 36), (12, 0, 26, 16)
)
pygame.draw.ellipse(
surface, (237, 28, 36), (0, 8, 50, 12)
)
for x in (10, 22, 34):
pygame.draw.rect(
surface, (0, 0, 0), (x, 12, 5, 3)
)
return surface
rows = [
"00100100",
"00011000",
"00111100",
"01111110",
"11011011",
"11111111",
"10100101",
]
if filename.endswith("2.png"):
rows[-1] = "01000010"
surface = pygame.Surface((32, 28), pygame.SRCALPHA)
for y, row in enumerate(rows):
for x, pixel in enumerate(row):
if pixel == "1":
pygame.draw.rect(
surface,
(255, 255, 255),
(x * 4, y * 4, 4, 4),
)
return surface
def load_image(filename):
path = ASSET_DIR / "images" / filename
try:
return pygame.image.load(str(path)).convert_alpha()
except (OSError, pygame.error):
missing_assets.add(str(path.relative_to(ASSET_DIR)))
return fallback_image(filename)
pygame.display.set_icon(load_image("icon.png"))
# Sound assets
bullet_sound = load_sound("shoot.wav")
enemy_laser_sound = load_sound("enemy_laser.wav")
enemy_death_sound = load_sound("invaderkilled.wav")
spawn_sound = load_sound("spawn.wav")
ufo_sound = load_sound("ufo.wav")
ufo_kill_sounds = [
load_sound(f"ufo_kill{i}.wav")
for i in range(1, 4)
]
track_sounds = [
load_sound(f"fastinvader{i}.wav")
for i in range(1, 5)
]
for sound in track_sounds:
sound.set_volume(0.4)
menu_music = load_sound("menusong.ogg")
start_game_sound = load_sound("start_game.wav")
explosion_sound = load_sound("explosion.wav")
gameover_sound = load_sound("game_over.ogg")
end_music = load_sound("endsong.ogg")
bullet_sound.set_volume(0.4)
enemy_death_sound.set_volume(0.15)
spawn_sound.set_volume(0.5)
ufo_sound.set_volume(0.3)
enemy_laser_sound.set_volume(0.4)
# Image assets
img_title = load_image("title.png")
img_p = load_image("Ship.png")
img_a1 = load_image("InvaderA1.png")
img_a2 = load_image("InvaderA2.png")
img_b1 = load_image("InvaderB2.png")
img_b2 = load_image("InvaderB1.png")
img_c1 = load_image("InvaderC1.png")
img_c2 = load_image("InvaderC2.png")
img_ufo = pygame.transform.scale(
load_image("ufo.png"), (50, 22)
)
if missing_assets:
print(
"Some assets are missing; using fallback "
"graphics/fonts and silent sounds."
)
print("Optional original assets folder:", ASSET_DIR)
if not pygame.mixer.get_init():
print("Audio unavailable; continuing without sound.")
# Colors
ORANGE = pygame.Color(255, 100, 0)
GREEN = pygame.Color(78, 255, 87)
YELLOW = pygame.Color(241, 255, 0)
BLUE = pygame.Color(0, 100, 255)
PURPLE = pygame.Color(203, 0, 255)
RED = pygame.Color(237, 28, 36)
WHITE = pygame.Color(255, 255, 255)
def set_color(img, color):
for x in range(img.get_width()):
for y in range(img.get_height()):
alpha = img.get_at((x, y)).a
img.set_at(
(x, y),
(color.r, color.g, color.b, alpha),
)
set_color(img_a1, BLUE)
set_color(img_a2, BLUE)
set_color(img_b1, PURPLE)
set_color(img_b2, PURPLE)
set_color(img_c1, ORANGE)
set_color(img_c2, ORANGE)
class Projectile:
def __init__(self, x, y, color, vel, is_enemy):
self.x = x
self.y = y
self.color = color
self.vel = vel
self.is_enemy = is_enemy
self.x_min = self.x - 0.2
self.x_max = self.x + 0.2
self.horizontal_direction = "right"
def draw(self):
pass
def move(self):
pass
def horiznotal_move(self):
if self.horizontal_direction == "right":
if self.x < self.x_max:
self.x += 0.10
else:
self.horizontal_direction = "left"
elif self.horizontal_direction == "left":
if self.x > self.x_min:
self.x -= 0.10
else:
self.horizontal_direction = "right"
class CircleProjectile(Projectile):
def __init__(self, radius, *args):
self.radius = radius
super().__init__(*args)
def draw(self, window):
self.horiznotal_move()
pygame.draw.circle(
window,
self.color,
(round(self.x), round(self.y)),
self.radius,
)
class RectProjectile(Projectile):
def __init__(self, width, height, *args):
self.width = width
self.height = height
super().__init__(*args)
def draw(self, window):
self.horiznotal_move()
pygame.draw.rect(
window,
self.color,
(
int(self.x),
int(self.y),
self.width,
self.height,
),
)
class Player:
player_image = pygame.transform.scale(img_p, (42, 21))
def __init__(self, x, y, width, height, vel):
self.x = x
self.y = y
self.width = width
self.height = height
self.vel = vel
self.can_fire = True
def draw(self, window):
window.blit(self.player_image, (self.x, self.y))
class Enemy:
def __init__(
self,
x,
y,
width,
height,
score,
color,
image_1,
image_2,
is_active,
depth,
row,
min_shoot_cd,
max_shoot_cd,
bullet_speed,
):
self.x = x
self.y = y
self.width = width
self.height = height
self.score = score
self.image_id = 1
self.is_active = is_active
self.depth = depth
self.row = row
self.min_shoot_cd = min_shoot_cd
self.max_shoot_cd = max_shoot_cd
self.bullet_speed = bullet_speed
self.cd = 0
self.set_cd = 0
self.color = color
self.enemy_image1 = pygame.transform.scale(
image_1, (28, 21)
)
self.enemy_image2 = pygame.transform.scale(
image_2, (28, 21)
)
set_color(self.enemy_image1, color)
set_color(self.enemy_image2, color)
self.enemy_image = self.enemy_image1
def draw(self, window):
window.blit(
self.enemy_image,
(int(self.x), int(self.y)),
)
def move(self, move_dir, is_by_wall, vel):
if is_by_wall:
self.y += self.height + 12
elif move_dir == "right":
self.x += vel
elif move_dir == "left":
self.x -= vel
if self.y + self.height + 3 >= win_height:
destroy_player()
def change_anim(self):
if self.image_id == 1:
self.image_id = 2
self.enemy_image = self.enemy_image2
else:
self.image_id = 1
self.enemy_image = self.enemy_image1
def shoot(self, bullets):
if self.is_active and self.y < win_height - 50:
if self.set_cd == 0:
self.set_cd = 60 + random.randrange(
self.min_shoot_cd,
self.max_shoot_cd,
)
self.cd = random.randrange(
0, self.set_cd - 30
)
self.cd += 1
if self.cd > self.set_cd:
new_bullet = RectProjectile(
4,
20,
self.x + self.width // 2,
self.y + self.height,
self.color,
self.bullet_speed,
True,
)
bullets.append(new_bullet)
play_sound(enemy_laser_sound)
self.cd = 0
self.set_cd = random.randrange(
self.min_shoot_cd,
self.max_shoot_cd,
)
class Ufo:
def __init__(self, x, y, width, height, vel, img):
self.x = x
self.y = y
self.width = width
self.height = height
self.vel = vel
self.img = img
def move(self):
self.x += self.vel
def draw(self, window):
window.blit(
self.img,
(int(self.x), int(self.y)),
)
class Text:
def __init__(self, font, color, x, y):
self.font = font
self.color = color
self.x = x
self.y = y
def draw(self, window, text):
text_obj = self.font.render(text, True, self.color)
window.blit(text_obj, (self.x, self.y))
class Music:
def __init__(self):
self.index = 0
def check_and_play(self):
play_sound(track_sounds[self.index])
self.index += 1
if self.index > 3:
self.index = 0
class Stats:
def __init__(self):
self.a_killed = 0
self.b_killed = 0
self.c_killed = 0
self.ufo_killed = 0
self.ufo_colledted_points = 0
def redraw_game_window():
win.fill((0, 0, 0))
player.draw(win)
for bullet in bullets:
bullet.draw(win)
if player_bullet is not None:
player_bullet.draw(win)
for enemy in enemies:
enemy.draw(win)
if ufo:
ufo.draw(win)
score_text.draw(win, "Score: " + str(score))
level_text.draw(win, "Wave: " + str(iteration))
pygame.display.update()
def handle_player_input():
global player_bullet
global player_shot_count
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] or keys[pygame.K_a]:
player.x = max(0, player.x - player.vel)
if keys[pygame.K_RIGHT] or keys[pygame.K_d]:
player.x = min(
win_width - player.width,
player.x + player.vel,
)
if keys[pygame.K_SPACE] and player.can_fire:
player.can_fire = False
player_shot_count += 1
play_sound(bullet_sound)
player_bullet = RectProjectile(
4,
16,
round(player.x + player.width // 2 - 1),
round(player.y - 1),
(0, 200, 0),
9,
False,
)
def handle_enemy_movement_direction():
global direction
check_wall = False
for enemy in enemies:
if (
direction == "right"
and enemy.x + 2 * enemy.width >= win_width
):
direction = "left"
check_wall = True
elif (
direction == "left"
and enemy.x - enemy.width <= 0
):
direction = "right"
check_wall = True
return check_wall
def handle_bullets():
global player_bullet
global score
global game_speed
global run
global stats
# Move the player's bullet.
if player_bullet is not None:
if player_bullet.y > -5:
player_bullet.y -= player_bullet.vel
else:
player_bullet = None
player.can_fire = True
# Move enemy bullets and remove those outside the window.
for bullet in bullets[:]:
if bullet.y < win_height:
bullet.y += bullet.vel
else:
bullets.remove(bullet)
# Check player bullet collisions with enemies.
for enemy in enemies[:]:
if player_bullet is not None:
bullet_rect = pygame.Rect(
int(player_bullet.x),
int(player_bullet.y),
player_bullet.width,
player_bullet.height,
)
enemy_rect = pygame.Rect(
int(enemy.x),
int(enemy.y),
enemy.width,
enemy.height,
)
if bullet_rect.colliderect(enemy_rect):
player_bullet = None
player.can_fire = True
score += enemy.score
play_sound(enemy_death_sound)
game_speed -= 2
activate_next_enemy(enemy, enemies)
if enemy.score == 10:
stats.a_killed += 1
if enemy.score == 20:
stats.b_killed += 1
if enemy.score == 30:
stats.c_killed += 1
enemies.remove(enemy)
continue
enemy.shoot(bullets)
# Check enemy bullet collisions with the player.
for bullet in bullets[:]:
bullet_rect = pygame.Rect(
int(bullet.x),
int(bullet.y),
bullet.width,
bullet.height,
)
player_rect = pygame.Rect(
int(player.x),
int(player.y),
player.width,
player.height,
)
if bullet_rect.colliderect(player_rect):
bullets.remove(bullet)
destroy_player()
return
def spawn_enemies(iter):
global enemies
spawn_sound.play(-1)
x = 130
y = 34 + 36 * min(iter, 5)
# Upper row
for d in range(1):
for i in range(11):
enemies.append(
Enemy(
x + i * 48,
y + d * 32 + 8,
32,
24,
30,
ORANGE,
img_c1,
img_c2,
False,
d,
i,
250,
420,
4,
)
)
redraw_game_window()
if not responsive_pause(50):
spawn_sound.stop()
return
# Middle rows
for d in range(1, 3):
for i in range(11):
enemies.append(
Enemy(
x + i * 48,
y + d * 32 + 8,
32,
24,
20,
PURPLE,
img_b1,
img_b2,
False,
d,
i,
350,
700,
6,
)
)
redraw_game_window()
if not responsive_pause(50):
spawn_sound.stop()
return
# Lower rows
for d in range(3, 5):
for i in range(11):
enemies.append(
Enemy(
x + i * 48,
y + d * 32 + 8,
32,
24,
10,
BLUE,
img_a1,
img_a2,
False,
d,
i,
350,
700,
4,
)
)
redraw_game_window()
if not responsive_pause(50):
spawn_sound.stop()
return
for enemy in enemies:
if enemy.depth == 4:
enemy.is_active = True
spawn_sound.stop()
responsive_pause(333)
def activate_next_enemy(enemy_out, enemies):
if enemy_out.is_active:
new_max_depth = -1
new_enemy = None
for enemy in enemies:
if (
enemy.row == enemy_out.row
and enemy.depth < enemy_out.depth
):
if enemy.depth > new_max_depth:
new_max_depth = enemy.depth
new_enemy = enemy
if new_enemy is not None:
new_enemy.is_active = True
def move_enemies():
global current_time
global enemy_move_cycle
global game_speed
current_time += 2
vel = 8
if len(enemies) == 1:
game_speed = 16
if current_time == 4 or current_time == 12:
by_wall = handle_enemy_movement_direction()
for enemy in enemies[:]:
enemy.move(direction, by_wall, vel)
if current_event != "game":
return
if current_time >= game_speed:
current_time = 0
if not music_muted:
music_loop.check_and_play()
by_wall = handle_enemy_movement_direction()
for enemy in enemies[:]:
enemy.move(direction, by_wall, vel)
if current_event != "game":
return
enemy.change_anim()
enemy_move_cycle = 0
if (
current_time >= game_speed / 2
and enemy_move_cycle == 0
):
enemy_move_cycle = 1
by_wall = handle_enemy_movement_direction()
for enemy in enemies[:]:
enemy.move(direction, by_wall, vel)
if current_event != "game":
return
def spawn_ufo():
global ufo
global music_muted
music_muted = True
play_sound(ufo_sound, loops=100)
ufo = Ufo(0, 40, 50, 22, 1.75, img_ufo)
def handle_ufo():
global ufo
global player_bullet
global player
global score
global music_muted
global player_shot_count
global stats
global ufo_milestone
if ufo is None:
if (
player_shot_count >= ufo_milestone
and len(enemies) > 4
):
spawn_ufo()
player_shot_count = 0
ufo_milestone = random.randrange(12, 25)
else:
ufo.move()
if ufo.x > win_width:
destroy_ufo()
elif player_bullet is not None:
bullet_rect = pygame.Rect(
int(player_bullet.x),
int(player_bullet.y),
player_bullet.width,
player_bullet.height,
)
ufo_rect = pygame.Rect(
int(ufo.x),
int(ufo.y),
ufo.width,
ufo.height,
)
if bullet_rect.colliderect(ufo_rect):
destroy_ufo()
stats.ufo_killed += 1
player_bullet = None
player.can_fire = True
possible_scores = (50, 100, 150)
random_num = random.randrange(0, 3)
points = possible_scores[random_num]
score += points
stats.ufo_colledted_points += points
play_sound(ufo_kill_sounds[random_num])
def destroy_ufo():
global ufo
global music_muted
ufo = None
ufo_sound.stop()
music_muted = False
def redraw_menu():
global state
win.fill((0, 0, 0))
intro_text = Text(
font, WHITE, 272, win_height - 60
)
controls_text = Text(
font, WHITE, 220, win_height - 130
)
shoot_text = Text(
font, WHITE, 460, win_height - 130
)
value1_text = Text(font, BLUE, 262, 280)
value2_text = Text(font, ORANGE, 492, 280)
value3_text = Text(font, PURPLE, 262, 400)
value4_text = Text(font, RED, 492, 400)
if state == 1:
state = 0
intro_text.color = GREEN
win.blit(img_a1, (250, 240))
win.blit(img_b1, (250, 360))
win.blit(img_c1, (480, 240))
win.blit(img_ufo, (480, 365))
else:
state = 1
intro_text.color = WHITE
win.blit(img_a2, (250, 240))
win.blit(img_b2, (250, 360))
win.blit(img_c2, (480, 240))
win.blit(img_ufo, (480, 365))
controls_text.draw(win, "Move: Arrows")
shoot_text.draw(win, "Shoot: Space")
value1_text.draw(win, "10p")
value2_text.draw(win, "30p")
value3_text.draw(win, "20p")
value4_text.draw(win, "???")
intro_text.draw(win, "Hold Space to start the race!")
win.blit(img_title, (206, 30))
pygame.display.update()
def change_event(next_event):
global current_event, score, enemies, state
global player_bullet, bullets, iteration, stats
global player_shot_count, ufo_milestone
global direction, current_time
global enemy_move_cycle, game_speed
if pygame.mixer.get_init():
pygame.mixer.stop()
destroy_ufo()
if next_event == "menu":
score = 0
iteration = 0
state = 0
enemies = []
bullets = []
player_bullet = None
player.x = (win_width - player.width) // 2
player.can_fire = True
stats = Stats()
player_shot_count = 0
ufo_milestone = random.randrange(20, 30)
direction = "right"
current_time = 80
enemy_move_cycle = 0
game_speed = 130
current_event = "menu"
menu_music.play(-1)
elif next_event == "game":
current_event = "game"
start_game_sound.play()
responsive_pause(1000)
elif next_event == "end":
state = 0
current_event = "end"
enemies = []
bullets = []
player_bullet = None
play_sound(gameover_sound)
end_music.play(-1)
def show_number(number, desired_units, fill_chareacter):
return str(number).rjust(
desired_units, fill_chareacter
)
def destroy_player():
global player_bullet
if current_event != "game":
return
player_bullet = None
player.can_fire = True