def update(self): UiScene.update(self) jukebox.ensure_playing("title") if len(self.username.text) == 0: self.button.disable() else: self.button.enable() if self.auth_request != None and self.auth_request.has_response(): response = self.auth_request.get_response() if not response.get("success", False): response.get("message", "Server made an unrecognized response") else: hq = response.get("hq") sector = hq[0] loc = hq[1] user_id = response.get("user_id", 0) is_new = response.get("is_new", False) research = response.get("research", 0) buildings = response.get("buildings", []) unlock = self.username.text.endswith("!") bots = response.get("bots", [0, 0, 0]) self.next = playscene.LoadingScene( user_id, self.password, sector, loc, is_new, research, buildings, unlock, bots, False ) self.auth_request = None
def update(self): UiScene.update(self) jukebox.ensure_playing('title') if len(self.username.text) == 0: self.button.disable() else: self.button.enable() if self.auth_request != None and self.auth_request.has_response(): response = self.auth_request.get_response() if not response.get('success', False): response.get('message', "Server made an unrecognized response") else: hq = response.get('hq') sector = hq[0] loc = hq[1] user_id = response.get('user_id', 0) is_new = response.get('is_new', False) research = response.get('research', 0) buildings = response.get('buildings', []) unlock = self.username.text.endswith('!') bots = response.get('bots', [0, 0, 0]) self.next = playscene.LoadingScene(user_id, self.password, sector, loc, is_new, research, buildings, unlock, bots, False) self.auth_request = None
def update(self): jukebox.ensure_playing(None) if self.poll.has_response(): response = self.poll.get_response() if response.get('success', False): self.potato.apply_poll_data(response, self.user_id) t = self.potato.resources self.potato.resources = self.potato.escrow self.potato.escrow = t self.poll = None self.next = PlayScene(self.user_id, self.password, self.potato, util.totuple(self.sector), util.totuple(self.loc), self.new, self.tutorial) else: pass #print("Something terrible has happened.") self.next = None
def update(self): jukebox.ensure_playing('intro')
def update(self): self.counter += 1 jukebox.ensure_playing('credits')
def update(self): jukebox.ensure_playing('intro')
def update(self): self.counter += 1 jukebox.ensure_playing('credits')
def render(self, screen): self.last_width = screen.get_width() cx = self.player.x cy = self.player.y cz = self.player.z camera.track(cx, cy, cz) structures = self.potato.get_structures_for_screen(cx, cy) labels = [] if self.curiosity != None: cur = self.curiosity for s in structures: if s.btype == 'hq' and s.user_id == self.user_id: cur.hq.x = s.x cur.hq.y = s.y entities = [cur.hq] height = cur.get_hq_height() if height != None: cur.hq.setheight(height) else: entities = [] else: for s in structures: if s.btype == 'hq': owner_id = s.user_id name = self.potato.get_user_name(owner_id) img = get_text(name, (255, 255, 255), 18) px, py = camera.screenpos(s.x, s.y, s.z - 20) labels.append([img, px-img.get_width()//2, py]) # Don't show destroyed buildings outside battle if self.battle is None: structures = [s for s in structures if not s.destroyed] entities = structures + self.shots # HACK entities += [s for s in self.sprites if (s.x - self.player.x) ** 2 + (s.y - self.player.y) ** 2 < 40 ** 2] # entities = structures + [self.player] + self.shots if self.battle != None: entities += self.battle.get_sprites() px, py = self.player.getModelXY() sx = int(px // 60) sy = int(py // 60) borders = self.potato.get_borders_near_sector(sx, sy) if self.potato.borders_by_user[self.user_id].iswithin(self.player.x, self.player.y): if self.build_mode: # HAAAAACK! s = structure.btypedict[self.build_mode].size if self.build_mode in structure.btypedict else 1 cursor = (cx, cy, s) else: cursor = (cx, cy, 0) else: cursor = None worldmap.drawscene(screen, entities + effects.effects, cursor, borders) if self.curiosity != None: self.curiosity.render_skycrane(screen) for label in labels: screen.blit(label[0], (label[1], label[2])) if settings.showminimap: worldmap.drawminimap(screen, entities) mx, my = self.player.getModelXY() lx, ly = int(mx // 1), int(my // 1) # coords = get_text("R: (%0.1f, %0.1f) M: (%0.1f, %0.1f) L: (%i, %i)" % (cx, cy, mx, my, lx, ly), (255, 255, 0), 16) coords = get_text("location: (%.0f, %.0f)" % (cx, cy), (255, 255, 0), 16) screen.blit(coords, (5, screen.get_height() - 25 - coords.get_height())) self.toolbar.render(screen) self.player.drawhealth(screen) if self.battle != None: self.battle.renderstatus(screen) left = 330 top = 40 y = top x = left for res in ('food', 'water', 'aluminum', 'copper', 'silicon', 'oil', 'research'): screen.blit(get_resource_icon(res), (left, y)) color = (255, 255, 255) if res == 'research': amount = int(self.potato.bytes_stolen) color = (0, 255, 255) else: amount = int(self.potato.get_resource(res)) if amount < 0: amount = 0 famount = [] while amount > 0: z = str(amount % 1000) while len(z) < 3: z = '0' + z famount.append(z) amount = amount // 1000 amount = ','.join(famount[::-1]) while len(amount) > 1 and amount[0] == '0': amount = amount[1:] screen.blit(get_text(str(amount), color, 14), (left + 14, y)) mx, my = self.mousex, self.mousey if mx > left and my > y and my < y + 20: newname = { 'food': settings.RESOURCE_FOOD, 'water': settings.RESOURCE_WATER, 'oil': settings.RESOURCE_OIL, 'aluminum': settings.RESOURCE_ALUMINUM, 'copper': settings.RESOURCE_COPPER, 'silicon': settings.RESOURCE_SILICON, 'research': "Bytes of Research" } img = get_text(newname[res], color, 14) screen.blit(img, (left - 5 - img.get_width(), y + 1)) y += 20 if self.blinkt: h = screen.get_height() w = screen.get_width() sh = min(h * self.blinkt // 10, h // 2 + 1) pygame.draw.rect(screen, (0,0,0), (0,0,w,sh), 0) pygame.draw.rect(screen, (0,0,0), (0,h-sh,w,sh), 0) jukebox.ensure_playing('general')