def draw(self): parent = get(self.parentid) p = window.screenpos(parent.X, parent.y) color = tuple(int(a * (0.8 + 0.2 * math.sin(8 * self.t))) for a in (128, 255, 128)) pygame.draw.circle(window.screen, color, p, F(5), 0) pygame.draw.circle(window.screen, color, p, F(10), F(1)) pygame.draw.circle(window.screen, color, p, F(15), F(1))
def draw(self): if not self.bubble: return X, y, t = self.bubble t = self.t - t p = window.screenpos(X, y) r = max(F(6 * t), F(1)) pygame.draw.circle(window.screen, (0, 60, 30), p, r, F(1))
def draw(self): p = window.screenpos(self.X, self.y) color = tuple( int(a * (0.8 + 0.2 * math.sin(8 * self.t))) for a in (255, 128, 128)) pygame.draw.circle(window.screen, color, p, F(5), 0) pygame.draw.circle(window.screen, color, p, F(10), F(1)) pygame.draw.circle(window.screen, color, p, F(15), F(1))
def drawnotice(text): alpha = pygame.time.get_ticks() * 0.001 % 1 ptext.draw(text, midtop=F(854 / 2, 100), color="#FF7777", owidth=1, fontsize=F(36), fontname="NovaSquare", alpha=alpha)
def draw(): for line, t0, t in lines: alpha = min(2 * t, 1, (2 * (t0 - t) if t0 is not None else 1)) ptext.draw(line, fontsize=F(24), midtop=F(854 / 2, 80), width=F(460), color="gray", owidth=1, alpha=alpha, fontname="Orbitron", lineheight=1.2)
def drawstats(): global statsbox if not state.you: return w = F(80) if statsbox is None or statsbox.get_size() != (w, w): statsbox = pygame.Surface((w, w)).convert_alpha() statsbox.fill((0, 0, 0, 30)) img = image.get(state.you.imgname, s=F(60)) statsbox.blit(img, img.get_rect(center=statsbox.get_rect().center)) pygame.draw.rect(statsbox, (255, 255, 255, 40), (0, 0, w, w), F(3)) window.screen.blit(statsbox, statsbox.get_rect(left=F(10), top=F(10))) shipname, special = shipdata[state.you.__class__.__name__] text = "\n".join([ "Current ship: %s" % shipname, "Hold space: teleport", "Tap space: %s" % special if special is not None else "", "Backspace: emergency teleport", ]) ptext.draw(text, topleft=F(10, 104), fontsize=F(16), shadow=(1, 1), lineheight=1.1, alpha=0.5, fontname="Exo") x0, y0, w, h, dx, thick = F(104, 10, 16, 20, 20, 2) for j in range(state.you.maxhp): pygame.draw.rect(window.screen, (0, 100, 0), (x0 + j * dx, y0, w, h), (0 if j < state.you.hp else thick))
def drawtitle(): a1 = math.clamp((t - 4) / 2, 0, 1) a2 = math.clamp((t - 5.5) / 2, 0, 1) a3 = math.clamp((t - 6.5) / 2, 0, 1) a4 = math.clamp((t - 8) / 2, 0, 1) ptext.draw(settings.gamename, fontsize=F(70), center=F(427, 140), owidth=2, color="#44FF77", gcolor="#AAFFCC", alpha=a1, fontname="Audiowide") ptext.draw("by Christopher Night", fontsize=F(26), midtop=F(427, 180), owidth=2, color="#7777FF", gcolor="#AAAAFF", alpha=a2, fontname="Audiowide") ptext.draw("MUSIC\nPRODUCTION\nTESTING\nARTWORK\nVOICE", fontsize=F(24), topright=F(427 - 10, 240), lineheight=1.24, owidth=2, color="#7777FF", gcolor="#AAAAFF", alpha=a2, fontname="Audiowide") ptext.draw( "Mary Bichner\nCharles McPillan\nLeo Stein\nMolly Zenobia\nRandy Parcel", fontsize=F(24), topleft=F(427 + 10, 240), lineheight=1.24, owidth=2, color="#7777FF", gcolor="#AAAAFF", alpha=a2, fontname="Audiowide") ptext.draw("Press space to begin", fontsize=F(24), midtop=F(427, 440), owidth=2, color="#777777", gcolor="#AAAAAA", alpha=a3, fontname="Audiowide")
def draw(self): if self.deployed: dX = 3 * math.sin(4 * self.t) / self.y dy = 3 * math.cos(4 * self.t) px, py = window.screenpos(self.X + dX, self.y + dy) size = F(2) window.screen.fill((255, 255, 255), (px, py, size, size))
def drawminimap(): global minimap w = F(120) scale = window.f if minimap is None or minimap.get_size() != (w, w): minimap = pygame.Surface((w, w)).convert_alpha() minimap.fill((255, 255, 255, 30)) p0 = window.windowpos(0, 0, w, w, window.camera.X0, window.camera.y0, scale) for r in range(25, state.R + 25, 25): pygame.draw.circle(minimap, (255, 255, 255, 60), p0, int(scale * r), F(1)) for j in range(48): r0 = 25 * (8 if j % 2 else 4 if j % 4 else 2 if j % 8 else 1) X = math.tau * j / 48 p1 = window.windowpos(X, r0, w, w, window.camera.X0, window.camera.y0, scale) p2 = window.windowpos(X, state.R, w, w, window.camera.X0, window.camera.y0, scale) pygame.draw.line(minimap, (255, 255, 255, 60), p1, p2, F(1)) objs = [(state.you, (200, 200, 200))] objs += [(g, (200, 0, 200)) for g in state.goals] for obj, color in objs: p = window.windowpos(obj.X, obj.y, w, w, window.camera.X0, window.camera.y0, scale) pygame.draw.circle(minimap, color, p, F(2)) pygame.draw.rect(minimap, (255, 255, 255, 60), (0, 0, w, w), F(3)) window.screen.blit(minimap, minimap.get_rect(right=window.sx - F(10), top=F(10)))
def draw(self): if not self.deployed: return r = settings.beacondetect - 1 for j in range(3): a = 4 * self.t + j * math.tau / 3 X = self.X + r * math.sin(a) / self.y y = self.y + r * math.cos(a) pygame.draw.circle(window.screen, (200, 200, 50), window.screenpos(X, y), F(2))
def draw(self): target = get(self.targetid) if not target: return for d, s in [(-0.1, 3), (-0.05, 6), (0, 8), (0.05, 6), (0.1, 3)]: f = math.clamp(self.flife + d, 0, 1) X = self.X + f * (target.X - self.X) y = self.y + f * (target.y - self.y) pygame.draw.circle(window.screen, (255, 128, 255), window.screenpos(X, y), F(s), 0)
def draw(): window.screen.fill((0, 0, 0)) background.draw() a1 = math.clamp((t - 4) / 2, 0, 1) a2 = math.clamp((t - 5.5) / 2, 0, 1) a3 = math.clamp((t - 6.5) / 2, 0, 1) a4 = math.clamp((t - 8) / 2, 0, 1) ptext.draw(settings.gamename, fontsize=F(70), center=F(427, 140), owidth=2, color="#44FF77", gcolor="#AAFFCC", alpha=a1, fontname="Audiowide") # ptext.draw("by Christopher Night", fontsize = F(26), midtop = F(427, 180), # owidth = 2, color = "#7777FF", gcolor = "#AAAAFF", alpha = a2, fontname = "Audiowide") background.drawwash()
def draw(self): parent = get(self.parentid) if not parent: return p = px, py = window.screenpos(parent.X, parent.y) color = tuple( int(a * (0.8 + 0.2 * math.sin(8 * self.t))) for a in (128, 255, 128)) pygame.draw.circle(window.screen, color, p, F(5), 0) pygame.draw.circle(window.screen, color, p, F(10), F(1)) pygame.draw.circle(window.screen, color, p, F(15), F(1)) dx = F(90 * math.clamp(self.t * 0.6 - 0.2, 0, 1)) pygame.draw.line(window.screen, color, p, (px + dx, py), F(1)) ptext.draw("TELEPORT TO\nTHIS SHIP", fontsize=F(12), color=(128, 255, 128), owidth=1, fontname="Exo", midleft=(px + F(20), py), alpha=math.clamp(self.t - 1, 0, 1))
def draw(): if settings.drawbackground: background.draw() else: window.screen.fill((0, 60, 0)) for obj in todraw: obj.draw() if "cursor" in control: image.worlddraw("cursor", control["cursor"].X, control["cursor"].y, 1.6, angle=pygame.time.get_ticks() * 0.15) if "qtarget" in control: X, y = control["qtarget"] image.worlddraw("qtarget", X, y, 1, angle=-pygame.time.get_ticks() * 0.15) dialog.draw() hud.draw() hud.drawstats() state.you.drawhud() dy = state.you.y - state.Rcore if dy < 36: alpha = pygame.time.get_ticks() * 0.001 % 1 ptext.draw("Warning: Approaching data horizon", midtop=F(854 / 2, 100), color="#FF7777", owidth=1, fontsize=F(36), fontname="NovaSquare", alpha=alpha) background.drawwash()
def draw(self): if not self.deployed: return px0, py0 = window.screenpos(self.X, self.y) for obj in state.goals: dx = math.Xmod(obj.X - self.X) * (self.y + obj.y) / 2 dy = obj.y - self.y d = math.sqrt(dx ** 2 + dy ** 2) if d < 8: continue dx /= d dy /= d px = px0 + int(window.camera.R * 2 * dx) py = py0 - int(window.camera.R * 2 * dy) pygame.draw.circle(window.screen, (0, 0, 255), (px, py), F(2))
def draw(): if not currentline: return if currentline[0] == "E" or currentline[0] == "C": return fontname, fontsize, color = style[currentline[0]] ptext.draw(currentline[2:], fontsize = F(fontsize), width = F(640), owidth = 0, shadow = (1, 1), left = F(180), bottom = window.sy - F(10), fontname = fontname, color = color) img = image.get("avatar-" + currentline[0] + ".bmp", s = F(150)) window.screen.blit(img, img.get_rect(center = F(90, 390)))
def save(): from src import window, thing, quest, dialog, hud from src.window import F ptext.draw("Saving...", fontname="Audiowide", fontsize=F(70), color="orange", gcolor="white", owidth=2, center=window.screen.get_rect().center) pygame.display.flip() pklsave = settings.savename.endswith(".pkl") def getids(x): if x is None: return None if isinstance(x, list): return [a.thingid for a in x] return x.thingid if pklsave: getids = lambda x: x savestate = { "you": getids(you), "mother": getids(mother), "target": getids(target), "shipyard": shipyard, "ships": getids(ships), "objs": getids(objs), "hazards": getids(hazards), "beacons": getids(beacons), "effects": getids(effects), "convergences": getids(convergences), "goals": getids(goals), "quickteleport": quickteleport, "camera": window.camera.dump(), "thing": thing.pkldump() if pklsave else thing.dump(), "quest": quest.dump(), "dialog": dialog.dump(), "hud": hud.dump(), } if pklsave: pickle.dump(savestate, open(settings.savename, "wb")) else: json.dump(savestate, open(settings.savename, "w"))
def load(): from src import window, thing, quest, dialog, hud from src.window import F ptext.draw("Loading...", fontname="Audiowide", fontsize=F(70), color="orange", gcolor="white", owidth=2, center=window.screen.get_rect().center) pygame.display.flip() pklsave = settings.savename.endswith(".pkl") if pklsave: savestate = pickle.load(open(settings.savename, "rb")) thing.pklload(savestate["thing"]) getthings = lambda x: x else: savestate = json.load(open(settings.savename)) thing.load(savestate["thing"]) def getthings(x): if pklsave or x is None: return x if isinstance(x, list): return [thing.get(a) for a in x] return thing.get(x) window.camera.load(savestate["camera"]) quest.load(savestate["quest"]) dialog.load(savestate["dialog"]) hud.load(savestate["hud"]) global you, mother, target, goals global ships, shipyard, objs, hazards, beacons, effects, convergences, quickteleport you = getthings(savestate["you"]) mother = getthings(savestate["mother"]) target = getthings(savestate["target"]) ships = getthings(savestate["ships"]) shipyard = savestate["shipyard"] objs = getthings(savestate["objs"]) hazards = getthings(savestate["hazards"]) beacons = getthings(savestate["beacons"]) effects = getthings(savestate["effects"]) convergences = getthings(savestate["convergences"]) goals = getthings(savestate["goals"]) quickteleport = savestate["quickteleport"]
def draw(): window.screen.fill((0, 0, 100)) ptext.draw( "Press Esc to quit", fontname="Oregano", fontsize=F(40), bottomleft=window.screen.get_rect().inflate(*F((-20, -20))).bottomleft, color="#00AAFF", shadow=(1, 1)) for button in buttons: button.draw() pygame.draw.circle(window.screen, (255, 255, 255), F((420, 120)), F(100)) media.drawimage(media.colorfilter(media.getimage("earth.jpg")), F((640, 120)), 2.1 * window.sf) media.drawimage("egg.png", F((640, 320)), 0.3 * window.sf)
import pygame from pygame.locals import * from src import settings, window, ptext from src.scenes import play from src.window import F ptext.FONT_NAME_TEMPLATE = "data/%s.ttf" pygame.mixer.init() window.init() play.init() clock = pygame.time.Clock() playing = True while playing: dt = 0.001 * clock.tick(settings.maxfps) events = list(pygame.event.get()) for event in events: if event.type == QUIT: playing = False if event.type == KEYDOWN and event.key == K_ESCAPE: playing = False if event.type == KEYDOWN and event.key == K_F12: pygame.image.save(window.screen, "screenshot.png") play.think(dt, events) play.draw() ptext.draw("%.1ffps" % clock.get_fps(), fontname = "Oregano", fontsize = F(32), bottomright = window.screen.get_rect().bottomright, color = "white") pygame.display.flip() pygame.quit()
def draw(self): for d, s in [(-0.1, 3), (-0.05, 6), (0, 8), (0.05, 6), (0.1, 3)]: f = math.clamp(self.flife + d, 0, 1) X = self.X + f * (self.X1 - self.X) y = self.y + f * (self.y1 - self.y) pygame.draw.circle(window.screen, (255, 128, 255), window.screenpos(X, y), F(s), 0)
def playvideo(name, loops=0): video = getvideo(name) rect = pygame.Rect(F((0, 0) + video.get_size()), center=window.screen.get_rect().center) video.set_display(window.screen, rect) video.play()
def draw(self): p = window.screenpos(self.X, self.y) r = F(max(10 * self.flife, 1)) pygame.draw.circle(window.screen, self.color, p, r, F(1))
kpressed = { keyname: any(kpressed[code] for code in codes) for keyname, codes in settings.keycodes.items() } if scene.toinit: scene.toinit.init() scene.toinit = None s = scene.current if not s: break if tconfirmfull: if tconfirmfull == 10: s.think(0, events, kpressed) s.draw() ptext.draw("Press space to\nconfirm fullscreen", fontsize=F(50), owidth=1, center=window.screen.get_rect().center, fontname="Orbitron", color="orange") tconfirmfull -= dt if tconfirmfull <= 0: settings.fullscreen = False window.init() tconfirmfull = 0 else: s.think(dt, events, kpressed) s.draw() if settings.DEBUG: if state.you: ptext.draw("%.4f, %.1f" % (state.you.X, state.you.y),
def draw(self): window.screen.fill(self.bcolor, F(self.rect))
def contains(self, pos): return F(self.rect).collidepoint(pos)
def draw(self): rect = F(pygame.Rect(self.rect).inflate(-10, -10)) ptext.drawbox(self.text, rect, fontname="Oregano", color="white")
from src.window import F ptext.FONT_NAME_TEMPLATE = "data/%s.ttf" if not settings.noaudio: pygame.mixer.init() window.init() play.init() clock = pygame.time.Clock() playing = True while playing: dt = 0.001 * clock.tick(settings.maxfps) events = list(pygame.event.get()) for event in events: if event.type == QUIT: playing = False if event.type == KEYDOWN and event.key == K_ESCAPE: playing = False if event.type == KEYDOWN and event.key == K_F12: pygame.image.save(window.screen, "screenshot.png") play.think(dt, events) play.draw() ptext.draw("%.1ffps" % clock.get_fps(), fontname="Oregano", fontsize=F(32), bottomright=window.screen.get_rect().bottomright, color="white") pygame.display.flip() pygame.quit()
def drawmap(): global fullmap, grid w = F(420) scale = F(200) / state.R if fullmap is None or fullmap.get_size() != (w, w): fullmap = pygame.Surface((w, w)).convert_alpha() grid = pygame.Surface((w, w)).convert() grid.fill((0, 0, 0)) p0 = w // 2, w // 2 for filament in state.worlddata["filaments"]: ps = [ window.windowpos(X, y, w, w, 0, 0, scale) for X, y in filament ] pygame.draw.lines(grid, (40, 40, 0), False, ps, F(6)) for r in range(25, state.R + 25, 25): pygame.draw.circle(grid, (10, 40, 10), p0, int(scale * r), F(1)) pygame.draw.circle(grid, (200, 0, 0), p0, int(scale * state.R), F(1)) pygame.draw.circle(grid, (200, 0, 0), p0, int(scale * state.Rcore), F(1)) for j in range(48): r0 = 25 * (8 if j % 2 else 4 if j % 4 else 2 if j % 8 else 1) X = math.tau * j / 48 p1 = window.windowpos(X, r0, w, w, 0, 0, scale) p2 = window.windowpos(X, state.R, w, w, 0, 0, scale) pygame.draw.line(grid, (10, 40, 10), p1, p2, F(1)) ptext.draw("The Charybdis\nAnomaly", fontname="Exo", fontsize=F(19), bottomleft=F(10, 410), owidth=2, surf=grid) ptext.draw("OUTER HORIZON", fontname="Exo", fontsize=F(14), center=F(70, 70), angle=45, color=(200, 0, 0), owidth=2, surf=grid) ptext.draw("OUTER HORIZON", fontname="Exo", fontsize=F(14), center=F(420 - 70, 70), angle=-45, color=(200, 0, 0), owidth=2, surf=grid) ptext.draw("OUTER HORIZON", fontname="Exo", fontsize=F(14), center=F(420 - 70, 420 - 70), angle=45, color=(200, 0, 0), owidth=2, surf=grid) ptext.draw("DATA\nHORIZON", fontname="Exo", fontsize=F(14), center=F(210, 210), color=(200, 0, 0), owidth=2, surf=grid) ptext.draw("DANGER", fontname="Exo", fontsize=F(14), center=F(160, 126), angle=-5, color=(100, 100, 0), owidth=2, surf=grid) ptext.draw("DANGER", fontname="Exo", fontsize=F(14), center=F(270, 244), angle=6, color=(100, 100, 0), owidth=2, surf=grid) ptext.draw("DANGER", fontname="Exo", fontsize=F(14), center=F(295, 70), angle=-70, color=(100, 100, 0), owidth=2, surf=grid) grid.set_alpha(180) window.screen.blit(grid, grid.get_rect(center=window.screen.get_rect().center)) fullmap.fill((0, 0, 0, 0)) objs = [] if 0.001 * pygame.time.get_ticks() % 0.5 < 0.25: objs += [(state.you, (200, 200, 200), False)] objs += [(g, (200, 0, 200), g.isvisible()) for g in state.goals] for obj, color, outline in objs: p = window.windowpos(obj.X, obj.y, w, w, 0, 0, scale) pygame.draw.circle(fullmap, color, p, F(2)) if outline: pygame.draw.circle(fullmap, color, p, F(5), F(1)) pygame.draw.circle(fullmap, color, p, F(8), F(1)) name = "YOU" if obj is state.you else { "Payload": "DATA CORE", "BatesShip": "DISTRESS\nCALL", "Convergence": "???", }[obj.__class__.__name__] ptext.draw(name, fontname="Exo", fontsize=F(12), owidth=2, surf=fullmap, color=color, centerx=p[0], top=p[1] + F(1)) pygame.draw.rect(fullmap, (255, 255, 255, 120), (0, 0, w, w), F(3)) window.screen.blit( fullmap, fullmap.get_rect(center=window.screen.get_rect().center))
def draw(self): p = window.screenpos(self.X, self.y) for d in (10, 20, 30): r = F(max(1, abs(40 * self.flife - d))) pygame.draw.circle(window.screen, (255, 255, 127), p, r, F(1))