def think(dt, events, kpressed): global t, Rfactor t += dt hud.think(dt) quest.think(dt) dialog.think(dt) background.think(dt, 4) for event in (events or []): if event.type == KEYUP and event.key == "go" and t > 8: scene.current = play scene.toinit = play background.wash() for ship in state.ships: ship.think(dt) for effect in state.effects: effect.think(dt) state.effects = [e for e in state.effects if e.alive] dt = min(dt, 0.1) window.camera.X0 = 0 factor = 0.003 * t**3 window.camera.y0 += (1 - math.exp(-factor * dt)) * (R - 80 - window.camera.y0) factor = 0.3 + 0.1 * t**2 Rfactor += (1 - math.exp(-factor * dt)) * (1 / 1600 - Rfactor) window.camera.R = window.sy * Rfactor
def think(dt, events, kpressed): global t, Rfactor t += dt hud.think(dt) quest.think(dt) dialog.think(dt) background.think(dt, 4) for event in (events or []): if event.type == KEYUP and event.key == "go" and t > 8: scene.current = play scene.toinit = play background.wash() for ship in state.ships: ship.think(dt) for effect in state.effects: effect.think(dt) state.effects = [e for e in state.effects if e.alive] dt = min(dt, 0.1) window.camera.X0 = 0 factor = 0.003 * t ** 3 window.camera.y0 += (1 - math.exp(-factor * dt)) * (R - 80 - window.camera.y0) factor = 0.3 + 0.1 * t ** 2 Rfactor += (1 - math.exp(-factor * dt)) * (1 / 1600 - Rfactor) window.camera.R = window.sy * Rfactor
def think(dt, events, kpressed): global t t += dt background.think(dt, 4) for event in (events or []): if event.type == KEYUP and event.key == "go": scene.current = None
def think(dt, events, kpressed): global todraw, tplay dialog.think(dt) background.think(dt, 2) sound.think(dt) tplay += dt state.you.y -= 1 * dt if tplay > 7 and state.you.alive: state.you.die() state.effects.append( thing.CutsceneTeleport(X=0, y=state.you.y, X1=0, y1=window.camera.y0 - 20, color="gray")) while tspawn and tplay > tspawn[0]: tspawn.pop(0) state.effects.append( thing.CutsceneTeleport(X=random.gauss(0, 20 / window.camera.y0), y=random.gauss(window.camera.y0 - 14, 20), X1=random.gauss(0, 20 / window.camera.y0), y1=random.gauss(window.camera.y0 - 14, 20))) if tplay > 30: from src import scene from src.scenes import endtitle scene.current = endtitle scene.toinit = endtitle neffects = [] for effect in state.effects: effect.think(dt / 4) if effect.alive: neffects.append(effect) else: effect.die() state.effects = neffects
def think(dt, events, kpressed): global todraw, tplay dialog.think(dt) background.think(dt) sound.think(dt) tplay += dt background.flowt += dt * 2 state.you.y -= 1 * dt if tplay > 7 and state.you.alive: state.you.die() state.effects.append( thing.SlowTeleport(X=0, y=state.you.y, X1=0, y1=window.camera.y0 - 20)) if tplay > 10 and random.random() / (0.1 * tplay) < dt: state.effects.append( thing.SlowTeleport(X=random.gauss(0, 20 / window.camera.y0), y=random.gauss(window.camera.y0 - 14, 20), X1=random.gauss(0, 20 / window.camera.y0), y1=random.gauss(window.camera.y0 - 14, 20))) if tplay > 30: from src import scene from src.scenes import endtitle scene.current = endtitle scene.toinit = endtitle neffects = [] for effect in state.effects: effect.think(dt / 4) if effect.alive: neffects.append(effect) else: effect.die() state.effects = neffects
def think(dt, events, kpressed): global todraw, tplay dialog.think(dt) background.think(dt, 2) sound.think(dt) tplay += dt state.you.y -= 1 * dt if tplay > 7 and state.you.alive: state.you.die() state.effects.append( thing.CutsceneTeleport(X = 0, y = state.you.y, X1 = 0, y1 = window.camera.y0 - 20, color = "gray") ) while tspawn and tplay > tspawn[0]: tspawn.pop(0) state.effects.append(thing.CutsceneTeleport( X = random.gauss(0, 20 / window.camera.y0), y = random.gauss(window.camera.y0 - 14, 20), X1 = random.gauss(0, 20 / window.camera.y0), y1 = random.gauss(window.camera.y0 - 14, 20) )) if tplay > 30: from src import scene from src.scenes import endtitle scene.current = endtitle scene.toinit = endtitle neffects = [] for effect in state.effects: effect.think(dt/4) if effect.alive: neffects.append(effect) else: effect.die() state.effects = neffects
def think(dt, events, kpressed): global todraw, tplay dialog.think(dt) background.think(dt) sound.think(dt) tplay += dt background.flowt += dt * 2 state.you.y -= 1 * dt if tplay > 7 and state.you.alive: state.you.die() state.effects.append( thing.SlowTeleport(X = 0, y = state.you.y, X1 = 0, y1 = window.camera.y0 - 20) ) if tplay > 10 and random.random() / (0.1 * tplay) < dt: state.effects.append(thing.SlowTeleport( X = random.gauss(0, 20 / window.camera.y0), y = random.gauss(window.camera.y0 - 14, 20), X1 = random.gauss(0, 20 / window.camera.y0), y1 = random.gauss(window.camera.y0 - 14, 20) )) if tplay > 30: from src import scene from src.scenes import endtitle scene.current = endtitle scene.toinit = endtitle neffects = [] for effect in state.effects: effect.think(dt/4) if effect.alive: neffects.append(effect) else: effect.die() state.effects = neffects
def think(dt, events, kpressed): global todraw, tplay hud.think(dt) quest.think(dt) dialog.think(dt) background.think(dt) sound.think(dt) if playing: tplay += dt background.flowt += dt * 4 if tplay > 3: dialog.play("convo9") if tplay > 6: background.wash() from src import scene from src.scenes import play scene.current = play state.you.tflash = settings.tcutsceneinvulnerability return nbubble = int(dt * 30) + (random.random() < dt * 30 % 1) for _ in range(nbubble): X = random.gauss(state.you.X, 30 / state.you.y) y = random.gauss(state.you.y, 30) if y < state.R - 10: state.effects.append(thing.Bubble(X = X, y = y)) todraw = [] scollide = [] hcollide = [] nships = [] for ship in state.ships: if not window.camera.near(ship): nships.append(ship) continue ship.think(dt) if ship.alive: nships.append(ship) if window.camera.on(ship): todraw.append(ship) else: ship.die() if ship is state.you: regenerate() state.ships = nships nobjs = [] for obj in state.objs: if not window.camera.on(obj): nobjs.append(obj) continue obj.think(dt) if obj.alive: nobjs.append(obj) todraw.append(obj) else: obj.die() state.obj = nobjs for hazard in state.hazards: if not window.camera.near(hazard): continue hazard.think(dt) todraw.append(hazard) if window.camera.on(hazard): hcollide.append(hazard) state.obj = nobjs neffects = [] for effect in state.effects: effect.think(dt) if effect.alive: todraw.append(effect) neffects.append(effect) else: effect.die() state.effects = neffects window.camera.follow(state.you) window.camera.think(dt)
def think(dt, events, kpressed): global todraw, tplay hud.think(dt) quest.think(dt) dialog.think(dt) background.think(dt) sound.think(dt) if playing: tplay += dt background.flowt += dt * 4 if tplay > 3: dialog.play("convo9") if tplay > 6: background.wash() from src import scene from src.scenes import play scene.current = play state.you.tflash = settings.tcutsceneinvulnerability return nbubble = int(dt * 30) + (random.random() < dt * 30 % 1) for _ in range(nbubble): X = random.gauss(state.you.X, 30 / state.you.y) y = random.gauss(state.you.y, 30) if y < state.R - 10: state.effects.append(thing.Bubble(X=X, y=y)) todraw = [] scollide = [] hcollide = [] nships = [] for ship in state.ships: if not window.camera.near(ship): nships.append(ship) continue ship.think(dt) if ship.alive: nships.append(ship) if window.camera.on(ship): todraw.append(ship) else: ship.die() if ship is state.you: regenerate() state.ships = nships nobjs = [] for obj in state.objs: if not window.camera.on(obj): nobjs.append(obj) continue obj.think(dt) if obj.alive: nobjs.append(obj) todraw.append(obj) else: obj.die() state.obj = nobjs for hazard in state.hazards: if not window.camera.near(hazard): continue hazard.think(dt) todraw.append(hazard) if window.camera.on(hazard): hcollide.append(hazard) state.obj = nobjs neffects = [] for effect in state.effects: effect.think(dt) if effect.alive: todraw.append(effect) neffects.append(effect) else: effect.die() state.effects = neffects window.camera.follow(state.you) window.camera.think(dt)
def think(dt, events, kpressed): global todraw kx = kpressed["right"] - kpressed["left"] ky = kpressed["up"] - kpressed["down"] dt0 = dt if kpressed["go"] and control: dt *= 0.3 hud.think(dt0) quest.think(dt) dialog.think(dt0) background.think(dt) sound.epicness = 2 - (state.you.y - 100) / 160 sound.think(dt) oldX, oldy = state.you.X, state.you.y if 1e10 * random.random() < dt: state.ships.append( thing.Skiff(X=random.uniform(0, math.tau), y=state.R, vx=random.uniform(-6, 6))) state.ships.append( thing.Beacon(X=random.uniform(0, math.tau), y=state.R, vx=random.uniform(-6, 6))) nbubble = int(dt * 30) + (random.random() < dt * 30 % 1) for _ in range(nbubble): X = random.gauss(state.you.X, 30 / state.you.y) y = random.gauss(state.you.y, 30) if y < state.R - 10: state.effects.append(thing.Bubble(X=X, y=y)) if sum(isinstance(effect, thing.BubbleChain) for effect in state.effects) < 10: for c in state.convergences: N = math.clamp((100 / window.distance(state.you, c))**2, 0.05, 1) nbubble = int(dt * N) + (random.random() < dt * N % 1) for _ in range(nbubble): X = random.gauss(state.you.X, 30 / state.you.y) y = random.gauss(state.you.y, 30) if state.Rcore < y < state.R - 20: state.effects.append( thing.BubbleChain(X=X, y=y, X0=c.X, y0=c.y)) for event in events: if event.type == KEYDOWN and event.key == "go": control.clear() control["cursor"] = state.you control["queue"] = {} control["qtarget"] = [state.you.X, state.you.y] control["t0"] = 0.001 * pygame.time.get_ticks() if event.type == KEYDOWN and event.key == "abort": if not state.you.significant: state.you.die() regenerate() if event.type == KEYUP: if not state.quickteleport and "queue" in control and event.key in ( "up", "left", "right", "down"): control["queue"][event.key] = 0 if event.type == KEYUP and event.key == "go" and "cursor" in control: if control["cursor"] is not state.you: state.effects.append( thing.Teleport(X=state.you.X, y=state.you.y, targetid=control["cursor"].thingid)) sound.play("teleport") state.you = control["cursor"] elif 0.001 * pygame.time.get_ticks( ) - control["t0"] < settings.tactivate: state.you.deploy() control.clear() if kpressed["go"] and control: if any(kpressed[x] for x in ("left", "right", "up", "down")): control["t0"] = -1000 if state.quickteleport: control["qtarget"][ 0] += kx * dt0 * settings.vqteleport / control["qtarget"][1] control["qtarget"][1] += ky * dt0 * settings.vqteleport dx = math.Xmod(control["qtarget"][0] - state.you.X) * state.you.y dy = control["qtarget"][1] - state.you.y f = math.sqrt(dx**2 + dy**2) / settings.rqteleport if f > 1: dx /= f dy /= f control["qtarget"] = [ state.you.X + dx / state.you.y, state.you.y + dy ] retarget() else: q = control["queue"] for key in q: q[key] += dt0 if q[key] >= settings.jumpcombotime: dx = ("right" in q) - ("left" in q) dy = ("up" in q) - ("down" in q) jump(dx, dy) q.clear() break else: dvx = kx * dt * 20 dvy = ky * dt * 20 state.you.vx += dvx state.you.vy = min(state.you.vy + dvy, 0) todraw = [] scollide = [] hcollide = [] state.you.think(0) # Clear out any controls that should be overridden for convergence in state.convergences: if window.camera.near(convergence): convergence.think(dt) todraw.append(convergence) repopulating = (dt + state.you.t % 1) // 1 if repopulating: nships = [] for ship in state.ships: if not window.camera.on( ship) and ship is not state.you and not ship.significant: continue ship.think(dt) if ship.alive: nships.append(ship) todraw.append(ship) else: ship.die() state.ships = nships repopulateslice() else: nships = [] for ship in state.ships: if not window.camera.near(ship): nships.append(ship) continue ship.think(dt) if ship.alive: nships.append(ship) if window.camera.on(ship): todraw.append(ship) else: ship.die() state.ships = nships if not state.you.alive: regenerate() nobjs = [] for obj in state.objs: if not window.camera.on(obj): nobjs.append(obj) continue obj.think(dt) if obj.alive: nobjs.append(obj) todraw.append(obj) else: obj.die() state.obj = nobjs for hazard in state.hazards: if not window.camera.near(hazard): continue hazard.think(dt) todraw.append(hazard) if window.camera.on(hazard): hcollide.append(hazard) state.obj = nobjs # for filament in state.filaments: # filament.think(dt) neffects = [] for effect in state.effects: effect.think(dt) if effect.alive: todraw.append(effect) neffects.append(effect) else: effect.die() state.effects = neffects scollide = [state.you] for s in scollide: if not s.vulnerable(): continue for h in hcollide: if window.distance(h, s) < h.hazardsize: s.takedamage(h.dhp) if window.dbycoord((oldX, oldy), (state.you.X, state.you.y)) > settings.rqteleport + 10: clearfull() populatefull() if state.quickteleport and "qtarget" in control: X, y = control["qtarget"] dX = math.Xmod(X - state.you.X) dy = y - state.you.y window.camera.X0 = state.you.X + dX * 0.5 window.camera.y0 = state.you.y + dy * 0.5 window.camera.setlimits() else: window.camera.follow(state.you) window.camera.think(dt)
def think(dt, events, kpressed): global todraw kx = kpressed["right"] - kpressed["left"] ky = kpressed["up"] - kpressed["down"] dt0 = dt if kpressed["go"] and control: dt *= 0.3 hud.think(dt0) quest.think(dt) dialog.think(dt0) background.think(dt) sound.epicness = 2 - (state.you.y - 100) / 160 sound.think(dt) oldX, oldy = state.you.X, state.you.y if 1e10 * random.random() < dt: state.ships.append(thing.Skiff( X = random.uniform(0, math.tau), y = state.R, vx = random.uniform(-6, 6) )) state.ships.append(thing.Beacon( X = random.uniform(0, math.tau), y = state.R, vx = random.uniform(-6, 6) )) nbubble = int(dt * 30) + (random.random() < dt * 30 % 1) for _ in range(nbubble): X = random.gauss(state.you.X, 30 / state.you.y) y = random.gauss(state.you.y, 30) if y < state.R - 10: state.effects.append(thing.Bubble(X = X, y = y)) if sum(isinstance(effect, thing.BubbleChain) for effect in state.effects) < 10: for c in state.convergences: N = math.clamp((100 / window.distance(state.you, c)) ** 2, 0.05, 1) nbubble = int(dt * N) + (random.random() < dt * N % 1) for _ in range(nbubble): X = random.gauss(state.you.X, 30 / state.you.y) y = random.gauss(state.you.y, 30) if state.Rcore < y < state.R - 20: state.effects.append(thing.BubbleChain(X = X, y = y, X0 = c.X, y0 = c.y)) for event in events: if event.type == KEYDOWN and event.key == "go": control.clear() control["cursor"] = state.you control["queue"] = {} control["qtarget"] = [state.you.X, state.you.y] control["t0"] = 0.001 * pygame.time.get_ticks() if event.type == KEYDOWN and event.key == "abort": if not state.you.significant: state.you.die() regenerate() if event.type == KEYUP: if not state.quickteleport and "queue" in control and event.key in ("up", "left", "right", "down"): control["queue"][event.key] = 0 if event.type == KEYUP and event.key == "go" and "cursor" in control: if control["cursor"] is not state.you: state.effects.append( thing.Teleport(X = state.you.X, y = state.you.y, targetid = control["cursor"].thingid) ) sound.play("teleport") state.you = control["cursor"] elif 0.001 * pygame.time.get_ticks() - control["t0"] < settings.tactivate: state.you.deploy() control.clear() if kpressed["go"] and control: if any(kpressed[x] for x in ("left", "right", "up", "down")): control["t0"] = -1000 if state.quickteleport: control["qtarget"][0] += kx * dt0 * settings.vqteleport / control["qtarget"][1] control["qtarget"][1] += ky * dt0 * settings.vqteleport dx = math.Xmod(control["qtarget"][0] - state.you.X) * state.you.y dy = control["qtarget"][1] - state.you.y f = math.sqrt(dx ** 2 + dy ** 2) / settings.rqteleport if f > 1: dx /= f dy /= f control["qtarget"] = [state.you.X + dx / state.you.y, state.you.y + dy] retarget() else: q = control["queue"] for key in q: q[key] += dt0 if q[key] >= settings.jumpcombotime: dx = ("right" in q) - ("left" in q) dy = ("up" in q) - ("down" in q) jump(dx, dy) q.clear() break else: dvx = kx * dt * 20 dvy = ky * dt * 20 state.you.vx += dvx state.you.vy = min(state.you.vy + dvy, 0) todraw = [] scollide = [] hcollide = [] state.you.think(0) # Clear out any controls that should be overridden for convergence in state.convergences: if window.camera.near(convergence): convergence.think(dt) todraw.append(convergence) repopulating = (dt + state.you.t % 1) // 1 if repopulating: nships = [] for ship in state.ships: if not window.camera.on(ship) and ship is not state.you and not ship.significant: continue ship.think(dt) if ship.alive: nships.append(ship) todraw.append(ship) else: ship.die() state.ships = nships repopulateslice() else: nships = [] for ship in state.ships: if not window.camera.near(ship): nships.append(ship) continue ship.think(dt) if ship.alive: nships.append(ship) if window.camera.on(ship): todraw.append(ship) else: ship.die() state.ships = nships if not state.you.alive: regenerate() nobjs = [] for obj in state.objs: if not window.camera.on(obj): nobjs.append(obj) continue obj.think(dt) if obj.alive: nobjs.append(obj) todraw.append(obj) else: obj.die() state.obj = nobjs for hazard in state.hazards: if not window.camera.near(hazard): continue hazard.think(dt) todraw.append(hazard) if window.camera.on(hazard): hcollide.append(hazard) state.obj = nobjs # for filament in state.filaments: # filament.think(dt) neffects = [] for effect in state.effects: effect.think(dt) if effect.alive: todraw.append(effect) neffects.append(effect) else: effect.die() state.effects = neffects scollide = [state.you] for s in scollide: if not s.vulnerable(): continue for h in hcollide: if window.distance(h, s) < h.hazardsize: s.takedamage(h.dhp) if window.dbycoord((oldX, oldy), (state.you.X, state.you.y)) > settings.rqteleport + 10: clearfull() populatefull() if state.quickteleport and "qtarget" in control: X, y = control["qtarget"] dX = math.Xmod(X - state.you.X) dy = y - state.you.y window.camera.X0 = state.you.X + dX * 0.5 window.camera.y0 = state.you.y + dy * 0.5 window.camera.setlimits() else: window.camera.follow(state.you) window.camera.think(dt)
def think(dt, events, kpressed): kx = kpressed["right"] - kpressed["left"] ky = kpressed["up"] - kpressed["down"] dt0 = dt if kpressed["go"] and control: dt *= 0.3 hud.think(dt0) quest.think(dt) dialog.think(dt0) background.think(dt, 1) for event in events: if event.type == KEYDOWN and event.key == "go": control.clear() control["cursor"] = state.you control["queue"] = {} control["qtarget"] = [state.you.X, state.you.y] if event.type == KEYUP: if not state.quickteleport and "queue" in control and event.key in ( "up", "left", "right", "down"): control["queue"][event.key] = 0 if event.type == KEYUP and event.key == "go" and "cursor" in control: if control["cursor"] is not state.you: state.effects.append( thing.Teleport(X=state.you.X, y=state.you.y, targetid=control["cursor"].thingid)) sound.play("teleport") state.you = control["cursor"] control.clear() if kpressed["go"] and control: if state.quickteleport: control["qtarget"][ 0] += kx * dt0 * settings.vqteleport / control["qtarget"][1] control["qtarget"][1] += ky * dt0 * settings.vqteleport dx = math.Xmod(control["qtarget"][0] - state.you.X) * state.you.y dy = control["qtarget"][1] - state.you.y f = math.sqrt(dx**2 + dy**2) / settings.rqteleport if f > 1: dx /= f dy /= f control["qtarget"] = [ state.you.X + dx / state.you.y, state.you.y + dy ] retarget() else: q = control["queue"] for key in q: q[key] += dt0 if q[key] >= settings.jumpcombotime: dx = ("right" in q) - ("left" in q) dy = ("up" in q) - ("down" in q) jump(dx, dy) q.clear() break else: dvx = kx * dt * 20 dvy = ky * dt * 20 state.you.vx += dvx state.you.vy += dvy state.you.think(0) # Clear out any controls that should be overridden for ship in state.ships: ship.think(dt) dx = y0 * ship.X dy = ship.y - y0 f = math.sqrt(dx**2 + dy**2) / 15 if f > 1: ship.X /= f ship.y = y0 + dy / f ship.vx = 0 ship.vy = 0 for effect in state.effects: effect.think(dt) state.effects = [e for e in state.effects if e.alive] window.camera.X0 = 0 window.camera.y0 = y0 window.camera.R = window.sy / 32
sys.path.insert(1, sys.path[0] + "/..") from src import background, window, settings, state math.tau = 2 * math.pi window.init() class camera: X0 = 0 y0 = 100 R = 2 camera.y0 = state.R clock = pygame.time.Clock() playing = True while playing: dt = clock.tick(60) * 0.001 background.think(dt) background.flow(10 * dt) for event in pygame.event.get(): if event.type == KEYDOWN and event.key == K_ESCAPE: playing = False k = pygame.key.get_pressed() camera.X0 += 2 * dt * (k[K_RIGHT] - k[K_LEFT]) camera.y0 += 100 * dt * (k[K_UP] - k[K_DOWN]) background.draw(factor=12, camera=camera) pygame.display.flip()
from pygame.locals import * sys.path.insert(1, sys.path[0] + "/..") from src import background, window, settings, state math.tau = 2 * math.pi window.init() class camera: X0 = 0 y0 = 100 R = 2 camera.y0 = state.R clock = pygame.time.Clock() playing = True while playing: dt = clock.tick(60) * 0.001 background.think(dt) background.flow(10 * dt) for event in pygame.event.get(): if event.type == KEYDOWN and event.key == K_ESCAPE: playing = False k = pygame.key.get_pressed() camera.X0 += 2 * dt * (k[K_RIGHT] - k[K_LEFT]) camera.y0 += 100 * dt * (k[K_UP] - k[K_DOWN]) background.draw(factor = 12, camera = camera) pygame.display.flip()
def think(dt, events, kpressed): kx = kpressed["right"] - kpressed["left"] ky = kpressed["up"] - kpressed["down"] dt0 = dt if kpressed["go"] and control: dt *= 0.3 hud.think(dt0) quest.think(dt) dialog.think(dt0) background.think(dt, 1) for event in events: if event.type == KEYDOWN and event.key == "go": control.clear() control["cursor"] = state.you control["queue"] = {} control["qtarget"] = [state.you.X, state.you.y] if event.type == KEYUP: if not state.quickteleport and "queue" in control and event.key in ("up", "left", "right", "down"): control["queue"][event.key] = 0 if event.type == KEYUP and event.key == "go" and "cursor" in control: if control["cursor"] is not state.you: state.effects.append( thing.Teleport(X = state.you.X, y = state.you.y, targetid = control["cursor"].thingid) ) sound.play("teleport") state.you = control["cursor"] control.clear() if kpressed["go"] and control: if state.quickteleport: control["qtarget"][0] += kx * dt0 * settings.vqteleport / control["qtarget"][1] control["qtarget"][1] += ky * dt0 * settings.vqteleport dx = math.Xmod(control["qtarget"][0] - state.you.X) * state.you.y dy = control["qtarget"][1] - state.you.y f = math.sqrt(dx ** 2 + dy ** 2) / settings.rqteleport if f > 1: dx /= f dy /= f control["qtarget"] = [state.you.X + dx / state.you.y, state.you.y + dy] retarget() else: q = control["queue"] for key in q: q[key] += dt0 if q[key] >= settings.jumpcombotime: dx = ("right" in q) - ("left" in q) dy = ("up" in q) - ("down" in q) jump(dx, dy) q.clear() break else: dvx = kx * dt * 20 dvy = ky * dt * 20 state.you.vx += dvx state.you.vy += dvy state.you.think(0) # Clear out any controls that should be overridden for ship in state.ships: ship.think(dt) dx = y0 * ship.X dy = ship.y - y0 f = math.sqrt(dx ** 2 + dy ** 2) / 15 if f > 1: ship.X /= f ship.y = y0 + dy / f ship.vx = 0 ship.vy = 0 for effect in state.effects: effect.think(dt) state.effects = [e for e in state.effects if e.alive] window.camera.X0 = 0 window.camera.y0 = y0 window.camera.R = window.sy / 32