Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 79 lines (71 sloc) 3.783 kB
5790ab8 @Accusedbold Flying Enemy stuff
Accusedbold authored
1 #A villianous flying enemy
2 import pygame, random
3 import os
4
5
6 class Enemyflying(pygame.sprite.Sprite):
7
8 def __init__(self, right, speed):
9 pygame.sprite.Sprite.__init__(self)
10 self.HP = 5
11 self.image = 0
dbf05ec @sockser SPRITES FUCK
sockser authored
12 self.right = right
ace0073 @sockser just some stuff
sockser authored
13 self.boss = False
c508709 @sockser flying enemy animations
sockser authored
14 self.framenumber = 0
15 self.images = [pygame.image.load(os.path.join(os.curdir, 'flyingenemy1.png')).convert_alpha(),
16 pygame.image.load(os.path.join(os.curdir, 'flyingenemy2.png')).convert_alpha(),
17 pygame.image.load(os.path.join(os.curdir, 'flyingenemy3.png')).convert_alpha(),
18 pygame.image.load(os.path.join(os.curdir, 'flyingenemy4.png')).convert_alpha(),
19 pygame.image.load(os.path.join(os.curdir, 'flyingenemy5.png')).convert_alpha(),
20 pygame.image.load(os.path.join(os.curdir, 'flyingenemy6.png')).convert_alpha(),
21 pygame.image.load(os.path.join(os.curdir, 'flyingenemy7.png')).convert_alpha(),
22 pygame.image.load(os.path.join(os.curdir, 'flyingenemy8.png')).convert_alpha(),
23 pygame.image.load(os.path.join(os.curdir, 'flyingenemy9.png')).convert_alpha(),
24 pygame.image.load(os.path.join(os.curdir, 'flyingenemy10.png')).convert_alpha()
25 ]
9b07ca6 @Accusedbold collisons
Accusedbold authored
26
5790ab8 @Accusedbold Flying Enemy stuff
Accusedbold authored
27 self.rect = self.images[self.image].get_rect()
28 if right == True:
29 self.x = 1280
a3180f1 @zcr1 d
zcr1 authored
30 self.y = random.randint(80, 550)
5790ab8 @Accusedbold Flying Enemy stuff
Accusedbold authored
31 self.speed = -speed
32 else:
33 self.x = 0
a3180f1 @zcr1 d
zcr1 authored
34 self.y = random.randint(80, 550)
5790ab8 @Accusedbold Flying Enemy stuff
Accusedbold authored
35 self.speed = speed
36 self.rect = self.rect.move(self.x, self.y)
37
c508709 @sockser flying enemy animations
sockser authored
38 def updateEnemySprite(self, framestart, totalframes):
ace0073 @sockser just some stuff
sockser authored
39 if(self.boss):
40 self.images = [pygame.image.load(os.path.join(os.curdir, 'boss1.png')).convert_alpha(),
41 pygame.image.load(os.path.join(os.curdir, 'boss2.png')).convert_alpha(),
42 pygame.image.load(os.path.join(os.curdir, 'boss3.png')).convert_alpha(),
43 pygame.image.load(os.path.join(os.curdir, 'boss4.png')).convert_alpha(),
44 pygame.image.load(os.path.join(os.curdir, 'boss5.png')).convert_alpha(),
45 pygame.image.load(os.path.join(os.curdir, 'boss6.png')).convert_alpha(),
46 pygame.image.load(os.path.join(os.curdir, 'boss7.png')).convert_alpha(),
47 pygame.image.load(os.path.join(os.curdir, 'boss8.png')).convert_alpha(),
48 pygame.image.load(os.path.join(os.curdir, 'boss9.png')).convert_alpha(),
49 pygame.image.load(os.path.join(os.curdir, 'boss10.png')).convert_alpha()
50 ]
c508709 @sockser flying enemy animations
sockser authored
51 self.framenumber += 0.33
52 if(self.framenumber > framestart + totalframes or self.framenumber < framestart):
53 self.framenumber = framestart
54 self.image = (int(self.framenumber)) % totalframes + framestart
a3180f1 @zcr1 d
zcr1 authored
55
b50b0a1 @Accusedbold Enemies effect health of castle
Accusedbold authored
56 def updateEnemyPos(self, enemyList, index):
c508709 @sockser flying enemy animations
sockser authored
57 #self.image = (self.image + 1) % 8
58 if(self.right):
59 self.updateEnemySprite(5,5)
60 else:
61 self.updateEnemySprite(0,5)
9b07ca6 @Accusedbold collisons
Accusedbold authored
62 if self.x + self.speed < 513 or self.x + self.speed > 715:
5790ab8 @Accusedbold Flying Enemy stuff
Accusedbold authored
63 self.x += self.speed
64 self.rect = self.rect.move(self.speed,0)
b50b0a1 @Accusedbold Enemies effect health of castle
Accusedbold authored
65 else:
66 enemyList.pop(index)
67 return True
68 return False
5790ab8 @Accusedbold Flying Enemy stuff
Accusedbold authored
69
70 def swordHit(self, enemyList, index):
71 self.HP = slef.HP - 5
72 if self.HP < 1:
73 enemyList.pop(index)
15c1010 @zcr1 Meow
zcr1 authored
74 def Hit(self, enemyList, index, dmg):
75 self.HP = self.HP - dmg
5790ab8 @Accusedbold Flying Enemy stuff
Accusedbold authored
76 if self.HP < 1:
15c1010 @zcr1 Meow
zcr1 authored
77 enemyList.pop(index)
588750f @sockser SPRITE STUFF
sockser authored
78 return True;
Something went wrong with that request. Please try again.