-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.py~
75 lines (71 loc) · 2.12 KB
/
process.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
import pygame,sys,classes,random
def process(bug,FPS,total_frames):
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type==pygame.KEYDOWN:
if event.key == pygame.K_e:
classes.BugProjectile.fire=not classes.BugProjectile
keys = pygame.key.get_pressed()
if keys[pygame.K_d]:
classes.Bug.going_right=True
bug.image = pygame.image.load("images/xyz.png")
bug.velx = 5
elif keys[pygame.K_a]:
classes.Bug.going_right=False
bug.image = pygame.image.load("images/txyz.png")
bug.velx = -5
else:
bug.velx = 0
if keys[pygame.K_w]:
bug.jumping =True
if keys[pygame.K_SPACE]:
def direction():
if classes.Bug.going_right:
p.velx=8
else:
p.image=pygame.transform.flip(p.image,True,False)
p.velx=-8
if (classes.BugProjectile.fire):
p=classes.BugProjectile(bug.rect.x,bug.rect.y,True,"images/frost.jpeg")
direction()
else:
p=classes.BugProjectile(bug.rect.x,bug.rect.y,False,"images/fire.png")
direction()
spawn(FPS,total_frames)
collisions()
def spawn(FPS,total_frames):
four_seconds = FPS*4
if total_frames%four_seconds==0:
r=random.randint(1,2)
x=1
if r==2:
x=640-100
classes.Fly(x,130,"images/fly.png")
def collisions():
#for fly in classes.Fly.List:
#
# if pygame.sprite.spritecollide(fly,classes.BugProjectile.List,False):
# if classes.BugProjectile.fire:
# fly.health-=fly.half_health
# else :
# fly.velx=0
#for proj in classes.BugProjectile.List:
# if pygame.sprite.spritecollide(proj,classes.Fly.List,False):
# proj.rect.x=2*-proj.rect.width
# proj.destroy()
for fly in classes.Fly.List:
projectiles=pygame.sprite.spritecollide(fly,classes.BugProjectile.List,True)
for projectile in projectiles:
fly.health=0
if projectile.if_this_variable_is_true_then_fire:
fly.image=pygame.image.load("images/burnt_fly.png")
else:
if fly.velx>0:
fly.image=pygame.image.load("images/frozen_fly.png")
elif fly.velx<0:
fly.image=pygame.image.load("images/frozen_fly.png")
fly.image=pygame.transform.flip(fly.image,True,False)
proj.rect.x=2*-proj.rect.width
proj.destroy()