示例#1
0
    def drawDialogueBox(self, displaySurface):

        # Draw main Background rectangle
        displaySurface.draw.fill(g.GREY,
                                 (int((g.height / 200) * self.position[0]),
                                  int((g.width / 320) * self.position[1]),
                                  int((g.height / 200) * self.height),
                                  int((g.width / 320) * self.width)))

        # Draw Highlight rim
        pygame.draw.rect(displaySurface,
                         (g.GREY[0] - 20, g.GREY[1] - 20, g.GREY[2] - 20),
                         (int((g.height / 200) * self.position[0]),
                          int((g.width / 320) * self.position[1]),
                          int((g.height / 200) * self.height),
                          int((g.width / 320) * self.width)), 1)

        # Draw OK button Highlight Rim.  We use an optical illusion here.
        pygame.draw.rect(displaySurface,
                         (g.GREY[0] - 20, g.GREY[1] - 20, g.GREY[2] - 20),
                         (int((g.height / 200) *
                              (self.position[0] + self.okButton.position[0])),
                          int((g.width / 320) *
                              (self.position[1] + self.okButton.position[1])),
                          int((g.height / 200) * self.okButton.height),
                          int((g.width / 320) * self.okButton.width)), 1)

        # Draw OK text.
        h.renderText(["OK"], g.font, displaySurface, g.BLACK, 0,
                     int((g.width / 320) *
                         (self.position[1] + self.okButton.position[1])),
                     int((g.height / 200) *
                         (self.position[0] + self.okButton.position[0])))
示例#2
0
    def main_loop(self):

        # Display copyright credits on start.
        self.displaySurface.fill(g.BLACK)
        h.renderText(self.creditText, g.font, self.displaySurface, g.WHITE, g.offset)
        pygame.display.update()

        # wait some seconds, approx 4.
        pygame.time.wait(4000)

        # enter main state and logic loop.
        while 1:
            
            for evt in pygame.event.get():
                
                if evt.type == pygame.QUIT:
                    
                    pygame.quit()
                    sys.exit()
                    
                # Handle mouse input.
                elif evt.type == pygame.MOUSEBUTTONDOWN:
                    
                    self.state = self.interactive[self.state](evt.button)
                    
            g.gameDate.update()  #  Update game time in "realtime"
            self.state = self.states[self.state](self.displaySurface)
            # self.state(self.displaySurface)
            pygame.display.update()
示例#3
0
 def planetTextGenerate(self, text, planet, starfield, surface, height,
                        width, step):
     finished = False
     surface.fill(g.BLACK)  #  Blank surface, as starfield = transparent.
     surface.blit(starfield, (0,0))
     lowerThird = int(3*(height/4))
     centerWidth = int(3*(width/6))
     #  Render planet here.
     readyPlanet = pygame.Surface((g.planetWidth, g.planetHeight), 0)
     readyPlanet.set_colorkey(g.BLACK)
     terrainStart = step % (g.planetWidth+1)
     actualPlanet = planets.Planets[planet].planetBitmapToSphere(readyPlanet, terrainStart, eclipse = True)
     surface.blit(readyPlanet,(int(g.width/16),int(g.height/8)))
     #surface.blit(actualPlanet,(200,200))
     #finished = True #  W00T!
     
     h.renderText(text,g.font,surface,g.WHITE,
                  g.offset,centerWidth,lowerThird,True)
     """
     if h.fadeIn(width, height, surface, step):
         #finished = True
         #print("We Drew: " )
         surface.blit(planets.Planets[planet].planetTexture,(0,0))
     """
     h.fadeIn(width, height, surface, step)
     
     if self.stopwatch.stopwatchSet:
         
         if self.stopwatch.getElapsedStopwatch() > 15:
             
             self.stopwatch.resetStopwatch()
             finished = True
     else:
         
         self.stopwatch.setStopwatch()
         
     # uncomment to look at planet 2D texture.
     #surface.blit(planets.Planets[planet].planetTexture,(0,0))
     return finished
示例#4
0
 def drawCrew(self, displaySurface):
     
     crewType = "Stowaway"  #  This should not happen!
     
     if self.crewSelectStage == 1:
         
         crewType = "Psychometry"
         
     elif self.crewSelectStage == 2:
         
         crewType = "Engineering"
         
     elif self.crewSelectStage == 3:
         
         crewType = "Science"
         
     elif self.crewSelectStage == 4:
         
         crewType = "Security"
         
     elif self.crewSelectStage == 5:
         
         crewType = "Astrogation"
         
     elif self.crewSelectStage == 6:
         
         crewType = "Medical"
         
     else:
         
         pass
     
     displaySurface.fill(g.BLACK)
     
     #  Print what we are doing.
     h.renderText(["Crew Selection", crewType], g.font, displaySurface, g.WHITE, 15, (g.width/320)*179, (g.height/200)*99, True)
     
     #  Render the array containing the ship stat info.
     
     #  Name of Potential Crewmember.
     h.renderText([crew.CrewData[self.crewArray].name], g.font, displaySurface, g.WHITE, 0, (g.width/320)*3, (g.height/200)*120)
     
     #  Render Bio column of text.
     h.renderText(crew.CrewData[self.crewArray].bio, g.font, displaySurface, g.WHITE, 15, (g.width/320)*3, (g.height/200)*135)
     
     displaySurface.blit(self.crewSelectorScaled, (0, 0))        
     
     #  Render pulse line.
     #self.drawStatusLine(displaySurface, crew.CrewData[self.crewArray])
     crew.CrewData[self.crewArray].drawStatusLine(displaySurface, self.pulseDisplayArea)
     
     #  Render crewmember image.
     displaySurface.blit(crew.CrewData[self.crewArray].resizedImage, ((g.width/320)*13, (g.height/200)*7))
示例#5
0
    def drawShip(self, displaySurface):

        shipFront = self.frontHeavyScaled
        shipCenter = self.centerShuttleScaled
        shipRear = self.rearTransportScaled

        if self.currentShip.frontHull == 1:

            shipFront = self.frontHeavyScaled

        elif self.currentShip.frontHull == 2:

            shipFront = self.frontLightScaled

        elif self.currentShip.frontHull == 3:

            shipFront = self.frontStrategicScaled
        else:
            pass

        if self.currentShip.centerHull == 1:

            shipCenter = self.centerShuttleScaled

        elif self.currentShip.centerHull == 2:

            shipCenter = self.centerAssaultScaled

        elif self.currentShip.centerHull == 3:

            shipCenter = self.centerStormScaled
        else:
            pass

        if self.currentShip.rearHull == 1:

            shipRear = self.rearTransportScaled

        elif self.currentShip.rearHull == 2:

            shipRear = self.rearFrigateScaled

        elif self.currentShip.rearHull == 3:

            shipRear = self.rearCruiserScaled
        else:
            pass

        # 119, 99 - Text 0,0 position.

        displaySurface.fill(g.BLACK)
        displaySurface.blit(shipFront,
                            ((g.width / 320) * 121, (g.height / 200) * 14))
        displaySurface.blit(shipCenter,
                            ((g.width / 320) * 179, (g.height / 200) * 14))
        displaySurface.blit(shipRear,
                            ((g.width / 320) * 237, (g.height / 200) * 14))

        #  Highlight the area of the ship being changed.
        #  This is not canon, but I accidentally made a better ship constructor.
        #  Which is what happens when you're coding something up from memory
        #  before checking the original game itself.
        if self.shipSelectStage == 1:
            rectangle = ((g.width / 320) * 121, (g.height / 200) * 14,
                         (g.width / 320) * 58, (g.height / 200) * 75)
            pygame.draw.rect(displaySurface, g.BLUE, rectangle, 1)

        elif self.shipSelectStage == 2:
            rectangle = ((g.width / 320) * 179, (g.height / 200) * 14,
                         (g.width / 320) * 58, (g.height / 200) * 75)
            pygame.draw.rect(displaySurface, g.BLUE, rectangle, 1)

        elif self.shipSelectStage == 3:
            rectangle = ((g.width / 320) * 237, (g.height / 200) * 14,
                         (g.width / 320) * 58, (g.height / 200) * 75)
            pygame.draw.rect(displaySurface, g.BLUE, rectangle, 1)

        else:
            pass
        #  Print what we are doing.
        h.renderText(["Ship Selection"], g.font, displaySurface, g.WHITE, 0,
                     (g.width / 320) * 179, (g.height / 200) * 99, True)

        #  Render the array containing the ship stat info.

        #  Ship Name/Type.
        h.renderText([self.currentShip.name], g.font, displaySurface, g.WHITE,
                     0, (g.width / 320) * 130, (g.height / 200) * 120, True)

        #  Render left column of text.
        h.renderText(self.shipStatisticsNames, g.font, displaySurface, g.WHITE,
                     20, (g.width / 320) * 3, (g.height / 200) * 140)

        #  Render right column of values.
        self.shipStatistics = [
            str(self.currentShip.gunMax),
            str(self.currentShip.maxFuel) + " KG",
            str(self.currentShip.cargoMax) + " Units",
            str(self.currentShip.mass) + " Mt",
            str(self.currentShip.acceleration) + " M/S Sqr",
            str(self.currentShip.hullMax) + " Pts"
        ]
        h.renderText(self.shipStatistics, g.font, displaySurface, g.WHITE, 20,
                     (g.width / 320) * 180, (g.height / 200) * 140)

        displaySurface.blit(self.shipCreatorScaled, (0, 0))
示例#6
0
    def ironseedCrash(self, width, height, displaySurface):
        
        displaySurface.fill(g.BLACK)
        displaySurface.blit(self.ironseedScaled, (0, 0))
        
        finished = False
        currentTimer = 0
        #  Bar reduction steps.  These appear to be no x 10 percentages.
        # -1,0,0,-2
        # -3,0,-1-1
        # -1,-1,0,0
        
        #  11, 159 - text box location.

        #  Bar bounding box parameters.
        #  (X to X), (Y to Y)  104 wide, 10 high.
        #  (186,290), (35,45) - Hull integrity bar. 100%
        
        #  (186,200), (55,65) - Primary Power.  10% ?
        
        #  (186,233), (75,85) - Auxiliary power. 40% ?
        
        #  (186,279), (95,105) - Shield Strength. 90% ?
        
        barLengths = {0:(290, 200, 233, 279), 1:(280, 200, 233, 259),
                      2:(250, 200, 223, 249), 3:(240, 190, 223, 249),
                      4:(240, 190, 223, 249), 5:(240, 190, 223, 249)}
        
        if self.crashLandingStep >= 1 and self.crashLandingStep <= 3 and self.count <= 10:
            
            tempLengths = [0,0,0,0]
            
            for index in range(0, 4):
                
                tempLength = barLengths[self.crashLandingStep-1][index] - barLengths[self.crashLandingStep][index]
                tempLength /= 10  #  Based on 100ms per second.
                tempLengths[index] = barLengths[self.crashLandingStep-1][index] - int(tempLength * self.count)
                
            barLengths[self.crashLandingStep] = (tempLengths[0], tempLengths[1],
                                                 tempLengths[2], tempLengths[3])
            
        defaultBar = h.colourLine(int((g.width/320)*110), g.BLUE)
        
        barLineHull = h.createBar(defaultBar, int((g.width/320)*(barLengths[self.crashLandingStep][0]-186)), int(g.height/200*10))
        barLinePri = h.createBar(defaultBar, int((g.width/320)*(barLengths[self.crashLandingStep][1]-186)), int(g.height/200*10))
        barLineAux = h.createBar(defaultBar, int((g.width/320)*(barLengths[self.crashLandingStep][2]-186)), int(g.height/200*10))
        barLineShld = h.createBar(defaultBar, int((g.width/320)*(barLengths[self.crashLandingStep][3]-186)), int(g.height/200*10))

        #  Render planet here.
        readyPlanet = pygame.Surface((g.planetWidth, g.planetHeight), 0)
        readyPlanet.set_colorkey(g.BLACK)
        terrainStart = self.crashLandingStep % (g.planetWidth+1)
        planets.Planets["Icarus"].planetBitmapToSphere(readyPlanet, terrainStart, eclipse = True)
        displaySurface.blit(readyPlanet,(int(g.width/16),int(g.height/8)))
        
        #  Render text and bars.
        
        if self.crashLandingStep <= 4:
            
            currentTimer = 2
            h.renderText(self.introText7[0:self.crashLandingStep], g.font,
                         displaySurface, g.WHITE, g.offset,
                         int((g.width/320)*11), int((g.height/200)*159))
            
            # Draw Bars.
            displaySurface.blit(barLineHull, (int((g.width/320)*186), int((g.height/200)*35)), None, pygame.BLEND_MULT)
            displaySurface.blit(barLinePri, (int((g.width/320)*186), int((g.height/200)*55)), None, pygame.BLEND_MULT)
            displaySurface.blit(barLineAux, (int((g.width/320)*186), int((g.height/200)*75)), None, pygame.BLEND_MULT)
            displaySurface.blit(barLineShld, (int((g.width/320)*186), int((g.height/200)*95)), None, pygame.BLEND_MULT)
            
            # TODO: These bars need to reduce in length smoothly from one value to the next.
            
        else:
            
            finished = True
        
        #  Our timer for this sequence.
        if h.GameStopwatch.stopwatchSet:
            
            if h.GameStopwatch.getElapsedStopwatch() > currentTimer:
                
                h.GameStopwatch.resetStopwatch()
                self.crashLandingStep += 1
                self.count = 0
                
        else:
            
            h.GameStopwatch.setStopwatch()
        
        return finished
示例#7
0
    def scavengersAttack(self, displaySurface, width, height, step):
        
        finished = False
        currentTimer = 0
        lowerThird = int(6*(g.height/10))
        centerWidth = int(g.width/16)*2
        displaySurface.fill(g.BLACK)  #  Reset image buffer.
                
        #  Print the Scavenger's analysis and orders.
        
        if self.scavengerStep <= 6:
            
            #  Show the ship being examined
            
            displaySurface.blit(self.shipScaled, (0, 0))
            self.bufferSurfaceImage.set_colorkey(g.RED)
            self.bufferSurfaceImage.set_colorkey(g.BLACK)
            
            if self.scavengerStep < 6:
            
                currentTimer = 3
            
            if self.scavengerStep >= 1:
                
                h.renderText([self.introText6[0]], g.font, displaySurface,
                             g.GREEN, 0, centerWidth, lowerThird)
            
            if self.scavengerStep >= 2:
                
                h.renderText([self.introText6[1]], g.font, displaySurface,
                             g.GREEN, 0, centerWidth, lowerThird+(g.offset))
                
            if self.scavengerStep >= 3:
                
                h.renderText([self.introText6[2]], g.font, displaySurface,
                             g.GREEN, 0, centerWidth, lowerThird+(g.offset*2))
            
            if self.scavengerStep >= 4:
                
                h.renderText([self.introText6[3]], g.font, displaySurface,
                             g.GREEN, 0, centerWidth, lowerThird+(g.offset*3))
            
            if self.scavengerStep >= 5:
                
                h.renderText([self.introText6[4]], g.font, displaySurface,
                             g.GREEN, 0, centerWidth, lowerThird+(g.offset*4))
            
        # Now we switch to shrinking the screen into the viewing panel.
        if self.scavengerStep == 6:
            
            #  No Timer, this needs to be FAST!
            self.bufferSurfaceImage = pygame.Surface((g.width,g.height))
            self.bufferSurfaceImage.set_colorkey(g.RED)
            self.bufferSurfaceImage.fill(g.BLACK)
            self.bufferSurfaceImage.set_colorkey(g.BLACK)
            self.bufferSurfaceImage.blit(displaySurface, (0, 0))
            #  Surface prepared!
            self.scavengerStep += 1
        
        elif (self.scavengerStep >= 7 and self.scavengerStep <= 13):
            
            self.shrinkBufferSurface(self.scavengerStep-6)
            displaySurface.set_colorkey(g.RED)
            displaySurface.fill(g.BLACK)
            displaySurface.set_colorkey(g.BLACK)
            displaySurface.blit(self.bufferSurfaceImage,
                                (int((g.width/16)*((self.scavengerStep-6)*1.6)), 
                                 int((g.height/10)*(self.scavengerStep-6))))
            self.scavengerStep += 1
        
        #  Backup display into Buffer.
        elif self.scavengerStep == 14:
            
            #  Insert sacred pixel of bug fix!
            #bugFix = pygame.PixelArray(displaySurface)
            #  Ommmmm...
            #bugfix[0][0] = (1,1,1)
            #  *Monk chant* de sacra pixel insertis bugfix *bell toll*
            #bugfix.close()
            
            #  No Timer, this needs to be FAST!
            #self.bufferSurfaceImage = displaySurface.copy()
            #  Prior Surface sampled!
            self.scavengerStep += 1
            
        
        #  Prepare display surface for later frames.
        if (self.scavengerStep >= 15 and self.scavengerStep <= 279):
            
            displaySurface.set_colorkey(g.RED)
            displaySurface.fill(g.BLACK)
            displaySurface.set_colorkey(g.BLACK)
            displaySurface.blit(self.bufferSurfaceImage,
                                (int((g.width/16)*(7*1.6)), 
                                 int((g.height/10)*7)))
        
        if (self.scavengerStep >= 15 and self.scavengerStep <= 270):
            
            #  No Timer, this needs to be FAST!
            #  TODO:  Fix mysterous bug here!
            #  Note:  Voodoo bug!  Looks to be hardware surface mapping issue!

            #  Surface prepared!
            self.alienShipScaled.set_alpha(0 + (self.scavengerStep-15))
            
            if self.scavengerStep == 270:
                
                self.scavengerStep = 272
            
            else:
                
                self.scavengerStep += 5
        
        #  Draw Command Deck
        if (self.scavengerStep >= 15 and self.scavengerStep <= 279):
            
            displaySurface.blit(self.alienShipScaled, (0, 0))
        
        
        #  Make dot move twice to Thrice.
        #  Then draw reticules (3 of em, largest to smallest, 1 at a time).
        
        #  Need to draw ship dot moving into position on X and Y screens.
        if self.scavengerStep >= 272 and self.scavengerStep <= 275:
            
            currentTimer = 1
            adjustment = self.scavengerStep-272

            displayArray = pygame.PixelArray(displaySurface)
            displayArray[int((g.width/320)*183)-adjustment, int((g.height/200)*131)+adjustment] = g.WHITE
            displayArray[int((g.width/320)*62), int((g.height/200)*148)+adjustment] = g.WHITE
            displayArray.close()
        
        #  Draw targeting reticule.
        elif self.scavengerStep >= 276 and self.scavengerStep <= 279:
            
            currentTimer = 1  #  Temp.
            circles = self.scavengerStep-275

            displayArray = pygame.PixelArray(displaySurface)
            displayArray[int((g.width/320)*180), int((g.height/200)*134)] = g.WHITE
            displayArray[int((g.width/320)*62), int((g.height/200)*151)] = g.WHITE
            displayArray.close()
            
            h.targettingReticule(displaySurface, int((g.width/320)*180), int((g.height/200)*134), g.VILE_PINK, circles, 4, 1)
            h.targettingReticule(displaySurface, int((g.width/320)*62), int((g.height/200)*151), g.VILE_PINK, circles, 4, 1)
            
        if self.scavengerStep >= 280:
            
            finished = True
            
        #  Our timer for this sequence.
        if h.GameStopwatch.stopwatchSet:
            
            if h.GameStopwatch.getElapsedStopwatch() > currentTimer:
                
                h.GameStopwatch.resetStopwatch()
                self.scavengerStep += 1
                
        else:
            
            h.GameStopwatch.setStopwatch()
        
        return finished
示例#8
0
    def loadEncodes(self, surface):
        
        surface.fill(g.BLACK)
        finished = False
        currentTimer = 0
        lowerThird = int(7*(g.height/10))
        centerWidth = int(g.width/16)

        if self.encodeStep >= 0:
            
            currentTimer = 2
            h.renderText([self.introText4[0]], g.font, surface, g.WHITE,
                          0, centerWidth, lowerThird)

        if self.encodeStep >= 1:
            
            currentTimer = 3
            h.renderText([self.introText4[1]], g.font, surface, g.WHITE,
                         0, centerWidth*10, lowerThird)

        if self.encodeStep >= 2:
    
            currentTimer = 3
            h.renderText([self.introText4[2]], g.font, surface, g.WHITE,
            0, centerWidth, lowerThird+g.offset)
            
            if self.encodeStep == 2:
                
                self.count = 0

        #  Left Side

        if self.encodeStep == 3:
            
            currentTimer = 15
            #  TODO Set green light to red next to bar.
            self.drawEncodeBar(surface, 13, 48)

        if self.encodeStep == 4:
            
            currentTimer = 15
            #  TODO Set green light to red next to bar.
            self.drawEncodeBar(surface, 13, 78)

        if self.encodeStep == 5:
            
            currentTimer = 15
            #  TODO Set green light to red next to bar.
            self.drawEncodeBar(surface, 13, 108)

        #  Right Side.

        if self.encodeStep == 6:
            
            currentTimer = 15
            #  TODO Set green light to red next to bar.
            self.drawEncodeBar(surface, 271, 48)

        if self.encodeStep == 7:
            
            currentTimer = 15
            #  TODO Set green light to red next to bar.
            self.drawEncodeBar(surface, 271, 78)

        if self.encodeStep == 8:
            
            currentTimer = 15
            #  TODO Set green light to red next to bar.
            self.drawEncodeBar(surface, 271, 108)
            
        if self.encodeStep >= 9:
            
            currentTimer = 3
            h.renderText([self.introText4[3]], g.font, surface, g.WHITE,
            0, centerWidth, lowerThird+(g.offset*2))
            
        if self.encodeStep >= 10:
            
            currentTimer = 3
            h.renderText([self.introText4[4]], g.font, surface, g.WHITE,
            0, centerWidth, lowerThird+(g.offset*3))
            
        if self.encodeStep >= 11:
            
            currentTimer = 3
            h.renderText([self.introText4[5]], g.font, surface, g.WHITE,
            0, centerWidth, lowerThird+(g.offset*4))

        # Map the red encode sections to the screen.


        #  Draw full encode bars for each cycle.
        if self.encodeStep >= 4:
            
            #  Bar 1
            surface.blit(self.fullBar, (int((g.width/320)*13), int((g.height/200)*48)))
                        
            if self.encodeStep >= 5:
                
                #  Bar 2
                surface.blit(self.fullBar, (int((g.width/320)*13), int((g.height/200)*78)))
                                
                if self.encodeStep >= 6:
                    
                    #  Bar 3
                    surface.blit(self.fullBar, (int((g.width/320)*13), int((g.height/200)*108)))
                                        
                    if self.encodeStep >= 7:
                        
                        #  Bar 4
                        surface.blit(self.fullBar, (int((g.width/320)*271), int((g.height/200)*48)))
                                            
                        if self.encodeStep >= 8:
                            
                            #  Bar 5
                            surface.blit(self.fullBar, (int((g.width/320)*271), int((g.height/200)*78)))
                                                        
                            if self.encodeStep >= 9:
                                
                                #  Bar 6
                                surface.blit(self.fullBar, (int((g.width/320)*271), int((g.height/200)*108)))
                                                            
        #  Our timer for this sequence.
        if self.stopwatch.stopwatchSet:
            
            if self.stopwatch.getElapsedStopwatch() > currentTimer:
                
                self.stopwatch.resetStopwatch()
                self.encodeStep += 1
                
        else:
            
            self.stopwatch.setStopwatch()
        """
                self.introText4 = ["Ship IRONSEED to Relay Point:",
                           "Link Established.",
                           "Receiving Encode Variants.",
                           "Wiping Source Encodes.",
                           "Terminating Transmission.",
                           'Control Protocol Transfered to Human Encode "PRIME".']
        """
        if self.encodeStep >= 1:
            
            primeStatic = h.makeFuzz(int((g.width/16)*4), int((g.height/10)*4))
            surface.blit(primeStatic, (int((g.width/16)*6), int((g.height/10)*2)))

        surface.blit(self.charComScaled, (0, 0))
        
        # Add Tank Lights
        if self.encodeStep >= 4:
            
            # Red tank light top left
            surface.blit(self.redLightScaled, (int((g.width/320)*82), int((g.height/200)*31)))
            
            if self.encodeStep >= 5:
                
                # Red tank light middle left
                surface.blit(self.redLightScaled, (int((g.width/320)*82), int((g.height/200)*62)))
                
                if self.encodeStep >= 6:
                    
                    # Red tank light bottom left
                    surface.blit(self.redLightScaled, (int((g.width/320)*82), int((g.height/200)*92)))
                    
                    if self.encodeStep >= 7:
                        
                        # Red tank light top right
                        surface.blit(self.redLightScaledFlipped, (int((g.width/320)*226), int((g.height/200)*31)))
                    
                        if self.encodeStep >= 8:
                            
                            # Red tank light middle right
                            surface.blit(self.redLightScaledFlipped, (int((g.width/320)*226), int((g.height/200)*62)))
                            
                            if self.encodeStep >= 9:
                                
                                # Red tank light bottom right
                                surface.blit(self.redLightScaledFlipped, (int((g.width/320)*226), int((g.height/200)*92)))
        
        if self.encodeStep == 12:
            
            finished = True
        
        return finished
示例#9
0
    def drawInterface(self, displaySurface):

        displaySurface.fill(g.BLACK)
        displaySurface.blit(self.crewInterfaceScaled, (0, 0))

        #  Render heartbeat pulse line in red.
        self.crewPointer.drawStatusLine(displaySurface, self.pulseDisplayArea,
                                        0)

        #  Render small pulse line in red.
        pulse = h.createBar(self.pulseLine, len(self.pulseLine),
                            self.pulseLineArea.height)
        displaySurface.blit(pulse, self.pulseLineArea)

        #  Make pulse rotate right after each frame.
        self.pulseLine = h.shiftArrayRight(self.pulseLine)

        #  Render crewmember image.
        displaySurface.blit(self.crewPointer.resizedImage,
                            ((g.width / 320) * 220, (g.height / 200) * 16))

        #  Render green LED for selected crew member.
        displaySurface.fill(g.GREEN, self.currentGreenLED)

        #  Calculate sanity bar length
        sanityBarLength = int(
            (self.sanityBarArea.height / 100) * self.crewPointer.sanity)

        #  Create sanity bar tuple list.
        sanityBar = h.colourGradient(sanityBarLength, g.RED)

        #  Render sanity bar for selected crew member.
        adjustedSanityBar = h.createBar(sanityBar, sanityBarLength,
                                        self.sanityBarArea.height)
        rotatedSanityBar = pygame.transform.rotate(adjustedSanityBar, -90)
        scaledSanityBar = pygame.transform.scale(
            rotatedSanityBar, (self.sanityBarArea.width, sanityBarLength))
        displaySurface.blit(scaledSanityBar, self.sanityBarArea)

        #  Render pretty graphics in mini-monitor for ambiance.

        displaySurface.blit(self.scaledTitleText[self.titleFrameCount],
                            self.titleTextDraw)

        displaySurface.blit(self.scaledPseudoText[self.pseudoTextCount1],
                            self.pseudoTextDraw1)

        displaySurface.blit(self.scaledPseudoText[self.pseudoTextCount2],
                            self.pseudoTextDraw2)

        #  Adjust frame counters and timers.
        if self.frameCount >= 20:

            self.titleFrameCount += 1

            if self.titleFrameCount >= len(self.scaledTitleText):

                self.titleFrameCount = 0

            self.frameCount = 0

        elif self.frameCount in [0, 5, 10, 15, 20]:

            self.pseudoTextCount1 += 1
            self.pseudoTextCount2 += 1

            if self.pseudoTextCount1 >= len(self.scaledPseudoText):

                self.pseudoTextCount1 = 0

            if self.pseudoTextCount2 >= len(self.scaledPseudoText):

                self.pseudoTextCount2 = 0

        self.frameCount += 1

        #  Clear text area.
        displaySurface.fill(g.BLACK, self.blankDisplayArea)

        #  Render Bio column of text.
        h.renderText(self.crewPointer.bio, g.font, displaySurface, g.WHITE, 15,
                     (g.width / 320) * 6, (g.height / 200) * 131)

        #  Render Character Level text.
        h.renderText([str(self.crewPointer.level)], g.font, displaySurface,
                     g.WHITE, 15, (g.width / 320) * 154,
                     (g.height / 200) * 120)

        #  Render Character Experience points.
        h.renderText([str(self.crewPointer.experience)], g.font,
                     displaySurface, g.WHITE, 15, (g.width / 320) * 190,
                     (g.height / 200) * 120)

        #  Render Character Name.  Note, using 180 for x as is centre of text field.
        h.renderText([str(self.crewPointer.name)], g.font, displaySurface,
                     g.WHITE, 15, (g.width / 320) * 180,
                     (g.height / 200) * 103, True)