Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

enemis drop items too

  • Loading branch information...
commit ab65a0400094e7105ef211b5959a3b534a5f0514 1 parent f060ae6
michael authored
View
4 data/config.conf
@@ -1,8 +1,8 @@
(dp0
S'sound'
p1
-I01
+I00
sS'resolution'
p2
-I00
+I01
s.
View
0  run_game.py 100644 → 100755
File mode changed
View
50 sources/enemy.py
@@ -15,8 +15,13 @@ def __init__(self, single_sprites, sprite_sequences,sounds, x, y, movementdirect
self.single_sprites=single_sprites
self.typeofship = typeofship
self.sprite_sequences =sprite_sequences
+
+
+
#this enemy is a ship
if self.typeofship==0:
+ self.bonusType=random.randint(0,1)
+
if bool(random.getrandbits(1)):
self.sprite_enemy = single_sprites['sprite_enemy.png']
else:
@@ -30,6 +35,7 @@ def __init__(self, single_sprites, sprite_sequences,sounds, x, y, movementdirect
self.offsetturn=random.randrange(1,9)*50
#this enemy is an asteroid
else:
+ self.bonusType=random.randint(0,2)
#load the appropriate sprite
choix = random.randrange(1,4)
size = random.randrange(80, 100)
@@ -43,21 +49,21 @@ def __init__(self, single_sprites, sprite_sequences,sounds, x, y, movementdirect
Enemy.nbAsteroids=Enemy.nbAsteroids+1
self.speed=3
self.sprite_explosion_list = sprite_sequences['sprite_explosion_list_asteroid.png']
-
- #if we are going to be a bonus, what bonus will it be ?
- #0 : health
- #1 : armor
- #2 : plasma
+
self.bonusType=random.randint(0,2)
- if self.bonusType==0:
- self.sprite_bonus=single_sprites['lifebonus.png']
- elif self.bonusType==1:
- self.sprite_bonus=single_sprites['armorbonus.png']
- else:
- self.sprite_bonus=single_sprites['plasmabonus.png']
- self.bonus=False
-
+ #if we are going to be a bonus, what bonus will it be ?
+ #0 : health
+ #1 : armor
+ #2 : plasma
+
+ if self.bonusType==0:
+ self.sprite_bonus=single_sprites['lifebonus.png']
+ elif self.bonusType==1:
+ self.sprite_bonus=single_sprites['armorbonus.png']
+ else:
+ self.sprite_bonus=single_sprites['plasmabonus.png']
+ self.bonus=False
self.alive = True
self.dying = False
@@ -73,8 +79,6 @@ def __init__(self, single_sprites, sprite_sequences,sounds, x, y, movementdirect
self.compteurx=0
self.compteury=0
-
-
self.w = self.sprite_enemy.get_width()
self.h = self.sprite_enemy.get_height()
@@ -162,7 +166,7 @@ def processHit(self,laserlist, ship):
self.dying = True
ship.score=ship.score+10
self.menu.play_sound(self.sounds['explosion2.wav'])
- print("dying")
+ #print("dying")
Enemy.nbAsteroids=Enemy.nbAsteroids-1
oldlasers.append((currentx, currenty, lasertype))
@@ -180,13 +184,15 @@ def update(self, ship):
self.y-86))
self.dying_index = self.dying_index +1
else:
- if (self.typeofship==1):
- self.bonus=True
- self.alive = True
+ #asteroid
+ #if (self.typeofship==1):
+ self.bonus=True
+ self.alive = True
#Enemy.nbAsteroids=Enemy.nbAsteroids-1
- else:
- self.dying = False
- self.alive = False
+ #enemy ship
+ #else:
+ # self.dying = False
+ # self.alive = False
elif self.alive:
#if we are being shot, there is alternate blitting for one second
View
4 sources/ship.py
@@ -146,8 +146,8 @@ def updatePosition(self):
self.position_ship_x = self.position_ship_x + self.currentspeed_x
#update de position Y:
- if self.position_ship_y+self.currentspeed_y>screen.get_height()-self.height:
- self.position_ship_y = screen.get_height()-self.height
+ if self.position_ship_y+self.currentspeed_y>screen.get_height()-self.height-32:
+ self.position_ship_y = screen.get_height()-self.height-32
#reset the speed
self.currentspeed_x =0
self.currentspeed_y= 0
Please sign in to comment.
Something went wrong with that request. Please try again.