-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboss.py
71 lines (50 loc) · 1.6 KB
/
boss.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
#Written by Jonathan Sumrall
#George Mason University Game Jam 2010
#Fall 2010
#See the README for bug info and how to play.
#Some interesting things you can edit:
#Not much actually, except you could have a blast changing the HP of the boss.
#Or maybe make the boss more immune to bombs.
import pygame,random,projectile
class Boss(object):
def __init__(self,x=0,y=0,vx=0,vy=0,hp=100,imgScale=1):
self.x = x
self.y = y
self.vx = vx
self.vy = vy
self.hp = hp
#we need to create the boss image, and scale it correctly
scalingVar = 3
self.outerX = 500/imgScale
self.outerY = 300/imgScale
self.isBoss = True
self.scale = imgScale
bossPicture = "pictures/boss.png"
self.exist = True
self.BossPic = pygame.image.load(bossPicture).convert_alpha()
self.BossPic = pygame.transform.scale(self.BossPic,
(self.outerX, self.outerY) )
def isHit(self):
self.hp -= 2
if self.hp < 0 :
self.exist = False
def getPic(self):
return self.BossPic
def getRect(self):
return pygame.Rect(self.x,self.y,self.outerX,self.outerY)
def update(self,player,projectiles):
bossShipSpeed = 1
if self.x < player.x:
self.vx = 1
elif self.x > player.x:
self.vx = -1
self.vx = self.vx * bossShipSpeed
self.x += self.vx
if (random.randint(0,100) > 99):
projectiles.append(self.shoot(self.scale))
def shoot(self,scale):
projectileSpeed = 1.5
return projectile.Projectile( x = self.x, y = self.y + self.outerY, vy = projectileSpeed, pic = "pictures/alienLaser.png",imgScale= scale)
def isDead(self):
pass
#WE dont need this for the boss