Commits

Anonymous committed 809b7a7

Clean up the .py in base directory... I think it'll still run!

Comments (0)

Files changed (19)

AttackerStuff.py

-# coding=UTF8
-# Copyright © 2010 Rob Leachman
-# Please see the file COPYING in this distribution for license information
-import pygame
-import random
-from pygame.color import THECOLORS
-
-import enviro # my global game environment
-from FloatingSprite import FloatingSprite
-from Fighter import Fighter
-
-
-    
-# Need a sprite to represent the shield, so we can test collision
-class ShieldSprite(pygame.sprite.Sprite):
-
-    def __init__(self, image_file, left, top, width, height):
-        pygame.sprite.Sprite.__init__(self)
-        
-        self.image = pygame.image.load(image_file)
-        self.rect = self.image.get_rect()
-
-        self.rect.left = left
-        self.rect.top = top
-        self.rect.width = width
-        self.rect.height = height
-        
-    # just for testing, this thing isn't drawn ever
-    def paint(self):
-        enviro.screen.blit(self.image, self.rect)

DeadFighter.py

-# coding=UTF8
-# Copyright © 2010 Rob Leachman
-# Please see the file COPYING in this distribution for license information
-import pygame
-import sys # for testing
-from pygame.color import THECOLORS
-
-import enviro # my global game environment
-from FloatingSprite import FloatingSprite
-from Fighter import Fighter # for testing...
-
-class DeadFighter:
-    def __init__(self, filenamePrefix):
-        self.deathImage = []
-        self.deathFrameCount = 0
-        self.top = 0
-        self.left = 0
-        
-        for i in range (1,9):
-            deathFile = filenamePrefix + str(i) + ".png"
-            deathImage = pygame.image.load(deathFile)
-            deathImage.convert()
-            self.deathImage.append(deathImage)
-            
-    def __str__(self):
-        msg =  "  Dead fighter X:" + str(self.top) + " Y:" + str(self.left)
-        msg += "    frameCount=" + str(self.deathFrameCount)
-        return msg               
-            
-    def paint(self):
-        #deathFrame = self.deathFrameCount / 10
-        deathFrame = self.deathFrameCount
-        # maybe we got called too many times... if so, let's not crash
-        if deathFrame >= len(self.deathImage):
-            return True
-        enviro.screen.blit(self.deathImage[deathFrame], [self.top, self.left])
-        self.deathFrameCount += 1
-        #nextFrame = self.deathFrameCount / 10
-        nextFrame = self.deathFrameCount
-        # the intention is to signal when we're done, and shouldn't be called again...
-        if nextFrame >= len(self.deathImage):
-            return True
-        return False
-    
-    def setLocation(self,fighterTop, fighterLeft):
-        self.top = fighterTop - 5
-        self.left = fighterLeft - 5
-        
-if __name__ == '__main__':
-    
-    pygame.init()
-    enviro.screen = pygame.display.set_mode([800,600])
-    myClock = pygame.time.Clock()
-    
-    delay=100
-    interval=50
-    pygame.key.set_repeat(delay,interval)
-    
-# init the test:
-    dramaBackground = pygame.image.load("dramaBackground.png") 
-    
-    fighterFile = "fighter.png"
-    fighterFleet = []
-    for i in range(0,9):
-        fighter = Fighter(fighterFile, len(fighterFleet))
-        fighterFleet.append(fighter)    
-    
-   #d = DeadFighter("deadFighter10PxA-", 450, 100)
-    
-    needDeadFighter = True
-    while True:
-        enviro.screen.blit(dramaBackground, [400,0,330,449])          
-    
-        for event in pygame.event.get():
-            if event.type == pygame.QUIT:
-                sys.exit()
-            if event.type == pygame.KEYDOWN:
-                if (pygame.key.get_mods() == 1024): # command key
-                    if (event.key == 113):   # q
-                        sys.exit()
-                                   
-                if event.key == pygame.K_SPACE:
-                    print "do it"
-                    if d.paint():
-                        print "that's all folks!"
-                        
-                        
-        # A loop like we use to get fighters launched:                
-        for i in range (0,9):
-            if fighterFleet[i].state == "launching":
-                if fighterFleet[i].move() == 0:
-                    print "fighter ",i, "READY TO SHOOT!"
-                    fighterFleet[i].state = "shoot"
-                    
-            if fighterFleet[i].state == "shoot" or fighterFleet[i].state == "shooting":
-                fighterFleet[i].paint()
-            if not (fighterFleet[i].state == "hit" or fighterFleet[i].state == "dead"):
-                fighterFleet[i].smokeCheck() 
-                
-            if fighterFleet[0].state == "shoot" or fighterFleet[0].state == "hit":
-                fighterFleet[0].state = "hit"
-                if needDeadFighter:
-                    needDeadFighter = False
-                    d = DeadFighter("deadFighter10PxA-")
-                    d.setLocation(fighterFleet[0].rect.left, fighterFleet[0].rect.top)
-                else:
-                    if d.paint():
-                        fighterFleet[0].state = "dead"
-                
-
-        myClock.tick(30)
-        pygame.display.flip()  
-    

DeadMother.py

-# coding=UTF8
-# Copyright © 2010 Rob Leachman
-# Please see the file COPYING in this distribution for license information
-import pygame
-import sys # for testing
-from pygame.color import THECOLORS
-
-import enviro # my global game environment
-import Noise
-from Fighter import Fighter # for testing...
-from MotherShip import MotherShip # for testing...
-
-class DeadMother:
-    def __init__(self, filenamePrefix):
-        self.deathImage = []
-        self.deathFrameCount = 0
-        self.top = 0
-        self.left = 0
-        
-        for i in range (1,9):
-            deathFile = filenamePrefix + str(i) + ".png"
-            deathImage = pygame.image.load(deathFile)
-            deathImage.convert()
-            self.deathImage.append(deathImage)
-            
-    def __str__(self):
-        msg =  "  Dead mother X:" + str(self.top) + " Y:" + str(self.left)
-        msg += "    frameCount=" + str(self.deathFrameCount)
-        return msg               
-            
-    def paint(self):
-        deathFrame = self.deathFrameCount 
-        #print "  deathframe=", deathFrame
-        # maybe we got called too many times... if so, let's not crash
-        if deathFrame >= len(self.deathImage):
-            return False
-        enviro.screen.blit(self.deathImage[deathFrame], [self.left, self.top])
-        self.deathFrameCount += 1
-        nextFrame = self.deathFrameCount 
-        # the intention is to signal when we're done, and shouldn't be called again...
-        if nextFrame >= len(self.deathImage):
-            return False
-        return True
-    
-    def setLocation(self,fighterLeft, fighterTop):
-        self.top = fighterTop
-        self.left = fighterLeft - 20
-        self.deathFrameCount = 0
-        
-if __name__ == '__main__':
-    
-    print "TEST: dead mothership"
-    pygame.init()
-    enviro.screen = pygame.display.set_mode([800,600])
-    myClock = pygame.time.Clock()
-    
-    delay=100
-    interval=50
-    pygame.key.set_repeat(delay,interval)
-    
-# stuff needed for init: 
-    enviro.soundEffect = []
-    enviro.soundEffect.append(Noise.load_sound('63068__radian__odd_trimmedAndReworked.wav'))
-    Noise.MOTHER_ENTERS = len(enviro.soundEffect) - 1 
-    
-    dramaBackground = pygame.image.load("dramaBackground.png")   
-    fighterFile = "fighter.png"
-
-    fighterFleet = []
-
-    for i in range(0,9):
-        fighter = Fighter(fighterFile, len(fighterFleet))
-        fighterFleet.append(fighter)
-
-    motherShipFile = "mother.png"
-    bomb_image = "bomb.png"
-    
-    enviro.MOTHER_START_WAIT = 10
-    enviro.MOTHER_RESTART_WAIT = 10  
-    enviro.MOTHER_MIN_RESTART = 10    
-
-    m = MotherShip(motherShipFile, fighterFleet, bomb_image)
-    
-    bombList = pygame.sprite.Group()
-    fightersActive = 1
-    
-    needDeadMother = False
-    sheDied = False
-    dead = DeadMother("motherDead-") 
-    while True:
-    
-        for event in pygame.event.get():
-            if event.type == pygame.QUIT:
-                sys.exit()
-            if (event.type == pygame.KEYDOWN):
-                if (pygame.key.get_mods() == 1024): # command key
-                    if (event.key == 113):   # q
-                        sys.exit()
-                        
-                if event.key == pygame.K_SPACE:                    
-                    m.state = "Hit"
-                    needDeadMother = True
-
-                    
-        enviro.screen.blit(dramaBackground, [400,0,330,449])                    
-                    
-        theMother = m.paint(bombList, fightersActive) # paint her progress, and get any emitted bombs
-        print m.rect.left
-        if needDeadMother:
-
-            dead.setLocation(m.diedAt,0) 
-            needDeadMother = False
-            sheDied = True
-            
-        if sheDied:
-            dead.paint()
-        
-        myClock.tick(30)
-        pygame.display.flip()      
- 
-    

Fighter.py

-# coding=UTF8
-# Copyright © 2010 Rob Leachman
-# Please see the file COPYING in this distribution for license information
-import pygame
-import random
-import sys # for testing
-from pygame.color import THECOLORS
-
-import enviro # my global game environment
-from FloatingSprite import FloatingSprite
-
-class Fighter(FloatingSprite):
-    def __init__(self, image_file, fleetCount):
-        
-        FloatingSprite.__init__(self, image_file)
-        self.maxBombs = 1
-        self.bewareILive(fleetCount)
-        self.bombsOut = 0
-        
-##        smoke_surface = pygame.surface.Surface([10,10])
-##        smokeArray = pygame.surfarray.pixels2d(smoke_surface)
-##        smokeArray[0][0] = 255
-##        smokeArray[9][9] = 255
-##        smokeOut = pygame.surfarray.make_surface(smokeArray)
-##        smokeOut.convert()
-##        
-##        enviro.screen.blit(smokeOut, [10,10])
-        
-    def __str__(self):
-        msg = FloatingSprite.__str__(self)
-        msg +=  "  Fighter state:" + str(self.state)
-        return msg         
-        
-    def bewareILive(self, fleetCount):
-        self.trueLeft = 552 # 552 will start right below mother
-        self.trueTop = 21 # 21 will start right below mother
-        
-        if fleetCount > -1:
-            self.fleetPosition = fleetCount        
-        
-##        fighterSpots = [ [560,91], [440,91], [500,91], [620,91], [680,91],
-##                            [470,71], [650,71], [590,71], [530,71]]
-        fighterSpots = ( (500,91), (680,91), (440,91), (620,91), (560,91),
-                            (470,71), (650,71), (590,71), (530,71) )                            
-        self.destX = fighterSpots[self.fleetPosition ][0]
-        self.destY = fighterSpots[self.fleetPosition ][1]
-        
-        self.calcSpeed(enviro.FIGHTER_LAUNCH_SPEED) # maybe 30.0 good for prod?
-        
-        self.state = "launching"
-        self.fullHealth = 150
-        self.life = self.fullHealth
-        
-    def smokeCheck(self):
-        top = self.rect.top+9
-        left = self.rect.left
-        if self.life > 0:
-            lifebar = (float(self.life)/self.fullHealth) * 20
-            pygame.draw.lines(enviro.screen, [255,255,255], False, [ [left,top],[left+lifebar,top]], 1)
-        
-    def test(self, targetSprite, nextState, laserPower):
-        # see if this fighter is it by the targeting sprite, if so set the next state
-
-        hitMe = False
-        killedMe = False
-        tester = pygame.sprite.Group()
-        tester.add(targetSprite)
-        if pygame.sprite.spritecollideany(self, tester):
-            #print "FIGHTER HIT! Laser power=", enviro.LASER_POWER
-            hitMe = True
-            self.life = self.life - laserPower
-            if self.life < 1:
-               self.state = nextState
-               killedMe = True
-        return [hitMe, killedMe]
-    
-    def takeAShot(self):
-        randShot = random.randint(1,10)
-        if randShot == 1:
-            if self.bombsOut < self.maxBombs:
-               self.state = "shooting"
-               self.bombsOut = self.bombsOut + 1
-               return True
-        return False
-    
-    def shotExpired(self):
-        self.bombsOut = self.bombsOut - 1
-        if self.state <> "hit" and self.state <> "launching":
-            self.state = "shoot"
-            
-        
-if __name__ == '__main__':
-    
-    print "TEST: fighter"
-    pygame.init()
-    enviro.screen = pygame.display.set_mode([800,600])
-    myClock = pygame.time.Clock()
-    
-# stuff needed for init: 
-    dramaBackground = pygame.image.load("dramaBackground.png")   
-    fighterFile = "fighter.png"
-
-    fighterFleet = []
-
-    for i in range(0,9):
-        fighter = Fighter(fighterFile, len(fighterFleet))
-        fighterFleet.append(fighter)
-       
-
-#    fightersActive = 1
-            
-    while True:
-
-
-    
-        for event in pygame.event.get():
-            if event.type == pygame.QUIT:
-                sys.exit()
-        if (event.type == pygame.KEYDOWN):
-            if (pygame.key.get_mods() == 1024): # command key
-                if (event.key == 113):   # q
-                    sys.exit()
-            if event.key == pygame.K_x:                    
-                fighterFleet[0].life = fighterFleet[0].life - 1
-                    
-            if event.key == pygame.K_SPACE:                    
-                fighterFleet[0].smokeCheck()
-                    
-        enviro.screen.blit(dramaBackground, [400,0,330,449])                    
-
-        for i in range (0,9):
-            if fighterFleet[i].state == "launching":
-                if fighterFleet[i].move() == 0:
-                    print "fighter ",i, "READY TO SHOOT!"
-                    fighterFleet[i].state = "shoot"
-                    
-            if fighterFleet[i].state == "shoot" or fighterFleet[i].state == "shooting":
-                fighterFleet[i].paint()
-            if i == 0:
-                fighterFleet[i].smokeCheck()
-        
-        myClock.tick(30)
-        pygame.display.flip()                 

FloatingSprite.py

-# coding=UTF8
-# Copyright © 2010 Rob Leachman
-# Please see the file COPYING in this distribution for license information
-import pygame
-from pygame.color import THECOLORS
-import enviro # my global game environment
-
-
-# Floating sprites work properly when speed is a float
-# (compare with pygame sprites which don't move properly if not int)
-class FloatingSprite(pygame.sprite.Sprite):
-    def __init__(self, image_file):
-        
-        pygame.sprite.Sprite.__init__(self)
-        self.theImage = image_file
-        self.image = pygame.image.load(self.theImage)
-        self.rect = self.image.get_rect()
-        
-        self.trueLeft = 0
-        self.trueTop = 0
-        
-        self.destX = 0
-        self.destY = 0
-        
-    def calcSpeed(self, steps):
-
-        speedX = (self.destX - self.trueLeft) / steps
-        speedY = (self.destY - self.trueTop) / steps
-        self.speed = [speedX, speedY]
-        
-    def __str__(self):
-        msg =  "FloatingSprite at x: %.1f y: %.1f" % (self.trueLeft, self.trueTop)
-        msg += "  dest x: " + str(self.destX) + " y:" + str(self.destY)
-        msg += "  speed x: %.2f y: %.2f" % (self.speed[0], self.speed[1])
-        return msg
-    
-    def paint(self):
-        self.rect.left = self.trueLeft
-        self.rect.top = self.trueTop
-                
-        enviro.screen.blit(self.image, self.rect) 
-        
-    def move(self):
-        if self.speed == [0,0]:
-            #print "Floating sprite at destination!"
-            return 0
-        
-        #pygame.draw.rect(enviro.screen, THECOLORS["black"], [self.rect.left,self.rect.top,self.rect.width,self.rect.height], 0)
-        self.trueLeft = self.trueLeft + self.speed[0]
-        self.trueTop = self.trueTop + self.speed[1]
-
-        self.rect.left = self.trueLeft
-        self.rect.top = self.trueTop
-        #print "Plotting at x=", self.rect.left, "y=",self.rect.top
-        #self.rect = self.rect.move(self.speed) # won't work with float!
-        
-        if self.speed[0] > 0:
-            #print "moving right ", self.rect.left, self.speed[0]
-            if self.trueLeft + self.speed[0] > self.destX:
-                self.speed[0] = self.destX - self.trueLeft
-        elif self.speed[0] < 0:
-            #print "moving left", self.rect.left, self.speed[0]
-            if self.trueLeft + self.speed[0] < self.destX:
-                self.speed[0] = self.destX - self.trueLeft
-                
-        if self.speed[1] > 0:
-            #print "moving down ", self.rect.top, self.speed[1]
-            if self.trueTop + self.speed[1] > self.destY:              
-                self.speed[1] = self.destY - self.trueTop
-        elif self.speed[1] < 0:
-            #print "moving up ", self.rect.top, self.speed[1]            
-            if self.trueTop + self.speed[1] < self.destY:               
-                self.speed[1] = self.destY - self.trueTop
-            
-        #print "float X:", self.rect.left, "Y:",self.rect.top, "destX:",self.destX, "destY:", self.destY, "speedX", self.speed[0], "speedY", self.speed[1]
-        enviro.screen.blit(self.image, self.rect)
-        if self.rect.left == self.destX:
-            self.trueLeft = self.destX
-            self.speed = [0,self.speed[1]]
-        if self.rect.top == self.destY:
-            self.trueTop = self.destY
-            self.speed = [self.speed[0], 0]
-        return 1
-            
-    def erase(self):
-        pygame.draw.rect(enviro.screen, THECOLORS["black"], [self.rect.left,self.rect.top,self.rect.width,self.rect.height], 0)
-        
-        
-        
-        

GasFactory.py

-# coding=UTF8
-# Copyright © 2010 Rob Leachman
-# Please see the file COPYING in this distribution for license information
-#not sure all of these are needed...
-import pygame, random
-from pygame.color import THECOLORS
-
-import enviro # my global game environment
-import Noise
-    
-from AttackerStuff import ShieldSprite
-from Harvester import Harvester
-
-
-class GasFactory(pygame.sprite.Sprite):
-    def __init__(self, image_file, left, top, 
-                 needStuff0_img, needMoney0_img, needMoney1_img, needMoney2_img, needStuff_img, built_img):
-        
-        pygame.sprite.Sprite.__init__(self)
-        self.theImage = image_file
-        self.image = pygame.image.load(self.theImage)
-        self.rect = self.image.get_rect()
-        self.rect.left = left
-        self.rect.top = top
-        self.location = 8
-        
-        self.need0_white = pygame.image.load(needStuff0_img)
-        self.need0 = pygame.image.load(needMoney0_img)
-        self.need1 = pygame.image.load(needMoney1_img)
-        self.need2 = pygame.image.load(needMoney2_img)
-        self.needStuffToBuild = pygame.image.load(needStuff_img)
-        self.gasFactoryBuilt = pygame.image.load(built_img)
-        self.needCount = 0
-        self.needXOffset = 20
-        self.needYOffset = 60
-        self.needType = "none"         
-        self.built = 0
-        self.padPainted = False
-##        if self.built == 1:
-##            self.build()
-
-    def paintPad(self):
-        enviro.screen.blit(self.image, self.rect)
-        self.padPainted = True
-        
-    def build(self):
-        self.built = 1
-        enviro.gasFactoryIsBuilt = True
-        enviro.screen.blit(self.gasFactoryBuilt, self.rect)
-        
-    def needMoney(self):
-        #print "NEED MONEY"
-        paintX = self.rect.left
-        paintY = self.rect.top
-        enviro.screen.blit(self.need1, [paintX+self.needXOffset, paintY+self.needYOffset])
-        self.needType = "credits"
-        self.needCount = 100
-        
-    def needStuff(self):
-        #print "NEED STUFF"
-        paintX = self.rect.left
-        paintY = self.rect.top
-        self.needType = "stuff"
-        enviro.screen.blit(self.needStuffToBuild, [paintX+self.needXOffset, paintY+self.needYOffset])
-        self.needCount = 100
-        
-    def clearNeeds(self):
-
-        paintX = self.rect.left
-        paintY = self.rect.top
-        if self.needCount > 0:
-            self.needCount = self.needCount - 1
-            #print "factory need type:", self.needType, " count:", self.needCount
-            if self.needCount == 0:
-                if self.built == 0:
-                   enviro.screen.blit(self.need0, [paintX+self.needXOffset, paintY+self.needYOffset])
-                else:
-                   enviro.screen.blit(self.need0_white, [paintX+self.needXOffset, paintY+self.needYOffset]) 
-            else:
-                needPhase = self.needCount / 10 - 1
-                if needPhase % 2 == 1 and needPhase > 1:
-                    enviro.screen.blit(self.need2, [paintX+self.needXOffset, paintY+self.needYOffset])
-                else:
-                    if self.needType == "credits":
-                        enviro.screen.blit(self.need1, [paintX+self.needXOffset, paintY+self.needYOffset])
-                    elif self.needType == "stuff":
-                        enviro.screen.blit(self.needStuffToBuild, [paintX+self.needXOffset, paintY+self.needYOffset])                  
-        
-    def paint(self,fuelPile):
-        enviro.screen.blit(self.image, self.rect)
-        self.myFuelPile = fuelPile
-
-        self.myFuelPile[self.fuelBay[1]].paint([146,150])
-        self.myFuelPile[self.fuelBay[0]].paint([173,150])
-        self.myFuelPile[self.fuelBay[2]].paint([200,150])
-        
-    def repaintBays(self):
-        #enviro.screen.blit(self.image, self.rect)
-
-        self.myFuelPile[self.fuelBay[1]].paint([146,150])
-        self.myFuelPile[self.fuelBay[0]].paint([173,150])
-        self.myFuelPile[self.fuelBay[2]].paint([200,150])
-    
-    def stashStuff(self):
-        for i in range(0,3):
-            if self.fuelBay[i] == 0:
-                self.fuelBay[i] = 10
-                self.repaintBays()
-                return True
-        return False
-    
-    def getStuff(self):
-        for i in range(0,3):
-            if self.fuelBay[i] == 10:
-                self.fuelBay[i] = 0
-                self.repaintBays()
-                return True
-        return False
-            

Generator.py

-# coding=UTF8
-# Copyright © 2010 Rob Leachman
-# Please see the file COPYING in this distribution for license information
-import pygame, random
-from pygame.color import THECOLORS
-
-import enviro # my global game environment
-import Noise
-
-from YourStuff import *
-
-    
-
-  
-class Generator:
-    def __init__(self, location, gauges, image_file):
-        
-        self.location = location
-        self.isReady = False
-        self.isTargeted = False
-        self.processCount = 0
-        self.cycleCount = 0
-        self.gas = 60
-        self.gasPromised = False
-                
-        coordX = enviro.getLocationX(location)
-        coordY = enviro.getLocationY(location)
-        
-        #image = pygame.image.load(image_file).convert()
-        image = pygame.image.load(image_file)
-        #print "Can't convert, it loses alpha..."
-        enviro.screen.blit(image,[coordX,coordY])
-        
-        #pygame.draw.rect(enviro.screen, [0,0,200], [coordX+5,coordY+5,80,80],0) # generator
-        #pygame.draw.rect(enviro.screen, THECOLORS["gray63"], [coordX+25,coordY+20,40,40],0) # result box
-        gauges[0].paint([coordX+15,coordY+10])
-        
-        self.genImage = []
-        for i in range (1,11):
-            genImg = pygame.image.load("generating-"+str(i)+".png")
-            self.genImage.append(genImg)
-            
-        
-    def __str__(self):
-        msg = "GENERATOR DEBUGGER:" + "\n"
-        msg += " Location: " + str(self.location) + "\n"
-        msg += " Ready: " + str(self.isReady) + "\n"
-        msg += " Targeted: " + str(self.isTargeted) + "\n"
-        msg += " Process count: "  + str(self.processCount) + "\n"
-        return msg
-    
-    def checkTankEmpty(self):
-        if self.gas == 0 and self.gasPromised == False:
-            return True
-        return False
-                
-    def produce(self, gauges):
-
-        coordX = enviro.getLocationX(self.location)
-        coordY = enviro.getLocationY(self.location)
-                
-        if (self.processCount == 10):
-            self.isReady = True
-            self.processCount = 0
-            pygame.draw.rect(enviro.screen, [0,255,0], 
-               [(coordX + 30), (coordY + 25),30,30],0) # the result
-    
-        hasGas = False
-        if (self.isReady == False):
-            if self.cycleCount == 0 and self.processCount == 0:
-                if self.gas > 0:
-                    self.gas = self.gas - 20
-                    hasGas = True
-                
-                    if self.gas == 40:
-                        gauges[1].paint([coordX+15,coordY+10])
-                    if self.gas == 20:
-                        gauges[2].paint([coordX+15,coordY+10])
-                    if self.gas == 0:
-                        gauges[3].paint([coordX+15,coordY+10])
-            else:
-                hasGas = True
-                
-            if hasGas:
-                self.cycleCount = self.cycleCount + 1
-                if self.cycleCount > enviro.PRODUCTION_TIMER:
-                    self.cycleCount = 0
-                    self.processCount = self.processCount + 1
-                    enviro.screen.blit(self.genImage[self.processCount-1], [coordX+5,coordY+15])
-##                    pygame.draw.rect(enviro.screen, [255,255,0], 
-##                        [(coordX + 4) + self.processCount * 7,(coordY + 70),5,5],0)
-                        
-    def refill(self, gasGauges):
-        coordX = enviro.getLocationX(self.location)
-        coordY = enviro.getLocationY(self.location)
-                
-        self.gas = 60
-        gasGauges[0].paint([coordX+15,coordY+10])
-        self.gasPromised = False
-                    
-    def harvestStuff(self):
-        if self.isReady == True:
-            self.isReady = False
-            self.isTargeted = False
-            self.processCount = 0
-            self.cycleCount = 0
-            coordX = enviro.getLocationX( self.location )
-            coordY = enviro.getLocationY( self.location )
-            #pygame.draw.rect(enviro.screen, [100,100,0], [coordX+25,coordY+10,40,40],0) # result box
-            pygame.draw.rect(enviro.screen, [0,0,200], 
-                        [ coordX + 5, coordY + 70,80,5],0) # clear the progress meter
-            pygame.draw.rect(enviro.screen, [0,0,200], 
-                   [(coordX + 30), (coordY + 25),30,30],0) # the result
-            return True
-        return False
-    
-    
-if __name__ == '__main__':
-    
-    pygame.init()
-    enviro.screen = pygame.display.set_mode([800,600])
-    myClock = pygame.time.Clock()
-    
-    delay=100
-    interval=50
-    pygame.key.set_repeat(delay,interval)
-        
-    
-# stuff needed for init:
-    gasFiles = ["gas-full.png", "gas-twoThirds.png", "gas-oneThird.png", "gas-empty.png"]
-    for gasFile in gasFiles:
-        gas = GasGauge(gasFile)
-        enviro.gasGauges.append(gas)
-
-
-    newGen = Generator(5,enviro.gasGauges, "generator0.png")
-    newGen.refill(enviro.gasGauges)
-    
-    enviro.PRODUCTION_TIMER = 1
-            
-    while True:
-        
-        for event in pygame.event.get():
-            if event.type == pygame.QUIT:
-                sys.exit()
-            if (event.type == pygame.KEYDOWN):
-                if (pygame.key.get_mods() == 1024): # command key
-                    if (event.key == 113):   # q
-                        sys.exit()
-                        
-                if event.key == pygame.K_SPACE:
-                    print "Generate!"
-                    newGen.produce(enviro.gasGauges)
-                   
-                    
-        myClock.tick(30)
-        pygame.display.flip()       
-              

Harvester.py

-# coding=UTF8
-# Copyright © 2010 Rob Leachman
-# Please see the file COPYING in this distribution for license information
-import pygame, random
-from pygame.color import THECOLORS
-
-import enviro # my global game environment
-import Noise
-
-import sys    # for testing
-    
-from AttackerStuff import ShieldSprite
-
-class Harvester:
-    def __init__(self, count):
-        
-        self.imageEmpty = pygame.image.load("botEmpty.png")
-        self.imageEmpty.convert() # they say this makes it faster...
-        self.imageStuff = pygame.image.load("botWithStuff.png")
-        self.imageStuff.convert()
-        self.imageGas = pygame.image.load("botWithGas.png")
-        self.imageGas.convert()
-        self.rect = self.imageEmpty.get_rect()
-        
-        self.state = "Returning" # they used to start Idle, now "return" to home
-        self.target = 0 # we're on the path to location 0
-        self.progress = 3 # was 0
-        self.fleetPosition = count
-        self.cooldown = 0
-        self.gasTarget = -1
-
-        self.locationX = 35
-        self.locationY = 100
-        pygame.draw.rect(enviro.screen, [200,0,0], [self.locationX,self.locationY,40,40], 0)
-        
-    def __str__(self):
-##        msg = "HARVESTER DEBUGGER:" + "\n"
-        msg = " Harvester: " + str(self.fleetPosition) + "\n"
-        msg += " State: " + str(self.state) + "\n"
-        msg += " Location: " + str(self.locationX) + "," + str(self.locationY) + "\n"
-        msg += " Progress: " + str(self.progress)
-        return msg        
-                    
-    def spawn(self):
-        # home location
-        self.locationX = 165
-        self.locationY = 230
-        
-        coordX = enviro.getLocationX(4)
-        coordY = enviro.getLocationY(4)
-        pygame.draw.rect(enviro.screen, [255,255,255], 
-            [(coordX + 5) + (self.fleetPosition+1) * 7,(coordY + 70),5,5],0)
-            
-        enviro.screen.blit(self.imageEmpty, [self.locationX,self.locationY])
-
-    def move(self, goalX, goalY, pathDirection):
-        #print "Target=", self.target, "progress=", self.progress
-        
-        # erase where we're at now -- or not, since in the end I decided to paint the road every frame
-        #pygame.draw.rect(enviro.screen, [0,0,0], [self.locationX,self.locationY,40,40], 0)
-        #self.rect.top = self.locationY
-        #self.rect.left = self.locationX
-        #enviro.screen.blit(enviro.roadImage,self.rect,self.rect)
-        
-        # then move, like add 1 to y
-        if self.locationY < goalY:
-            self.locationY = self.locationY + enviro.SPEED
-            if self.locationY > goalY:
-                self.locationY = goalY
-        if self.locationY > goalY:
-            self.locationY = self.locationY - enviro.SPEED
-            if self.locationY < goalY:
-                self.locationY = goalY
-        if self.locationX < goalX:
-            self.locationX = self.locationX + enviro.SPEED
-            if self.locationX > goalX:
-                self.locationX = goalX
-        if self.locationX > goalX:
-            self.locationX = self.locationX - enviro.SPEED
-            if self.locationX < goalX:
-                self.locationX = goalX
-        
-        # draw new
-        if self.state == "GotGas" or self.state == "DeliverGas":
-           enviro.screen.blit(self.imageGas, [self.locationX,self.locationY])            
-        elif (self.state == "Carrying" or
-            self.state == "Selling" or 
-            self.state == "Fueling" or 
-            self.state == "Stuck" or 
-            self.state == "Reenergizing" or
-            self.state == "GetGas"):
-           self.paintHarvesterWithStuff()
-        else:
-           enviro.screen.blit(self.imageEmpty, [self.locationX,self.locationY])
-        
-        if self.locationX == goalX and self.locationY == goalY:
-            if pathDirection == 1:
-                self.progress = self.progress + 1
-            else:
-                self.progress = self.progress - 1
-        return self.progress
-    
-    def paintHarvesterWithStuff(self):
-        #pygame.draw.rect(enviro.screen, [0,255,0], 
-        #       [(self.locationX + 5), (self.locationY + 5),30,30],0)
-        enviro.screen.blit(self.imageStuff, [self.locationX,self.locationY])            
-            
-    def home(self):
-        # erase from playfield
-        #pygame.draw.rect(enviro.screen, [0,0,0], [self.locationX,self.locationY,40,40], 0)
-        self.rect.top = self.locationY
-        self.rect.left = self.locationX
-        #enviro.screen.blit(enviro.roadImage,self.rect,self.rect)        
-        
-        # add back to home list
-        coordX = enviro.getLocationX(4)
-        coordY = enviro.getLocationY(4)
-    
-        pygame.draw.rect(enviro.screen, [255,0,0], 
-            [(coordX + 5) + (self.fleetPosition+1) * 7,(coordY + 70),5,5],0)
-
-    def getNextState(self, shields, base, generators, laser):
-        #print "state ", self.state, "progress", self.progress, "x", self.locationX
-        
-        if self.state == "Cooling":
-            self.cooldown = self.cooldown - 1
-            if self.cooldown < 1:
-                self.state = "Idle"
-        
-        # First priority is to capitalize on when she's dead, sell
-        if self.state == "Idle" and base.isFull():
-            if enviro.mother.state == "Hit" or enviro.mother.state == "Waiting":
-                if enviro.combatStarted:
-                    if base.getStuff():
-                        self.state = "Selling"
-                        self.target = 13 # the market
-                        self.progress = 0
-                        self.spawn() 
-                        
-        # Under combat, don't let the shields or laser run dry...
-        # but they don't need to be chock full either, not if we've got
-        # a generator out of gas
-        if self.state == "Idle":
-            # Be sure the shields are pumping safety above our head
-            if shields.nearlyEmpty():
-                if base.getStuff():
-                    self.state = "Fueling"
-                    shields.promiseRefuel()
-                    self.target = 9 # the shield generator
-                    self.progress = 0
-                    self.spawn()
-            # ...and then be sure we're blasting anything we can
-            elif laser.nearlyEmpty():
-                if base.getStuff():
-                    self.state = "Reenergizing"
-                    laser.promiseRefuel()
-                    self.target = 10
-                    self.progress = 0
-                    self.spawn()                        
-                        
-        # They're not running dry, so next priority is to keep the generators fueled up
-        if self.state == "Idle" and enviro.gasFactory.built == 1:
-            for generator in generators:
-                genIsEmpty = generator.checkTankEmpty()
-                if genIsEmpty:
-                    #print "Found empty tank"
-                    if base.getStuff():
-                        generator.gasPromised = True                    
-                        self.state = "GetGas"
-                        self.target = 8
-                        self.gasTarget = generator.location
-                        self.progress = 0
-                        self.spawn()                       
-                        break                                          
-        
-        if self.state == "Idle":
-            # Be sure the shields are pumping safety above our head
-            if shields.needFuel():
-                if base.getStuff():
-                    self.state = "Fueling"
-                    shields.promiseRefuel()
-                    self.target = 9 # the shield generator
-                    self.progress = 0
-                    self.spawn()
-            # ...and then be sure we're blasting anything we can
-            elif laser.needFuel():
-                if base.getStuff():
-                    self.state = "Reenergizing"
-                    laser.promiseRefuel()
-                    self.target = 10
-                    self.progress = 0
-                    self.spawn()
-                    
-            # Find a generator that has stuff ready to collect...
-            for generator in generators:
-                # need to check idle here again because two generators could be ready at the same time...
-                if self.state == "Idle" and generator.isReady == True and generator.isTargeted == False:
-                    #print "Found target to harvest"
-                    self.state = "Harvesting"
-                    self.target = generator.location
-                    generator.isTargeted = True
-                    self.progress = 0
-                    self.spawn()
-
-        if self.state == "Fueling" or self.state == "Selling":
-            goalX = enviro.path[self.target][self.progress][0]
-            goalY = enviro.path[self.target][self.progress][1]
-            if goalX <> -1:
-                self.move(goalX, goalY, 1)
-            else:
-                if self.state == "Fueling":
-                    if shields.loadFuel():
-                        self.state = "Returning"
-                        self.progress = self.progress - 1;
-                    else: # couldn't refuel, must return
-                        self.state = "Carrying"
-                        self.progress = self.progress - 1;
-                elif self.state == "Selling":
-                    #print "At market!"
-                    enviro.credits = enviro.credits + 1000
-                    #print "now you have ", enviro.credits
-                    enviro.writeCredits(enviro.credits)
-                    self.state = "Returning"
-                    self.progress = self.progress - 1
-                    enviro.SPEED = enviro.SPEED + .25
-                    enviro.YOURSPEED = enviro.YOURSPEED + .25
-                    enviro.PRODUCTION_TIMER -= 1
-                    if enviro.PRODUCTION_TIMER < 1:
-                        enviro.PRODUCTION_TIMER = 1
-                    
-        if self.state == "Reenergizing":
-            goalX = enviro.path[self.target][self.progress][0]
-            goalY = enviro.path[self.target][self.progress][1]
-            if goalX <> -1:
-                self.move(goalX, goalY, 1)
-            else:
-                if laser.stashStuff():
-                    self.state = "Returning"
-                    self.progress = self.progress - 1;
-                else: # couldn't refuel, must return
-                    self.state = "Carrying"
-                    self.progress = self.progress - 1; 
-                    
-        if self.state == "GetGas" or self.state == "DeliverGas":
-            goalX = enviro.path[self.target][self.progress][0]
-            goalY = enviro.path[self.target][self.progress][1]
-            if goalX <> -1:
-                self.move(goalX, goalY, 1)
-            else:
-                if self.state == "GetGas":
-                    self.state = "GotGas"
-                    self.progress = self.progress - 1;            
-                elif self.state == "DeliverGas":
-                    #print "At gas target!"
-                    for generator in generators:
-                        if generator.location == self.target:
-                            generator.refill(enviro.gasGauges)
-                            break
-                    self.state = "Returning"
-                    self.progress = self.progress - 1;
-            
-        if self.state == "Harvesting":
-            goalX = enviro.path[self.target][self.progress][0]
-            goalY = enviro.path[self.target][self.progress][1]
-            
-            if goalX <> -1:
-                self.move(goalX, goalY, 1)
-            else:
-                for generator in generators:
-                    if self.target == generator.location:
-                        if generator.harvestStuff():
-                            self.state = "Carrying"
-                            self.paintHarvesterWithStuff()
-                            self.progress = self.progress - 1;
-                        else: # somebody beat me to it
-                            self.state = "Returning"
-                            self.progress = self.progress - 1
-
-        # Come back, on path direction negative
-        if (self.state == "Carrying" or 
-            self.state == "Returning" or 
-            self.state == "GotGas"):
-            goalX = enviro.path[self.target][self.progress][0]
-            goalY = enviro.path[self.target][self.progress][1]
-            newProgress = self.move(goalX, goalY, -1) 
-            if newProgress == -1: # made it home
-                if self.state == "Carrying":
-                    if base.stashStuff():
-                       self.state = "Cooling"
-                       self.cooldown = enviro.HARVESTER_COOLDOWN
-                       #print "Home!"
-                       self.home()
-                    else:
-                       self.state = "Stuck"
-                       self.progress = 0
-                       self.target = random.randint(11,12)
-                elif self.state == "Returning":
-                    self.state = "Cooling"
-                    self.cooldown = enviro.HARVESTER_COOLDOWN
-                    #print "Home!"
-                    self.home()
-                elif self.state == "GotGas":
-                    self.state = "DeliverGas"
-                    self.progress = 0
-                    self.target = self.gasTarget
-                    
-                    
-        if self.state == "Stuck":
-            if enviro.mother.state == "Hit" or enviro.mother.state == "Waiting":
-                if enviro.combatStarted:                
-                    self.state = "Selling"
-                    self.target = 13 # the market
-                    self.progress = 0
-                            
-            if shields.needFuel():
-                self.state = "Fueling"
-                self.target = 9 # the shield generator
-                self.progress = 0
-                shields.promiseRefuel()
-                
-            elif laser.needFuel():
-                self.state = "Reenergizing"
-                laser.promiseRefuel()                
-                self.target = 10
-                self.progress = 0
-                
-            else:
-                # see if the stuff should be made into gas
-                genNeedsGas = False
-                for generator in generators:
-                    genIsEmpty = generator.checkTankEmpty()
-                    if genIsEmpty:
-                        genNeedsGas = True
-                        generator.gasPromised = True                    
-                        self.state = "GetGas"
-                        self.target = 8
-                        self.gasTarget = generator.location
-                        self.progress = 0
-                        break
-                        
-                if not genNeedsGas:
-                    # we're just stuck, pace awhile and try again in a bit
-                    goalX = enviro.path[self.target][self.progress][0]
-                    goalY = enviro.path[self.target][self.progress][1]
-                    if goalX <> -1:
-                        self.move(goalX, goalY, 1)
-                    else:
-                        self.state = "Carrying"
-                        self.progress = self.progress - 1
-                        # Huh, I needed to move here to avoid some mean flicker
-                        # Not sure why just here though, odd?
-                        goalX = enviro.path[self.target][self.progress][0]
-                        goalY = enviro.path[self.target][self.progress][1]                        
-                        self.move(goalX, goalY, -1) 
-
-
-if __name__ == '__main__':
-
-    
-    print "TEST: Harvester"
-    pygame.init()
-    enviro.screen = pygame.display.set_mode([800,600])    
-    h = Harvester(0)
-
-    pygame.display.flip()
-    while True:
-    
-        for event in pygame.event.get():
-            if event.type == pygame.QUIT:
-                sys.exit()
-        if (event.type == pygame.KEYDOWN):
-            if (pygame.key.get_mods() == 1024): # command key
-                if (event.key == 113):   # q
-                    sys.exit()                    

Laser.py

-# coding=UTF8
-# Copyright © 2010 Rob Leachman
-# Please see the file COPYING in this distribution for license information
-#not sure all of these are needed...
-import sys
-import pygame
-from pygame.color import THECOLORS
-
-import enviro # my global game environment
-import Noise
-    
-from AttackerStuff import ShieldSprite
-from YourStuff import TargetSprite
-from YourStuff import FuelStuff # for testing
-
-
-class Laser(pygame.sprite.Sprite):
-    def __init__(self, image_file):
-        
-        pygame.sprite.Sprite.__init__(self)
-        self.theImage = image_file
-        self.image = pygame.image.load(self.theImage)
-        self.rect = self.image.get_rect()
-        self.location = 11
-        
-        self.state = "Armed"
-        self.aimCount = 0
-        
-        self.fuelBay = [10,10,10]
-        self.promises = 0
-        
-        self.consuming = enviro.LASER_PER_PELLET
-        self.consumingBay = 0
-##        self.upgrades = init_Upgrades
-##        for i in range(0,self.upgrades):
-##            self.applyUpgrade()
-        self.upgrades = enviro.laserUpgrades
-        self.initUpgrades() # I added continue/restart too late, killing me now
-            
-    def initUpgrades(self):
-        self.laserPower = enviro.LASER_UPGRADE_POWER
-        self.aimTime = enviro.LASER_AIM_TIME
-        for i in range(0,self.upgrades):
-            self.applyUpgrade()        
-            
-    def paintPad(self):
-        pass
-        
-    def paint(self, location, fuelPile):
-        self.myFuelPile = fuelPile
-        
-        self.rect.left = location[0]
-        self.rect.top = location[1]
-        
-        enviro.screen.blit(self.image, self.rect)
-        
-        left = self.rect.left
-        top = self.rect.top
-        self.myFuelPile[self.fuelBay[0]].paint([left+5,top + 44])
-        self.myFuelPile[self.fuelBay[1]].paint([left+5+(173-146),top + 44])
-        self.myFuelPile[self.fuelBay[2]].paint([left+5+(200-146),top + 44])
-        
-        pygame.draw.rect(enviro.screen, THECOLORS["blue"], [left+4,top+71,80,9], 0)
-        for i in range(0, self.upgrades):
-            pygame.draw.rect(enviro.screen, [130,202,253], [left+6+i*7,top+73,5,5], 0)
-        
-    def repaint(self):
-        enviro.screen.blit(self.image, self.rect)
-        
-        left = self.rect.left
-        top = self.rect.top
-        self.myFuelPile[self.fuelBay[0]].paint([left+5,top + 44])
-        self.myFuelPile[self.fuelBay[1]].paint([left+5+(173-146),top + 44])
-        self.myFuelPile[self.fuelBay[2]].paint([left+5+(200-146),top + 44])
-        
-        pygame.draw.rect(enviro.screen, THECOLORS["blue"], [left+4,top+71,80,9], 0)
-        for i in range(0, self.upgrades):
-            pygame.draw.rect(enviro.screen, [130,202,253], [left+6+i*7,top+73,5,5], 0)
-            
-    def upgrade(self):
-        if self.upgrades < 11:
-            self.upgrades = self.upgrades + 1
-            enviro.laserUpgrades = enviro.laserUpgrades + 1
-            self.applyUpgrade()
-            self.repaint()
-            return True
-        return False
-    
-    def applyUpgrade(self):
-        self.laserPower += enviro.LASER_UPGRADE_POWER
-        self.aimTime -= 7.5
-        #print "Laser power=", self.laserPower, " aimTime=", self.aimTime
-
-        
-    def stashStuff(self):
-        for i in range(0,3):
-            if self.fuelBay[i] == 0:
-                self.fuelBay[i] = 10
-                self.promises = self.promises - 1
-                
-                # pretty sure this is too simple, but moving on...
-                # "if we're out of gas then this pad got loaded with 9
-                #  and the laser is restocked..." -- but what if there's
-                #  another bay with fuel? I think we restock too soon?
-                if self.consuming == 0:
-                    self.fuelBay[i] = 9
-                    self.consuming = enviro.LASER_PER_PELLET
-                self.repaint()
-                return True
-        return False
-    
-    def unloadStuff(self):
-        for i in range(0,3):
-            if self.fuelBay[i] == 10:
-                self.fuelBay[i] = 0
-                self.repaint()
-                return True
-        return False
-        
-    
-    # See if we could use more fuel for laser
-    def needFuel(self):
-        if enviro.laserRefuelDisabled:
-            return False
-        
-        emptyBays = 0
-        for i in range(0,3):
-            if self.fuelBay[i] == 0:
-                emptyBays += 1
-        if emptyBays > self.promises:
-            return True
-        return False 
-    
-    # See if we're about to run out of laser power
-    def nearlyEmpty(self):
-        if enviro.laserRefuelDisabled:
-            return False
-        
-        emptyBays = 0
-        for i in range(0,3):
-            if self.fuelBay[i] == 0:
-                emptyBays += 1
-        if emptyBays < 2:
-            return False
-        if emptyBays > self.promises:
-            return True
-        return False     
-               
-    def promiseRefuel(self):
-        self.promises = self.promises + 1    
-
-    def autoTarget(self, bombList):
-        targetCoord = [0,0]
-        
-        if self.state == "Armed":
-            self.aimCount = self.aimCount + 1
-            if self.aimCount > self.aimTime:
-                self.aimCount = 0
-                self.state = "Shooting"
-        elif self.state == "Shooting":
-            if len(bombList) > 0:
-                
-                lowest = 0
-                for bomb in bombList:
-                    if bomb.rect.top > lowest:
-                        lowest = bomb.rect.top
-                        targetBomb = bomb
-                targetCoord = targetBomb.rect.center
-                #print "autoshoot! target=",targetCoord
-                
-                self.state = "Armed"
-            
-        return targetCoord
-        
-        
-    def shoot(self, bombList, cursor, mouseButtonUp, autoTargeting):
-        stillShooting = False
-        laserHitCenter = [0,0]
-        shootingBomb = False
-        
-        # This could be better?
-        if mouseButtonUp:
-            return False # not shooting anymore
-
-        cost = 5 + self.upgrades * enviro.LASER_COST_FACTOR     
-        self.consuming -= cost
-        #print "Shooting, power=", enviro.LASER_POWER, "cost=", cost, "consuming buffer=", self.consuming
-        
-        if self.consuming < 1:
-            if self.fuelBay[self.consumingBay] == 0:            
-                for i in range(0,3):
-                    if self.fuelBay[i] > 0:
-                        self.consumingBay = i            
-            
-            if self.fuelBay[self.consumingBay] > 0:
-               self.consuming = enviro.LASER_PER_PELLET
-               self.fuelBay[self.consumingBay] = self.fuelBay[self.consumingBay] - 1
-               self.repaint()
-        
-        if self.consuming < 1:
-            return False            
-        
-        target = TargetSprite()
-        target.rect.centerx = cursor[0]
-        target.rect.centery = cursor[1]        
-        
-        miss = True
-        
-        # target the mothership
-        if not autoTargeting and enviro.mother.rect.center[0] < 680: # don't target if not fully in area
-        
-            motherHit = enviro.mother.test(target, "Hit", self.laserPower)
-            hit = motherHit[0]
-            killed = motherHit[1]
-            if motherHit:
-                #print "hit the mothership!"
-                laserHitCenter = enviro.mother.rect.center            
-                if hit and not killed:
-                    stillShooting = True
-                    channel = pygame.mixer.find_channel(True)
-                    if channel:
-                        #print "got channel"
-                        channel.play(enviro.soundEffect[Noise.MOTHER_SHOT])
-                    else:
-                        print "no channel for mother shot sound, will try to use main"
-                        enviro.soundEffect[Noise.MOTHER_SHOT].play()  
-                    miss = False
-                elif killed: # killed him
-                    stillShooting = False
-                    #print "Laser: killed mother!"
-
-                    # Too simple, we might have all channels tied up so no sound:
-                    #enviro.soundEffect[Noise.FIGHTER_KILLED].play()
-                    # Instead we'll try finding a channel, and force kill on the longest playing if required:
-                    channel = pygame.mixer.find_channel(True)
-                    if channel:
-                        #print "got channel"
-                        channel.play(enviro.soundEffect[Noise.MOTHER_HIT])
-                    else:
-                        print "no channel for mother kill sound, will try to use main"
-                        enviro.soundEffect[Noise.MOTHER_HIT].play()
-                    miss = False
-
-        # target a fighter
-        if miss and not autoTargeting:
-            fighters = enviro.mother.getFighterFleet()
-            for fighter in fighters:
-                fighterHit = fighter.test(target, "hit", self.laserPower)
-                hit = fighterHit[0]
-                killed = fighterHit[1]
-                laserHitCenter = fighter.rect.center            
-                if hit and not killed:
-                    stillShooting = True
-                    channel = pygame.mixer.find_channel(True)
-                    if channel:
-                        #print "got channel"
-                        channel.play(enviro.soundEffect[Noise.FIGHTER_HIT])
-                    else:
-                        print "no channel for fighter shot sound, will try to use main"
-                        enviro.soundEffect[Noise.FIGHTER_HIT].play() 
-                    miss = False
-                    break                
-                elif killed: # killed him
-                    enviro.mother.notifyDeadFighter(fighter)
-                    stillShooting = False
-                    #print "Laser: killed fighter!"
-
-                    # Too simple, we might have all channels tied up so no sound:
-                    #enviro.soundEffect[Noise.FIGHTER_KILLED].play()
-                    # Instead we'll try finding a channel, and force kill on the longest playing if required:
-                    channel = pygame.mixer.find_channel(True)
-                    if channel:
-                        #print "got channel"
-                        channel.play(enviro.soundEffect[Noise.FIGHTER_KILLED])
-                    else:
-                        print "no channel for fighter kill sound, will try to use main"
-                        enviro.soundEffect[Noise.FIGHTER_KILLED].play()
-                    miss = False
-                    break        
-        
-        
-        # target a bomb
-        if miss:
-            shootingBomb = True
-            targetHit = False
-            if len(bombList) > 0:
-                for bomb in bombList:
-                    targetHit = bomb.test(target, "hit")
-                    if targetHit:
-                        laserHitCenter = bomb.rect.center
-                        stillShooting = False
-                        #enviro.soundEffect[Noise.BOMB_HIT].play()
-                        channel = pygame.mixer.find_channel(True)
-                        if channel:
-                            #print "got channel"
-                            channel.play(enviro.soundEffect[Noise.BOMB_HIT])
-                        else:
-                            print "no channel for mother kill sound, will try to use main"
-                            enviro.soundEffect[Noise.BOMB_HIT].play()                         
-                        
-                        
-                        miss = False
-                        break
-                
-        if miss:
-            channel = pygame.mixer.find_channel(True)
-            if channel:
-                #print "got channel"
-                channel.play(enviro.soundEffect[Noise.LASER_MISS])
-            else:
-                print "no channel for mother kill sound, will try to use main"
-                enviro.soundEffect[Noise.LASER_MISS].play()            
-            
-            
-            #enviro.soundEffect[Noise.LASER_MISS].play()
-            laserHitCenter = cursor
-        
-        #print "Laser shot to", laserHitCenter
-        if shootingBomb:
-            pygame.draw.lines(enviro.screen, [255,0,0], False, [[683,448],laserHitCenter], 1)
-        else:
-            pygame.draw.lines(enviro.screen, [0,255,0], False, [[683,448],laserHitCenter], 3)
-        return stillShooting  
-    
-if __name__ == '__main__':
-    
-    print "TEST: laser"
-    pygame.init()
-    enviro.screen = pygame.display.set_mode([800,600])
-    myClock = pygame.time.Clock()
-    
-# stuff needed for init:
-
-    for i in range(0,11):
-        fuelFile = "fuelStore" + str(i) + ".png"
-        fuelState = FuelStuff(fuelFile)
-        enviro.fuelPile.append(fuelState)
-        
-    laserFile = "laser.png"
-
-
-    l = Laser(laserFile)
-    l.paint([640,450], enviro.fuelPile)  
-    
-
-            
-    while True:
-    
-        for event in pygame.event.get():
-            if event.type == pygame.QUIT:
-                sys.exit()
-        if (event.type == pygame.KEYDOWN):
-            if (pygame.key.get_mods() == 1024): # command key
-                if (event.key == 113):   # q
-                    sys.exit()
-            if event.key == pygame.K_SPACE:                    
-                l.upgrade()
-
-                   
-                    
-        myClock.tick(30)
-        pygame.display.flip()       
-          

MotherShip.py

-# coding=UTF8
-# Copyright © 2010 Rob Leachman
-# Please see the file COPYING in this distribution for license information
-import pygame, random
-from pygame.color import THECOLORS
-import sys    # for testing
-from pygame.locals import *
-
-import enviro # my global game environment
-import Noise
-from FloatingSprite import FloatingSprite
-from AttackerStuff import *
-from DeadFighter import DeadFighter
-from Third_Party_Sources import gradients
-
-from Source import Bomb
-
-class MotherShip(pygame.sprite.Sprite):
-    def __init__(self, image_file, fighterFleet, bomb_image):
-        
-        pygame.sprite.Sprite.__init__(self)
-        self.theImage = image_file
-        self.image = pygame.image.load(self.theImage)
-        self.rect = self.image.get_rect()
-        
-        self.fighterFleet = fighterFleet
-        self.buildCount = 0
-        self.activeFighters = 0
-        
-        self.state = "Waiting"
-        self.waitCount = enviro.MOTHER_START_WAIT #200 good for prod?
-        self.rect.left = enviro.MOTHER_START_POSITION #810 good for prod, off the screen
-        self.rect.top = 0
-        self.diedAt = 0 # when she dies we'll stash the spot here...
-        
-        self.bomb_img_file = bomb_image
-        
-        self.fullHealth = 300
-        self.life = self.fullHealth
-        
-        self.fasterNextTime = 300
-        
-        self.deadFighterList = []
-        self.enterNoiseCounter = 0
-        
-    def test(self, targetSprite, nextState, laserPower):
-        # given a bomb and the shield object, see if we hit the shield
-
-        hitMe = False
-        killedMe = False
-        tester = pygame.sprite.Group()
-        tester.add(targetSprite)
-        if pygame.sprite.spritecollideany(self, tester):
-            #print "MOTHER HIT!"
-            hitMe = True
-            self.life = self.life - laserPower
-            if self.life < -1:
-               self.state = nextState
-               killedMe = True
-        return [hitMe, killedMe]        
-        
-    def getFleetSize(self):
-        return len(self.fighterFleet)
-    
-    def getFighterFleet(self):
-        """ Get a list of active fighters"""
-        
-        myFleet = []
-        for i in range (0,self.activeFighters):
-            if not self.fighterFleet[i].state == "hit":
-                myFleet.append(self.fighterFleet[i])
-            
-        return myFleet
-    
-    def notifyDeadFighter(self,fighter):
-        fighterDeathFileName = "deadFighter10PxA-"
-        anotherDead = DeadFighter(fighterDeathFileName)        
-        
-        #anotherDead = enviro.deadFighterModel
-        anotherDead.setLocation(fighter.rect.left, fighter.rect.top)
-        """ One of the active fighters is dead! """
-        self.deadFighterList.append(anotherDead)
-        
-    def paint(self, bombList, fighterCount):
-        
-        self.life = self.life + 1
-        if self.life > self.fullHealth:
-            self.life = self.fullHealth
-        
-        dramaState = 0 # 0=nothing, 1=shield is hit
-        
-##        for deadFighter in self.deadFighterList:
-##            print deadFighter
-##            if deadFighter.paint():
-##                print "done"            
-##        print
-        for i in range (len(self.deadFighterList)-1, -1, -1):
-            #print i
-            #print self.deadFighterList[i]
-            if self.deadFighterList[i].paint():
-                #pass
-                del self.deadFighterList[i]
-        #print "Dead list len=", len(self.deadFighterList)
-
-        #if self.state == "Fighting" or self.state == "Hit":
-        if True:
-            #print "Bombs=", len(bombList)
-            for bomb in bombList:
-                if bomb.state == "caught":
-                    #print "caught bomb launched from ", bomb.fromFighter
-                    self.fighterFleet[bomb.fromFighter].shotExpired()
-
-                    dramaState = 1
-                    bombList.remove(bomb)
-                elif bomb.state == "hit":
-                    bomb.paint()
-                    bomb.explode()
-                elif bomb.state == "dead":
-                    #print "Dead bomb from fighter", bomb.fromFighter
-                    #self.fighterFleet[bomb.fromFighter].state = "shoot"
-                    self.fighterFleet[bomb.fromFighter].shotExpired()
-                    bombList.remove(bomb)
-                    
-            for i in range (0,self.activeFighters):
-                #print self.fighterFleet[i]
-                if self.fighterFleet[i].state == "launching":
-                    if self.fighterFleet[i].move() == 0:
-                        self.fighterFleet[i].state = "shoot"
-                if self.fighterFleet[i].state == "shoot" or self.fighterFleet[i].state == "shooting":
-                    if self.fighterFleet[i].takeAShot():
-                        randX = random.randint(1,80) - 40
-                        bomb = Bomb(self.bomb_img_file,self.fighterFleet[i].trueLeft+6,self.fighterFleet[i].trueTop+8,
-                           self.fighterFleet[i].trueLeft+6 + randX-5,430, i)
-                        bombList.add(bomb)
-                if self.fighterFleet[i].state == "shoot" or self.fighterFleet[i].state == "shooting":
-                    self.fighterFleet[i].paint()
-                if self.fighterFleet[i].state <> "hit":
-                    self.fighterFleet[i].smokeCheck()
-                    
-        if self.state == "Fighting":
-            if self.buildCount > 0 and enviro.test == 1:
-                pygame.draw.lines(enviro.screen, [255,255,255], False, [[400,0],[400+self.buildCount,0]], 1)
-            fighterNeedsRebuild = False                    
-            for i in range(0, self.activeFighters):
-                if self.fighterFleet[i].state == "hit":
-                    fighterNeedsRebuild = True
-                    break
-            if fighterNeedsRebuild or self.activeFighters < fighterCount:
-                self.buildCount = self.buildCount + 1
-                if self.buildCount > enviro.MOTHER_BUILD_SPEED:
-                    self.buildCount = 0
-                    builtFighter = False
-                    for i in range(0, self.activeFighters):
-                        if self.fighterFleet[i].state == "hit":
-                            self.fighterFleet[i].bewareILive(-1)
-                            #print "revived fighter!"
-                            self.fighterFleet[i].paint()
-                            builtFighter = True
-                            break
-                    if not builtFighter:
-                        self.activeFighters = self.activeFighters + 1
-                        #print "now there are ",self.activeFighters, "fighters"
-                        self.fighterFleet[self.activeFighters-1].paint()
-                        
-        if self.state == "Waiting":
-            self.waitCount = self.waitCount - 1
-            if self.waitCount == 0:
-                self.state = "Approaching"
-                
-        if self.state == "Approaching":
-            #print "centertest", self.rect.center
-            if self.rect.left > 530:
-                pygame.draw.rect(enviro.screen, THECOLORS["black"], [self.rect.left,self.rect.top,60,20], 0)
-                self.rect.left = self.rect.left - 3
-                if self.rect.left % 10 == 0 and self.rect.left > 580:
-                    channel = pygame.mixer.find_channel(True)
-                    if channel:
-                        #print "got channel"
-                        channel.play(enviro.soundEffect[Noise.MOTHER_ENTERS])
-                    else:
-                        print "no channel for mother kill sound, will try to use main"
-                        enviro.soundEffect[Noise.MOTHER_HIT].play()                
-            else:
-                self.state = "Ready"
-                
-        if self.state == "Ready":
-            if self.activeFighters == 0:
-                self.activeFighters = 1
-            #self.fighterFleet[0].paint() # paint the new fighter
-            self.state = "Fighting"
-       
-        if self.state <> "Hit" and self.state <> "Waiting":    
-           enviro.screen.blit(self.image, self.rect)
-           self.paintHealthMeter()
-        else:
-            pygame.draw.rect(enviro.screen, [0,0,0], [740,126,30,300], 0) 
-            
-        if self.state == "Hit":
-            self.state = "Waiting"
-            self.waitCount = enviro.MOTHER_RESTART_WAIT - self.fasterNextTime
-            if self.waitCount < 0:
-                self.waitCount = enviro.MOTHER_MIN_RESTART
-            self.fasterNextTime = self.fasterNextTime + 100
-            self.buildCount = 0
-            self.diedAt = self.rect.left
-            self.rect.left = enviro.MOTHER_START_POSITION
-            self.fullHealth = self.fullHealth + enviro.MOTHER_LIFEGAIN_PER_LEVEL
-            enviro.MOTHER_BUILD_SPEED = enviro.MOTHER_BUILD_SPEED - 150
-            if enviro.MOTHER_BUILD_SPEED < 200:
-                enviro.MOTHER_BUILD_SPEED = 200
-            
-        
-            self.life = self.fullHealth
-            
-        return [bombList, dramaState, self.state]
-        
-                         
-    def paintHealthMeter(self):
-        pygame.draw.rect(enviro.screen, [128,128,128], [740,126,30,300], 0)
-        if self.life > 0:
-            
-            #paintLifeBar = self.life
-            paintLifeBar = (float(self.life) / self.fullHealth) * 296
-            #paintLifeTop = 296-self.life
-            paintLifeTop = 296 - paintLifeBar
-            
-            #pygame.draw.rect(enviro.screen, [255,255,255], [742,128+paintLifeTop,26,paintLifeBar], 0)
-            enviro.screen.blit(gradients.vertical_func((26,int(paintLifeBar)),(255,255,255),(255,0,0)), (742,128+paintLifeTop))
-
-        
-if __name__ == '__main__':
-    
-    print "TEST: mothership"
-    pygame.init()
-    enviro.screen = pygame.display.set_mode([800,600])
-    myClock = pygame.time.Clock()
-    
-# stuff needed for init: 
-    enviro.soundEffect = []
-    enviro.soundEffect.append(Noise.load_sound('63068__radian__odd_trimmedAndReworked.wav'))
-    Noise.MOTHER_ENTERS = len(enviro.soundEffect) - 1 
-
-    dramaBackground = pygame.image.load("dramaBackground.png")   
-    fighterFile = "fighter.png"
-
-    fighterFleet = []
-
-    for i in range(0,9):
-        fighter = Fighter(fighterFile, len(fighterFleet))
-        fighterFleet.append(fighter)
-
-    motherShipFile = "mother.png"
-    bomb_image = "bomb.png"
-    
-    enviro.MOTHER_START_WAIT = 10
-
-    m = MotherShip(motherShipFile, fighterFleet, bomb_image)
-    
-    bombList = pygame.sprite.Group()
-    fightersActive = 1
-    
-    while True:
-    
-        for event in pygame.event.get():
-            if event.type == pygame.QUIT:
-                sys.exit()
-        if (event.type == pygame.KEYDOWN):
-            if (pygame.key.get_mods() == 1024): # command key
-                if (event.key == 113):   # q
-                    sys.exit()
-            if event.key == pygame.K_SPACE:                    
-                m.life = m.life - 10
-                    
-        enviro.screen.blit(dramaBackground, [400,0,330,449])                    
-                    
-        theMother = m.paint(bombList, fightersActive) # paint her progress, and get any emitted bombs  
-        
-        myClock.tick(30)
-        pygame.display.flip()                           
-        

Noise.py

-# coding=UTF8
-# Copyright © 2010 Rob Leachman
-# Please see the file COPYING in this distribution for license information
-# Gotta love noise!
-# I used music and sound code from http://www.pygame.org/project-Arcade+Tonk+Tanks-1078-2412.html
-
-# missioneers2? 4 is better
-
-
-import pygame
-import os.path
-
-import enviro # my global game environment
-
-SHIELD_HIT = 0
-BOMB_HIT = 0
-LASER_MISS = 0
-
-class dummysound:
-    # good idea but seems hopeless... so it must not fail!
-    def play(self): pass
-    def set_volume(self, volume): pass
-
-def load_sound(file):
-    #print 'Loading sounds...can I get the mixer?'
-    if not pygame.mixer: return dummysound()
-    file = os.path.join('Sound', file)
-    try:
-        testFile = open(file, "r")
-        sound = pygame.mixer.Sound(file)
-        #print 'Sound loaded'
-        return sound
-    except pygame.error:
-        print 'Warning, unable to load sound', file
-    except IOError:
-        print 'Warning, IO error loading sound', file
-    return dummysound()
-
-def initMixer():
-    if pygame.mixer and not pygame.mixer.get_init():
-        print 'WARNING: sound init failed!'
-        pygame.mixer = None
-
-def playMusic(file):
-    if pygame.mixer:
-        music = os.path.join('Sound', file)
-        
-        pygame.mixer.music.load(music)
-        # The old way, was pretty good but now it's a lot better
-        #pygame.mixer.music.set_volume(enviro.musicLevel[1])
-        #pygame.mixer.music.set_volume(enviro.musicLevel[enviro.musicVolume])
-        #pygame.mixer.music.set_volume(enviro.musicVolumeController.setting/100.0) 
-        pygame.mixer.music.play(-1)
-    
-class Volume(pygame.sprite.Sprite):
-    def __init__(self, theScreen, location=[0,0], size=[100,20], init=50):
-        
-        self.screenSurface = theScreen
-        pygame.sprite.Sprite.__init__(self)
-        image_surface = pygame.surface.Surface([10,size[1]*.8])
-        image_surface.fill([255,255,255])
-        self.image = image_surface.convert()
-        self.rect = self.image.get_rect()
-        self.controlLocation = location
-        self.controlSize = size
-        
-        self.setting = init
-        
-        self.mousePosition = [0,0]
-        
-    def paintControl(self):
-        left = self.controlLocation[0]
-        top = self.controlLocation[1]
-        width = self.controlSize[0]
-        height = self.controlSize[1]
-        
-        pygame.draw.rect(self.screenSurface, [100,100,100], [left-5,top,width+10,height])
-        
-        lineInMiddle = top+height/2
-        pygame.draw.lines(self.screenSurface, [200,200,200], False, [[left,lineInMiddle],[left+width,lineInMiddle]], 1)
-        for i in range(0,6):
-            if i == 0 or i == 5:
-                markTop = top+2
-                markBot = top + height -4
-            else:
-                markTop = lineInMiddle - self.controlSize[1]*.2
-                markBot = lineInMiddle + self.controlSize[1]*.2
-            pygame.draw.lines(self.screenSurface, [200,200,200], False, [[left+i*(width/5),markTop],[left+i*(width/5),markBot]], 1)
-        offset = (self.setting/100.0)*width
-        self.rect.centery = lineInMiddle 
-        self.rect.centerx = left+offset
-        self.screenSurface.blit(self.image, self.rect)
-        
-    def mouseOnControl(self,mousePos):
-        left = self.rect.left
-        top = self.rect.top
-        width = 10
-        height = self.controlSize[1]*.8
-        
-        if (mousePos[0] > left and 
-           mousePos[0] < left+width and 
-           mousePos[1] > top and 
-           mousePos[1] < top+height):
-            self.mousePosition = mousePos
-            return True
-        return False
-    
-    def setLevel(self,mousePos):
-        self.setting += (mousePos[0] - self.mousePosition[0])/2
-        if self.setting < 0:
-            self.setting = 0
-        if self.setting > 100:
-            self.setting = 100
-        self.mousePosition = mousePos
-        
-    def setLevelByClick(self, mousePos):
-        left = self.controlLocation[0]
-        top = self.controlLocation[1]
-        width = self.controlSize[0]
-        height = self.controlSize[1]
-                
-        if (mousePos[0] > left and 
-           mousePos[0] < left+width and 
-           mousePos[1] > top and 
-           mousePos[1] < top+height):
-             
-            if mousePos[0] < self.rect.centerx:
-                self.setting -= 20
-            else:
-                self.setting += 20
-            self.setting = int(round(self.setting / 20.0) * 20)
-                
-            
-            if self.setting < 0:
-                self.setting = 0
-            if self.setting > 100:
-                self.setting = 100
-            return True
-        return False
-        
-    
-        
-if __name__ == '__main__':
-    
-    pygame.init()
-    enviro.screen = pygame.display.set_mode([800,600])
-    myClock = pygame.time.Clock()
-    
-    delay=100
-    interval=50
-    pygame.key.set_repeat(delay,interval)
-    
-    v = Volume(enviro.screen,location=[300,250], size=[250,40], init=100)
-    v.paintControl()
-    
-# stuff needed for init:
-            
-    heldDown = False
-    
-    playMusic('Allmyownworkv2.mp3')
-    pygame.mixer.music.set_volume(1) 
-    
-    
-    while True:
-        
-        for event in pygame.event.get():
-            if event.type == pygame.QUIT:
-                sys.exit()
-            elif event.type == pygame.MOUSEMOTION:
-                mousePos = event.pos
-                if heldDown:
-                    v.setLevel(mousePos)
-                    print v.setting
-                    pygame.mixer.music.set_volume(v.setting/100.0)
-            elif event.type == pygame.MOUSEBUTTONDOWN:
-                heldDown = v.mouseOnControl(mousePos)
-            elif event.type == pygame.MOUSEBUTTONUP:
-                if heldDown == False:
-                    v.setLevelByClick(mousePos)
-                    print v.setting
-                    pygame.mixer.music.set_volume(v.setting/100.0)
-                heldDown = False
-
-            elif (event.type == pygame.KEYDOWN):
-                if (pygame.key.get_mods() == 1024): # command key
-                    if (event.key == 113):   # q
-                        sys.exit()
-                        
-                if event.key == pygame.K_SPACE:
-                    print "Generate!"
-                   
-        v.paintControl()        
-        
-        myClock.tick(30)
-        pygame.display.flip()               

Shields.py

-# coding=UTF8
-# Copyright © 2010 Rob Leachman
-# Please see the file COPYING in this distribution for license information
-import pygame, random
-from pygame.color import THECOLORS
-import sys    # for testing
-from pygame.locals import *
-
-import enviro # my global game environment
-import Noise
-from FloatingSprite import FloatingSprite
-from AttackerStuff import *
-from YourStuff import FuelStuff # for testing
-
-
-class Shields(pygame.sprite.Sprite):
-    def __init__(self, image_file, increasing_file, initFuelBays):
-        pygame.sprite.Sprite.__init__(self)
-        self.theImage = image_file
-        self.image = pygame.image.load(self.theImage)
-        self.rect = self.image.get_rect()
-        self.location = 10
-        
-        self.increasingImage = pygame.image.load(increasing_file)
-        
-##        self.shieldBlue = []
-##        self.shieldRed = []
-##        self.shieldMaxRed = []
-##
-##        for i in range(0, 10):
-##            self.shieldBlue.append(0)
-##            self.shieldRed.append(0)
-##            self.shieldMaxRed.append(i*(150/15))
-            
-        #self.fuelBaysAvailable = 1  # great idea for upgrade potential!
-        self.fuelBay = initFuelBays
-        self.fuelPerPellet = enviro.FUEL_PER_PELLET
-
-        self.promises = 0
-        
-        #self.consuming = self.fuelPerPellet
-        self.consuming = 0
-        self.consumingBay = 0
-        
-        self.upgrades = enviro.shieldUpgrades
-                
-        self.initUpgrades()
-        self.cooldown = self.cooldown_period
-        self.poweringUp = 0
-        self.needHum = True
-        
-    def initUpgrades(self):
-        self.shieldBlue = []
-        self.shieldRed = []
-        self.shieldMaxRed = []
-
-        for i in range(0, 10):
-            self.shieldBlue.append(0)
-            self.shieldRed.append(0)
-            self.shieldMaxRed.append(i*(150/15))        
-        
-        self.cooldown_period = enviro.SHIELD_COOLDOWN
-        for i in range (0,self.upgrades):
-            self.applyUpgrade() 
-        
-        
-    def paintPad(self):
-        pass        
-
-    def upgrade(self):
-        if self.upgrades < 11:
-            self.upgrades = self.upgrades + 1
-            enviro.shieldUpgrades = self.upgrades
-            self.repaint()
-            self.applyUpgrade()
-            return True
-        return False
-    
-    def applyUpgrade(self):
-        self.cooldown_period = self.cooldown_period - 10
-        if self.cooldown_period < 0:
-            self.cooldown_period == 0
-        enviro.BOMB_POWER = enviro.BOMB_POWER - 40
-        if enviro.BOMB_POWER < 100:
-            enviro.BOMB_POWER = 100 
-        #print "cooldown period=", self.cooldown_period
-        #print "bomb power", enviro.BOMB_POWER
-        
-    def paint(self, location, fuelPile):
-        self.fuelPile = fuelPile
-        self.rect.left = location[0]
-        self.rect.top = location[1]
-        
-        enviro.screen.blit(self.image, self.rect)
-        
-        self.fuelPile[self.fuelBay[1]].paint([525,494])
-        self.fuelPile[self.fuelBay[0]].paint([552,494])
-        self.fuelPile[self.fuelBay[2]].paint([579,494])
-        
-        left = self.rect.left
-        top = self.rect.top        
-        
-        pygame.draw.rect(enviro.screen, THECOLORS["blue"], [left+4,top+71,80,9], 0)
-        for i in range(0, self.upgrades):
-            pygame.draw.rect(enviro.screen, [130,202,253], [left+6+i*7,top+73,5,5], 0)        
-        
-        
-    def repaint(self):
-        enviro.screen.blit(self.image, self.rect)
-        
-        self.fuelPile[self.fuelBay[1]].paint([525,494])
-        self.fuelPile[self.fuelBay[0]].paint([552,494])
-        self.fuelPile[self.fuelBay[2]].paint([579,494])
-        
-        left = self.rect.left
-        top = self.rect.top        
-        
-        pygame.draw.rect(enviro.screen, THECOLORS["blue"], [left+4,top+71,80,9], 0)
-        for i in range(0, self.upgrades):
-            pygame.draw.rect(enviro.screen, [130,202,253], [left+6+i*7,top+73,5,5], 0)        
-        
-
-    def hitShield(self, power):
-        for i in range(0,10):
-            self.shieldRed[i] = 0
-            self.shieldBlue[i] = 0        
-        color = power
-        shieldBar = 9
-        while color > 215:
-            self.shieldBlue[shieldBar] = 215
-            color = color - 215
-            shieldBar = shieldBar - 1
-        if shieldBar > -1:
-            self.shieldBlue[shieldBar] = color
-            
-
-    # Paint the shield on the screen, and produce a sprite as big as it is
-    def paintShield(self, power):
-        color=power
-        shieldBar = 9
-        for i in range(0,10):
-            self.shieldRed[i] = 0
-        #print "painting shields with power=",power
-        while color > 215:
-            self.shieldBlue[shieldBar] = 215
-            shieldBar = shieldBar - 1
-            for j in range (shieldBar+1,10):
-                self.shieldRed[j] = self.shieldRed[j] + 15
-                if self.shieldRed[j] > self.shieldMaxRed[j]:
-                   self.shieldRed[j] = self.shieldMaxRed[j]
-            if shieldBar == -1:
-                color = 215
-                #print "Max shields =",power
-                break
-            color = color - 215
-        if shieldBar > -1:
-            self.shieldBlue[shieldBar] = color
-    
-        shim = 0
-        shieldHeight = 0
-        shieldTop = 999
-        for i in range(9,-1,-1):
-            shim = 9-i+shim+4
-            if self.shieldBlue[i]>0:
-                shieldHeight = shieldHeight + (i+3)
-                if shieldTop > (275+i*15)+shim:
-                    shieldTop = (275+i*15)+shim
-            if self.shieldBlue[i] > 0:
-                pygame.draw.rect(enviro.screen, [self.shieldRed[i],0,self.shieldBlue[i]+40], 
-                   [400,(275+i*15)+shim,330,i+3],0)
-        #print "Power:", power, "Shield top:",shieldTop,"height:", shieldHeight
-        if power == 2050:
-            pygame.draw.lines(enviro.screen, [200,200,200], False, [ [400,359], [729,359] ], 1)
-            
-        shieldSprite = ShieldSprite(self.theImage, 400,shieldTop, 330, shieldHeight)
-        #shieldSprite.paint()
-        return shieldSprite
-        
-    def powerUp(self, power, fuelPile):
-        pygame.draw.rect(enviro.screen, [0,0,0], [530,425,68,28], 0) # clear the powerup indicator
-        if self.consuming > 0:
-            if power < enviro.SHIELD_MAX:
-                enviro.screen.blit(self.increasingImage, [530,420])
-                
-                if self.needHum:
-                    #self.powerUpAnimationLine = 420
-                    self.powerUpAnimationLine = 9
-                    self.needHum = False
-                    #print "Play the hum"
-                    channel = pygame.mixer.find_channel(True)
-                    if channel:
-                        #print "got channel"
-                        channel.play(enviro.soundEffect[Noise.SHIELD_HUM])
-                    else:
-                        print "no channel for shield hum sound, will try to use main"
-                        enviro.soundEffect[Noise.SHIELD_HUM].play()
-                # Dr. Bart had me add this cool animation... not bad!
-                self.powerUpAnimationLine -= 1
-                if self.powerUpAnimationLine < 0:
-                    self.powerUpAnimationLine = 9
-                
-                for i in range(self.powerUpAnimationLine, 27,10):
-                     pygame.draw.lines(enviro.screen, [0,0,0], False, [[530,self.powerUpAnimationLine+i+420],[601,self.powerUpAnimationLine+i+420]], 3)
-                
-                power = power + enviro.SHIELD_POWER_PER_CYCLE
-                if power > enviro.SHIELD_MAX:
-                    power = enviro.SHIELD_MAX
-                self.consuming = self.consuming - 1
-            
-        if self.consuming == 0 and power < enviro.SHIELD_MAX + 1:
-            if self.cooldown > 0:
-                self.cooldown = self.cooldown - 1
-            else:
-                
-#                self.poweringUp = self.poweringUp + 1
-#                if self.poweringUp > enviro.SHIELD_INCREASE_PER_CYCLE:
-                self.cooldown = self.cooldown_period
-                self.needHum = True
-#                   self.poweringUp = 0
-            
-            
-                if self.fuelBay[self.consumingBay] > 0:
-                   self.consuming = self.fuelPerPellet
-                   self.fuelBay[self.consumingBay] = self.fuelBay[self.consumingBay] - 1
-                   self.repaint()
-                else:
-                    for i in range(0,3):
-                        if self.fuelBay[i] > 0:
-                            self.consumingBay = i
-
-        return power
-    
-    def loadFuel(self):
-        loadBay = -1
-        for i in range(0,3):
-            if self.fuelBay[i] == 0:
-                loadBay = i
-        if loadBay > -1:
-            self.fuelBay[loadBay] = 10
-            self.promises = self.promises - 1
-            self.repaint()
-            return True
-        return False
-
-    def unloadStuff(self):
-
-        for i in range(0,3):
-            if self.fuelBay[i] == 10:
-                self.fuelBay[i] = 0
-                self.repaint()
-                return True
-        return False    
-    
-    
-    def promiseRefuel(self):
-        self.promises = self.promises + 1
-
-    # See if we need more fuel for shields
-    def needFuel(self):
-        emptyBays = 0
-        for i in range(0,3):
-            if self.fuelBay[i] == 0:
-                emptyBays += 1
-        if emptyBays > self.promises:
-            return True
-        return False
-    
-    def nearlyEmpty(self):
-        if enviro.laserRefuelDisabled:
-            return False
-        
-        emptyBays = 0
-        for i in range(0,3):
-            if self.fuelBay[i] == 0:
-                emptyBays += 1
-        if emptyBays < 2:
-            return False
-        if emptyBays > self.promises: