def __init__(self, position, data): """ create tooltip window. data must be list of pairs ["label", "value"] """ Window.__init__(self, (0, 0), position) self.data = data self.alphavalue = 200 # self.crete_widgets()
def __init__(self, position, data): """create tooltip window. data must be list of pairs ["label", "value"] """ Window.__init__(self, 0, 0, position) self.data = data self.alphavalue = 200 # self.create_widgets()
def __init__(self, size): Window.__init__(self, size, (150, 40)) # set window alpha self.alphavalue = 250 * 0.95 # Create gui self.create_gui() # hide market at load self.hide()
def __init__(self, width, height): Window.__init__(self, width, height, (150, 40)) # set window alpha self.alphavalue = 250 * 0.95 # Create gui self.create_gui() # hide market at load self.hide()
def update(self): """Update farm""" Window.update(self) self.eventstimer.tick() self.updatetimer.tick() # update inventory self.inventorywindow.update() # Update game 20 times per second if self.updatetimer.tickpassed(20): self.gamemanager.update() # update inventory when changed self.update_current_money() if self.inventorywindow.ismodified(): self.recreate_inventory()
def __init__(self): Window.__init__(self, (800, 600), (0, 0)) self.lazyscreen = None # Create gamemanager self.gamemanager = GameManager() # timers self.eventstimer = Timer() self.updatetimer = Timer() self.images = ImageLoader(imagesdata) self.notifyfont = pygame.font.Font("dejavusansmono.ttf", 12) self.font2 = pygame.font.Font("dejavusansmono.ttf", 18) # Install plugins self.coreplugin = PluginSystem.installPlugin(CorePlugin) self.coreplugin.gamewindow = self # background image bgimg = Image(self.images['background'], (0, 0)) self.addwidget(bgimg) # Create inventory window player = self.gamemanager.getplayer() self.inventorywindow = InventoryWindow(self.images, player) self.inventorywindow.hide() # create market window self.sellwindow = MarketWindow((400, 400), self.images, player, self.gamemanager) self.sellwindow.gamewindow = self # Market button marketbutton = Button("", (800 - 42, 10), bgimage=self.images['marketbutton']) marketbutton.connect("clicked", self.toggle_market) self.addwidget(marketbutton) # Inventory button inventorybutton = Button("", (800 - 42, 52), bgimage=self.images['inventorybutton']) inventorybutton.connect("clicked", self.toggle_inventory) self.addwidget(inventorybutton) # Create help window self.helpwindow = HelpWindow((500, 300)) # Create expbar self.expbar = ExpBar(player) self.addwidget(self.expbar) # labels self.moneylabel = Label("", (400, 5), align="center") self.addwidget(self.moneylabel) # Label for version versionlabel = Label("v. " + __VERSION__ + " (H for help)", (5, 580)) self.addwidget(versionlabel) # Is game running? self.running = False # Farm position offset (to center map) self.farmoffset = (212, 50) # Temp image for farmfield redraw if not modified self.tempfarmimage = None
def redraw(self, screen): """Redraw screen""" Window.draw(self, screen) # Draw gamewindow self.draw(screen) farm = self.gamemanager.getfarm() player = self.gamemanager.getplayer() # avoid temp farm image to be None if not self.tempfarmimage or farm.ismodified(): # Draw farmfield self.tempfarmimage = render_field(screen, self.images, farm, self.farmoffset) # Blit farmfield screen.blit(self.tempfarmimage, (0, 0)) # draw rain if farm.raining and self.updatetimer.tickpassed(2): render_rain(screen) x = random.randint(0, 12) y = random.randint(0, 12) farm.water(x, y) drawnearcursor = not self.sellwindow.visible # Draw tools and selected tool rectangle draw_tools(screen, player.selectedtool, player.selecteditem, self.images, drawnearcursor=drawnearcursor) # draw watercanuses uses = Label("", (110 + 2, 10 + 2), color=(255, 240, 240)) uses.settext(str(player.watercanuses)) uses.repaint() uses.draw(screen) if not self.sellwindow.visible and \ not self.inventorywindow.visible: mx, my = pygame.mouse.get_pos() # Draw help window self.helpwindow.draw(screen) # draw notify window if mouse under seed pos = self.get_farmtile_pos_under_mouse() if pos: farmtile = farm.get_farmtile(pos[0], pos[1]) farmobject = farmtile['object'] render_seed_notify(screen, self.notifyfont, mx + 5, my + 5, farmobject, farmtile, self.images ) # draw selected seed if player.selecteditem != None: draw_selected_seed(screen, player.selecteditem, self.images) # draw inventory self.inventorywindow.draw(screen) # redraw sell window self.sellwindow.draw(screen)
def redraw(self, screen): """Redraw screen""" Window.draw(self, screen) # Draw gamewindow self.draw(screen) farm = self.gamemanager.getfarm() player = self.gamemanager.getplayer() # avoid temp farm image to be None if not self.tempfarmimage or farm.ismodified(): # Draw farmfield self.tempfarmimage = render_field(screen, self.images, farm, self.farmoffset) # Blit farmfield screen.blit(self.tempfarmimage, (0, 0)) # draw rain if farm.raining and self.updatetimer.tickpassed(2): render_rain(screen) x = random.randint(0, 12) y = random.randint(0, 12) farm.water(x, y) drawnearcursor = not self.sellwindow.visible # Draw tools and selected tool rectangle draw_tools(screen, player.selectedtool, player.selecteditem, self.images, drawnearcursor=drawnearcursor) # draw watercanuses uses = Label("", (110 + 2, 10 + 2), color=(255, 240, 240)) uses.settext(str(player.watercanuses)) uses.repaint() uses.draw(screen) if not self.sellwindow.visible and \ not self.inventorywindow.visible: mx, my = pygame.mouse.get_pos() # Draw help window self.helpwindow.draw(screen) # draw notify window if mouse under seed pos = self.get_farmtile_pos_under_mouse() if pos: farmtile = farm.get_farmtile(pos[0], pos[1]) farmobject = farmtile['object'] render_seed_notify(screen, self.notifyfont, mx + 5, my + 5, farmobject, farmtile, self.images) # draw selected seed if player.selecteditem != None: draw_selected_seed(screen, player.selecteditem, self.images) # draw inventory self.inventorywindow.draw(screen) # redraw sell window self.sellwindow.draw(screen)