def main(): drawList = [] #Realtor Domain title titleText = vars.Text('Realtor Domain', None, 120) titleText.rect.centerx = vars.WINW * .4 titleText.rect.top = 100 drawList.append(titleText) #Menu Items menuText = [] menuText.append(vars.Text('New Game', None, 80)) menuText[0].rect.left = titleText.rect.left + 100 menuText[0].rect.top = titleText.rect.top + 150 menuText.append(vars.Text('Developer', None, 80)) menuText[1].rect.topleft = (menuText[0].rect.left, menuText[0].rect.top + 100) drawList.append(menuText[0]) drawList.append(menuText[1]) loop = True while loop: for event in pygame.event.get(): if event.type == QUIT: Terminate() if event.type == MOUSEBUTTONDOWN: if menuText[1].rect.collidepoint(event.pos): engine.main(True) vars.DISP.fill(vars.BLACK) for i in range(len(drawList)): drawList[i].Draw() pygame.display.update() vars.FPSCLOCK.tick(vars.FPS)
def Update(self): if self.dirty: self.playerText[0] = (vars.Text(self.name, None, 48)) self.playerText[1] = (vars.Text(' Debt / Credit ', None, 32)) self.playerText[2] = (vars.Text( ' $ ' + str(self.debt) + ' / ' + str(self.creditLine), None, 32)) self.playerText[3] = (vars.Text(' Cash ', None, 32)) self.playerText[4] = (vars.Text(' $ ' + str(self.cash), None, 32)) self.playerText[0].rect.topleft = (vars.INFOX + 10, vars.INFOY + 10) for i in range(len(self.playerText)): if i != 0: self.playerText[i].rect.topleft = self.playerText[ i - 1].rect.bottomleft self.dirty = False
def Draw(self): pygame.draw.rect(vars.DISP, vars.BLACK, (0, 0, 900, 900)) for i in range(len(self.blocks)): self.blocks[i].Draw() for i in range(len(self.mapButtons)): self.mapButtons[i].Draw() temp = vars.Text(str(self.time), None, 24) temp.rect.centery = self.mapButtons[3].rect.centery temp.rect.left = self.mapButtons[3].rect.right + 10 temp.Draw()
def Starting(self): self.debt = 1000 self.creditLine = 10000 self.cash = 40000 self.isPlayer = True self.playerText.append( vars.Text(self.name, None, 48, vars.WHITE, vars.VDKGREY)) self.playerText.append( vars.Text(' Debt / Credit ', None, 32, vars.WHITE, vars.VDKGREY)) self.playerText.append( vars.Text(' $ ' + str(self.debt) + ' / ' + str(self.creditLine), None, 32, vars.WHITE, vars.VDKGREY)) self.playerText.append( vars.Text(' Cash ', None, 32, vars.WHITE, vars.VDKGREY)) self.playerText.append( vars.Text(' $ ' + str(self.cash), None, 32, vars.WHITE, vars.VDKGREY)) self.playerText[0].rect.topleft = (vars.INFOX + 10, vars.INFOY + 10) for i in range(len(self.playerText)): if i != 0: self.playerText[i].rect.topleft = self.playerText[ i - 1].rect.bottomleft
def SplashScreen(Surface, FPSClock): looper = True splashText = vars.Text('blacKnight gaMing', None, 32, vars.WHITE, vars.BLACK) splashText.rect.centerx = 200 splashText.rect.centery = 200 ticker = 0 while looper: Surface.fill(vars.BLACK) splashText.Draw(Surface) ticker += 1 if ticker > 20: looper = False pygame.display.update() FPSClock.tick(vars.FPS)
def Update(self): if self.selected is not None and self.selected.dirty: self.blockInfo = [] #Update all the selected info text self.title = vars.Text(self.selected.name, None, 48, vars.WHITE, vars.VDKGREY) self.address = vars.Text('Feature to be Coded.', None, 32, vars.WHITE, vars.VDKGREY) self.owner = vars.Text('Owner: ' + self.selected.owner, None, 32, vars.WHITE, vars.VDKGREY) if self.selected.owner == player.name: adjustVal = .75 else: adjustVal = 1.25 self.price = vars.Text( 'Price: ' + str(self.selected.value * adjustVal), None, 32, vars.WHITE, vars.VDKGREY) #Reset all the rect positioning self.title.rect.topleft = [vars.DETAILSX + 10, vars.DETAILSY + 10] self.address.rect.topleft = self.title.rect.bottomleft self.owner.rect.topleft = self.address.rect.bottomleft self.price.rect.topleft = self.owner.rect.bottomleft #If this isn't an empty lot we need the building information if not self.empty: self.type = vars.Text(self.selected.type + ' Building', None, 32, vars.WHITE, vars.VDKGREY) self.shape = vars.Text(self.selected.shape, None, 32, vars.WHITE, vars.VDKGREY) temp = str(self.selected.floors) + ' + ' + \ str(int(self.selected.additionalFloor)) self.floors = vars.Text(temp + ' floors', None, 32, vars.WHITE, vars.VDKGREY) self.type.rect.topleft = self.price.rect.bottomleft self.shape.rect.topleft = self.type.rect.bottomleft self.floors.rect.topleft = self.shape.rect.bottomleft #Readjust the button voids for i in range(len(self.buttons)): self.buttons[i].void = False if self.selected.owner == player.name: self.buttons[0].void = True self.buttons[1].void = False if (self.selected.additionalFloor or self.selected.type == 'Empty'): self.buttons[2].void = True if (self.selected.type != 'Retail' and self.selected.type != 'Residential'): self.buttons[3].void = True if self.empty: self.buttons[4].void = True self.buttons[5].void = False else: self.buttons[4].void = False self.buttons[5].void = True else: self.buttons[0].void = False for i in range(len(self.buttons)): if i != 0: self.buttons[i].void = True #Ensure the selected building/plot is highlighted self.selected.highlight = True #Reset the dirty flag self.selected.dirty = False