-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprojectile.py~
80 lines (51 loc) · 1.78 KB
/
projectile.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
76
77
78
79
80
#Written by Jonathan Sumrall
#George Mason University Game Jam 2010
#See the README for bug info and how to play.
#The phaser-bullet-laser things that the ships shoot
import pygame
class Projectile(object):
def __init__(self,x=0,y=0,vx=0,vy=0,shot = 1,pic ="pictures/rock.png",nukeStatus = False,imgScale=1):
self.outerX = 55/imgScale
self.outerY = 65/imgScale
#This control strcture makes one bullet shot from the left of the ship, and one shoot from the right side
if(shot == 1):
self.x = x - 15
else:
self.x = x + self.outerX
self.y = y
self.vx = vx
self.vy = vy
self.exist = True
self.isNuke = nukeStatus
#Creatre the pygame pic of the bullet
self.projectilePic = pygame.image.load(pic).convert_alpha()
self.projectilePic = pygame.transform.scale(self.projectilePic,(self.outerX,self.outerY))
def xPos(self):
return self.x
def yPos(self):
return self.y
def hitShip(self):
self.exist = False
def update(self,screenHeight):
self.x = self.x + self.vx
self.y = self.y + self.vy
#check if it leaves the screen
if (self.y < 0) or (self.y > screenHeight):
self.exist = False
def getPic(self):
return self.projectilePic
def getRect(self):
return pygame.Rect(self.x,self.y,self.outerX,self.outerY)
def nukeExplode(self, shipObjects,ship,screen):
#make the nuke kill everything
for ships in shipObjects:
shipObjects.remove(ships)
'''
explodeRangeX = 500000
explodeRangeY = 500000
blastRadius = pygame.draw.rect(screen,(0, 0, 0), (ship.x, ship.y, explodeRangeX, explodeRangeY ) )
for ship in shipObjects:
if ship.getRect().colliderect(blastRadius):
ship.exist = False
self.exist = False
'''