Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added fading
  • Loading branch information
mthenault committed Jun 1, 2012
1 parent 4487756 commit 2193847
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 2 deletions.
Binary file modified images/sprite_enemy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions sources/effects.py
@@ -0,0 +1,23 @@
import os
import common_pygame
import random
pygame = common_pygame.pygame
screen= common_pygame.screen
clock= common_pygame.clock

def fadeToColor(r, g, b):
animlen=150
for i in range(0, animlen, 5):
clock.tick_busy_loop(30)
screen.fill(((255-r)*i/animlen,(255-g)*i/animlen,(255-b)*i/animlen), special_flags=pygame.BLEND_SUB)
pygame.display.flip()

#def fadeFromBlack():
#animlen=255
#for i in range(0, animlen, 5):
#clock.tick_busy_loop(30)
#screen.fill((i, \
#i,\
#i),\
#special_flags=pygame.BLEND_MIN)
#pygame.display.flip()
11 changes: 11 additions & 0 deletions sources/game.py
Expand Up @@ -10,6 +10,7 @@
import hud
import bonus
import menu
import effects

pygame = common_pygame.pygame
screen= common_pygame.screen
Expand Down Expand Up @@ -86,6 +87,7 @@

thegame=True
level =0

while thegame:
compteur_shoot=compteur_shoot+1

Expand Down Expand Up @@ -241,8 +243,17 @@
youlost = font2.render("Game over", True, (255,255, 255))
presskey = font.render("press any key to quit", True, (255,255, 255))
yourscore = font.render("Your score : "+ str(ship.score), True, (255,255, 255))

#play a the explosion sound
menu.play_sound(sounds['explosion2.wav'])
#blit the explosion
screen.blit(sprite_sequences['sprite_explosion_list_asteroid.png'][3],\
(ship.position_ship_x-64,ship.position_ship_y-64))
#fade to red
effects.fadeToColor(255, 0, 0)
scoreBonus.ProcessBonus(ship)


pygame.display.flip()

exitloop = True
Expand Down
4 changes: 4 additions & 0 deletions sources/menu.py
Expand Up @@ -6,6 +6,7 @@
import pygame, sys, pygame.mixer
from pygame.locals import *
import pickle
import effects
pygame = common_pygame.pygame
screen= common_pygame.screen
clock = common_pygame.clock
Expand Down Expand Up @@ -68,6 +69,8 @@ def launch(self, withresume):
decaly=0
decalx=-150
space=120

firstRound=True
while(True):
for event in pygame.event.get():
if event.type == pygame.QUIT:
Expand Down Expand Up @@ -107,6 +110,7 @@ def launch(self, withresume):
if self.menuStatus==0:
if pygame.key.get_pressed()[pygame.K_RETURN] and self.selection==1 and self.compteur>=5:
self.compteur=0
effects.fadeToColor(0, 0, 0)
return

if pygame.key.get_pressed()[pygame.K_RETURN] and self.selection==3 and self.compteur>=5:
Expand Down
3 changes: 2 additions & 1 deletion sources/progressbar.py
Expand Up @@ -19,5 +19,6 @@ def update(self,percent):
screen.blit(self.loading, (300,self.textHeight))
txtpercent = self.font.render(str(percent)+"%", True, self.color)
screen.blit(txtpercent, (20,self.y1+30))
pygame.draw.rect(screen, self.color, (20,self.y1,(percent*self.max_width)/100,20), 2)
pygame.draw.rect(screen, self.color, (20,self.y1,self.max_width,20), 2 )
pygame.draw.rect(screen, self.color, (20,self.y1,(percent*self.max_width)/100,20), 0)
pygame.display.flip()
10 changes: 9 additions & 1 deletion sources/ship.py
Expand Up @@ -34,6 +34,7 @@ def __init__(self, single_sprites, sounds, menu):
#initial weapon
#1: normal laser
#2: plasma balls
#3: death ray
self.ammo=0
self.weapon=1

Expand Down Expand Up @@ -62,17 +63,24 @@ def shoot(self, laserlist, compteur_shoot, laser_width, laser_height, lasershoot
self.position_ship_y-laser_height+24, 2))
#lasershoot = 7
compteur_shoot=0
#death ray
elif compteur_shoot>2 and self.weapon == 3:
self.ammo=self.ammo-1

return (compteur_shoot, laserlist, lasershoot)

def setWeapon (self, number ):
if number==1:
self.weapon=1
self.sprite=self.single_sprites['sprite_ship.png']
else:
elif number ==2:
self.weapon=2
self.sprite=self.single_sprites['sprite_ship_weapon2.png']
self.ammo=100
else:
self.weapon=3
self.sprite=self.single_sprites['sprite_ship_weapon2.png']
self.ammo=100

def damage (self, amount):
if self.hurt==False:
Expand Down

0 comments on commit 2193847

Please sign in to comment.