Changeset 197


Ignore:
Timestamp:
05/23/2012 01:35:09 PM (3 years ago)
Author:
andefodahl
Message:

Completed (tentatively) most of the graphics methods

Location:
traintris
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • traintris/gameboardview.py

    r196 r197  
    108108        self.textColor = (55, 74, 46)
    109109        self.mbcolor = (146,209,79)
    110         self.randomcolor = (145, 200, 5)
    111110       
    112111        #Load pictures
     
    300299            elif number == 1:
    301300                self.moreInfoDraw("Falcon",self.comments["falconInfo"],
    302                     "3 cells", context, self.comments["falconfood"], "Human")
     301                    "3 cells", context, self.comments["falconFood"], "Human")
    303302            elif number == 2:
    304303                self.moreInfoDraw("Lion",self.comments["lionInfo"],
  • traintris/graphics.py

    r196 r197  
    66        self.screen = screen
    77        self.imageDict = {}
     8       
     9        self.white = (255, 255, 255)
     10        self.black = (0, 0, 0)
     11        self.yellow = (255, 255, 0)
     12        self.textColor = (55, 74, 46)
     13        self.mbcolor = (146,209,79)
     14        self.red = (255, 0, 0)
     15       
     16        self.screenheight = self.screen.get_height()
     17        self.screenwidth = self.screen.get_width()
    818       
    919        #Messageboard drawing presets
     
    99109        return
    100110
    101     # def drawInfoBox(self,
     111    def drawInfoBox(self, name, description, diet, rang, predators, color):
     112        boxsize = (self.screenwidth / 5)
     113        ystart = self.screenheight - boxsize
     114        self.drawImage("infobox", (0, ystart))
     115        if rang == "" and predators == "":
     116            self.drawText(name, (20, ystart + 20), (boxsize - 40), color, 10)
     117            self.drawText(description, (20, ystart + 98), (boxsize - 40), color, 10)
     118            self.drawText(diet, (20, ystart + 176), (boxsize - 40), color, 10)
     119        else:
     120            self.drawText(name, (20, ystart + 20), (boxsize - 40), color, 10)
     121            self.drawText(description, (20, ystart + 67), (boxsize - 40), color, 10)
     122            self.drawText(diet, (20, ystart + 114), (boxsize - 40), color, 10)
     123            self.drawText(rang, (20, ystart + 161), (boxsize - 40), color, 10)
     124            self.drawText(predators, (20, ystart + 208), (boxsize - 40), color, 10)
     125           
     126    def drawDialogBox(self, string1, string2, color):
     127        self.drawImage("dialogbox", ((self.screenwidth / 2) - 150, (self.screenheight / 2) - 100))
     128        self.drawText(string1, ((self.screenwidth / 2) - 130, (self.screenheight / 2) - 80), 260, color, 40)
     129        self.drawText(string2, ((self.screenwidth / 2) -130, (self.screenheight / 2) + 20), 260, color, 40)
    102130   
    103     # def drawDialogBox(self,
     131    def drawMenuBox(self,
     132        boxsize = (self.screenwidth) / 5)
     133        xstart = self.screenwidth - boxsize
     134        ystart = self.screenheight - boxsize
     135        self.drawImage("menubox", (xstart, ystart))
     136        #self.drawButton(r
     137       
     138    def drawBottomBar(self, daysRemaining, season, animal, diet, rang):
     139        boxsize = (3/5)*self.screenwidth
     140        xstart = self.screenwidth / 5
     141        ystart = self.screenheight - 90
     142        midbox = (1/2)*self.screenwidth
     143        self.drawImage("bottomBar", (xstart, ystart))
     144        self.drawImage(season, (xstart, ystart))
     145        self.drawImage(animal, (midbox, ystart)
     146        self.drawText(daysRemaining, (xstart + 100, ystart + 20), (mixbox - 110), self.black, 20)
     147        self.drawText(diet, (midbox + 100, ystart + 20), 190, self.black, 20)
     148        self.drawText(rang, (mixbox + 300, ystart + 20), 90, self.black, 20)
    104149   
    105     # def drawMenuBox(self,
    106    
    107     # def drawBottomBar(self, daysRemaining,
    108    
    109     # def drawCategoryBar(self,
     150    def drawCategoryBar(self):
     151       
    110152   
    111153    # def drawOrganismBar(self,
    112154   
    113     # def drawText(self,
     155    # def drawText(self, text, pos, width, color, size)
    114156   
    115 #-------------------------------------------------------------------------------------------------
    116 # draws a button (pos is top-left)
     157    #-------------------------------------------------------------------------------------------------
     158    # draws a button (pos is top-left)
    117159    def drawButton(self, images, mode, pos):
    118160   
     
    126168        self.drawImage(image, (x,y))
    127169
    128 #-------------------------------------------------------------------------------------------------
    129 # draws an image based on an identifying string and a pos
     170    #-------------------------------------------------------------------------------------------------
     171    # draws an image based on an identifying string and a pos
    130172    def drawImage(self, imageName, pos):
    131173        globalVars.screen.blit(self.loadImage(imageName), pos)
    132174
    133 #-------------------------------------------------------------------------------------------------
    134 # loads an image either from a file or from the image dictionary
     175    #-------------------------------------------------------------------------------------------------
     176    # loads an image either from a file or from the image dictionary
    135177    def loadImage(self, imageName):
    136178        imageName = path.join('gfx\objects', imageName)
Note: See TracChangeset for help on using the changeset viewer.