Skip to content

Commit

Permalink
added smoke
Browse files Browse the repository at this point in the history
  • Loading branch information
michael authored and michael committed Jul 30, 2012
1 parent dd8abdc commit d408ef2
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
Binary file added images/smoke.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions sources/enemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import random
import hud
import particles
import smoke
pygame = common_pygame.pygame

class Enemy():
Expand Down Expand Up @@ -258,6 +259,10 @@ def update(self, ship):
##if we are the first boss, we draw the sprite anyway
#if self.typeofship==2:
#self.screen.blit(self.sprite_enemy, (self.x, self.y))

if self.shot%7==0:
smoke.addSmoke(self.x,self.y)

else:
if self.typeofship==0:
self.screen.blit(self.single_sprites['sprite_enemy_fire.png'], (self.x, self.y-15))
Expand Down
2 changes: 2 additions & 0 deletions sources/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def game():
import menu
import effects
import particles
import smoke

pygame = common_pygame.pygame
screen= common_pygame.screen
Expand Down Expand Up @@ -266,6 +267,7 @@ def game():
effects.fadeToColor(255, 0, 0)
#scoreBonus.ProcessBonus(ship)
particles.blitAndUpdate()
smoke.blitAndUpdate()

pygame.display.flip()

Expand Down
2 changes: 1 addition & 1 deletion sources/load_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def load_resources(pygame_arg):
"menu_on.png", "menu_off.png","menu_resolution.png","menu_800600.png", "menu_800500.png", \
"sprite_enemy2.png", "plasmaBonusRing.png", "plasmabonus.png", "boss1.png", \
"particle1.png", "particle2.png", "particle3.png", "particle4.png", "barArmor.png", "barLife.png", \
"johnson.png" ]
"johnson.png", "smoke.png" ]

for index in xrange (len(sprite_load_list)):
add_sprite(sprite_load_list[index])
Expand Down
42 changes: 42 additions & 0 deletions sources/smoke.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#handles the smoke present at the screen at this time
import random
import common_pygame
import load_resources

single_sprites=load_resources.single_sprites
pygame = common_pygame.pygame
screen= common_pygame.screen

smokes = list()

#size : 1 : asteroids, 2: ships, 3: boss
def addSmoke ( x, y):
#appending the smoke particle, and his current life (300
smokes.append((x,y,256, 45))


def determine_smoke(k):
(x, y, life, size) = k
#print("life:", life)
if life >= 0:
return True
return False

def blitAndUpdate():
for i in range(len(smokes)):
#delete the particles that are too old
smokes[:]=[k for k in smokes if determine_smoke(k)]
for i in range(len(smokes)):
#blit the concerned particle
(x, y, life, size) = smokes[i]
life = life -1

if size > 0 and life%2==0:
size=size-1

#print("size", size)
toblit = pygame.transform.scale(single_sprites['smoke.png'],( size, size))
screen.blit(toblit, (x-(45-size),y-(45-size)))

smokes[i]=(x, y, life,size)

0 comments on commit d408ef2

Please sign in to comment.