def render(): #Render game graphics! game.graphics.window.fill(pygame.Color(0, 0, 0)) #Draw game world game.graphics.camera.update() #Render UI game.graphics.base_ui.render() #Call miscellaneous "every frame" functions messaging.propagate("new_frame") #Finalize this rendering of the game pygame.display.update()
def handle_events(): #When focus is lost or gained, fire appropriate events if not(pygame.key.get_focused()): if game.graphics.last_focused: game.graphics.last_focused = False messaging.propagate("Focus-Lost") elif not game.graphics.last_focused: game.graphics.last_focused=True messaging.propagate("Focus-Gained") for event in pygame.event.get(): r = event.type if r==pygame.locals.ACTIVEEVENT: n = str(r) + "-" + str(event.gain) + "-" + str(event.state) elif r==pygame.locals.KEYDOWN: n = str(r) + "-" + str(event.key) elif r==pygame.locals.KEYUP: n = str(r) + "-" + str(event.key) elif r==pygame.locals.MOUSEBUTTONUP: n = str(r) + "-" + str(event.button) elif r==pygame.locals.MOUSEBUTTONDOWN: n = str(r) + "-" + str(event.button) elif r==pygame.locals.QUIT: if tkMessageBox.askyesno("Quit", "Do you really want to quit?"): game.running=False n="QUIT" else: continue else: n=str(r) messaging.propagate(n,(event,)) #note that the trailing comma is needed to make a tuple of 1 ele
def check_terrain_click(self, x, y): if x > self.x and y > self.y and x < self.x + self.width and y < self.y + self.height: x3, y3 = self.screen_to_cam(x, y) x2, y2 = self.cam_to_world(x3, y3) messaging.propagate("terrain_clicked", (x2, y2))
def check_terrain_click(self,x,y): if x>self.x and y>self.y and x<self.x+self.width and y<self.y+self.height: x3,y3=self.screen_to_cam(x,y) x2,y2=self.cam_to_world(x3,y3) messaging.propagate("terrain_clicked",(x2,y2))