def think(dt, events, mousepos): global mpos, cursor, point sound.playmusic("equip") if settings.pauseondialog and state.state.playing: dialog.think(dt) for event in events: if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and state.state.tline > 0.5: dialog.advance() dt = 0 point = pointat(mousepos) for event in events: if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: scene.pop() gamescene.makebuttons() if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: handleclick() if event.type == pygame.MOUSEBUTTONDOWN and event.button == 2: cursor = None mpos = mousepos dialog.think(dt) for b in buttons: if b.name.startswith("buy"): cname = "conduit-" + b.name[3:] b.text = "Buy: $%d\nAvail: %d" % (settings.modulecosts[cname], state.state.unused[cname]) b.makeimg() for q in state.state.quests: q.think(dt)
def think(dt, events, mpos): for event in events: if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: if buttons[0].within(mpos): play() if buttons[1].within(mpos): quit() sound.playmusic("title")
def think(dt, events, mpos): sound.playmusic("boss" if state.state.bossmode else "travel") if settings.pauseondialog and state.state.playing: dialog.think(dt) for event in events: if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and state.state.tline > 0.5: dialog.advance() dt = 0 for event in events: if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: handleclick(event.pos) if event.type == pygame.KEYDOWN and event.key == pygame.K_F1 and settings.DEBUG: scene.push(buildscene) if event.type == pygame.KEYDOWN and event.key == pygame.K_F2 and settings.DEBUG: state.state.you.x = state.state.mother.x state.state.you.y = state.state.mother.y if event.type == pygame.KEYDOWN and event.key == pygame.K_F3 and settings.DEBUG: state.state.bank += 1 if event.type == pygame.KEYDOWN and event.key == pygame.K_F4 and settings.DEBUG: state.state.bank += 10 if event.type == pygame.KEYDOWN and event.key == pygame.K_F5 and settings.DEBUG: state.state.bank += 100 global mapmode mapmode = any(b.name == "scope" and b.within(mpos) for b in buttons) state.state.think(dt) vista.think(dt) dialog.think(dt) for b in buttons: b.think(dt) if state.state.mother.within((state.state.you.x, state.state.you.y)): if apart["mother"]: apart["mother"] = False scene.push(buildscene) state.state.you.x = state.state.mother.x state.state.you.y = state.state.mother.y state.state.you.allstop() else: apart["mother"] = True global shroud if shroud: alpha = shroud.get_alpha() alpha = int(alpha - 200 * dt) if alpha <= 0: shroud = None else: shroud.set_alpha(alpha) if not state.state.you.corpse.alive: import menuscene scene.pop() scene.push(menuscene)
def init(): glEnable(GL_COLOR_MATERIAL) glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE) glEnable(GL_NORMALIZE) lighting.init() hud.init() camera.init() cursor.tobuild = None global playing, ending, alpha, lastsave playing = True ending = False alpha = 0 lastsave = 0 sound.playmusic(info.music[settings.level])
def init(): glEnable(GL_COLOR_MATERIAL) glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE) glEnable(GL_NORMALIZE) lighting.init() state.init() hud.init() hud.menumode() camera.menuinit() global playing, alpha, selected playing = True alpha = 0 selected = None sound.playmusic(info.music["menu"]) state.R = 40
def start(): global ships, player, hazards, effects, projectiles, bosses, vyc, yc, zc global stage, substages, tstage global hpmax setmode("quest") tstage = 0 substages = legs[stage][:] setstage() player = ship.PlayerShip((0, yc, 0)) ships = [player] hpmax = 8 player.hp = hpmax if stage == 1: player.tcooldown = 0.4 player.cannons = [[0, 0, 0, 0]] elif stage == 2: player.tcooldown = 0.2 player.cannons = [ [0.4, 0, 0, 0], [-0.4, 0, 0, 0], ] elif stage == 3: player.tcooldown = 0.1 player.cannons = [ [0, 0, 0, 0], [-0.4, 0, -4, 0], [0, 0, 0, 0], [0.4, 0, 4, 0], ] elif stage == 4: player.tcooldown = 0.05 player.cannons = [ [0, 0, 0, 0], [0.6, 0, 6, 0], [-0.2, 0, -2, 0], [0.4, 0, 4, 0], [-0.4, 0, -4, 0], [0.2, 0, 2, 0], [-0.6, 0, -6, 0], ] player.jumps = 2 if stage >= 3 else 1 think(0) player.jump(1.4) sound.playmusic(tunes[(stage, atboss)])
def start(): global ships, player, hazards, effects, projectiles, bosses, vyc, yc, zc global stage, substages, tstage global hpmax setmode("quest") tstage = 0 substages = legs[stage][:] setstage() player = ship.PlayerShip((0, yc, 0)) ships = [player] hpmax = 8 player.hp = hpmax if stage == 1: player.tcooldown = 0.4 player.cannons = [[0,0,0,0]] elif stage == 2: player.tcooldown = 0.2 player.cannons = [ [0.4, 0, 0, 0], [-0.4, 0, 0, 0], ] elif stage == 3: player.tcooldown = 0.1 player.cannons = [ [0, 0, 0, 0], [-0.4, 0, -4, 0], [0, 0, 0, 0], [0.4, 0, 4, 0], ] elif stage == 4: player.tcooldown = 0.05 player.cannons = [ [0, 0, 0, 0], [0.6, 0, 6, 0], [-0.2, 0, -2, 0], [0.4, 0, 4, 0], [-0.4, 0, -4, 0], [0.2, 0, 2, 0], [-0.6, 0, -6, 0], ] player.jumps = 2 if stage >= 3 else 1 think(0) player.jump(1.4) sound.playmusic(tunes[(stage, atboss)])
def addboss(): global mode, bosses, atboss, ships setmode("boss") atboss = True sound.playmusic(tunes[(stage, True)]) sound.playsound("addboss") save() ships = [player] player.hp = hpmax if stage == 1: bosses = [boss.Boss1((20, yc + 20, 0), 12)] ships.extend(bosses) ships.extend([ ship.Blockade(0, 4, 11, 0.7), ]) # bosses = [boss.Boss((20, yc + 20, 0), 8)] elif stage == 2: bosses = [boss.Balloon((0, yc, 4.5), 14)] ships.extend(bosses) elif stage == 3: bosses = [ boss.Bosslet((20, yc + 20, 0), 10), boss.Bosslet((-20, yc + 20, 0), 11), boss.Bosslet((-30, yc + 20, 0), 12), boss.Bosslet((30, yc + 20, 0), 13), ] ships.extend(bosses) ships.extend([ ship.Blockade(2, 3, 9.5, 1), ship.Blockade(-2, 3, 10.5, 1.2), ship.Blockade(0, 4, 12.5, 0.7), ]) elif stage == 4: bosses = [ boss.Ghost((0, yc + 20, 0), 15), ] ships.extend(bosses)
def think(dt): global started # Process local updates inp = userinput.get() if "quit" in inp: x, y = vista.p0() send("watch", x, y, True) stop() if "rotate" in inp: x, y, dA = inp["rotate"] if clientstate.canquest(x, y): send("qrequest", inp["mtile"]) elif clientstate.gridstate.canrotate(x, y): if vista.selected and dA == 3: send("deploy", (x, y), vista.selected) else: vista.SpinTile(clientstate.gridstate.getbasetile(x, y), dA) clientstate.gridstate.rotate(x, y, dA) send("rotate", (x, y), dA) if "krotate" in inp: x, y, dA = inp["krotate"] if clientstate.gridstate.canrotate(x, y): vista.SpinTile(clientstate.gridstate.getbasetile(x, y), dA) clientstate.gridstate.rotate(x, y, dA) send("rotate", (x, y), dA) if "kdragx" in inp and (inp["kdragx"] or inp["kdragy"]): vista.kdrag(dt * inp["kdragx"], dt * inp["kdragy"]) if "drag" in inp: if vista.drag(*inp["drag"]): send("watch", *vista.p0()) if "scroll" in inp: vista.zoom(inp["scroll"], inp["scrollpos"]) if "deploy" in inp: pos, device = inp["deploy"] if device in clientstate.you.unlocked: send("deploy", pos, device) if "cheat" in inp: send("cheat") if "screenshot" in inp: vista.screenshot() if "select" in inp and inp["select"]: if "qaccept" in inp["select"]: qinfo = menu.top().qinfo send("qaccept", qinfo["p"], ("solo" in inp["select"])) menu.pop() if inp["select"] == "cancel": menu.pop() if inp["select"] == "next": menu.advance() if not menu.stack: if settings.BOSS: pass elif "qaccept" in inp["select"]: if qinfo["t"] == "record": sound.playmusic("minima") else: sound.playmusic("cephalopod") else: sound.playmusic("space1990") if "hudclick" in inp: vista.handlehudclick(inp["hudclick"]) if clientstate.canunlock(inp["hudclick"]): send("unlock", inp["hudclick"]) vista.hudpoint = inp["hudpoint"] if "hudpoint" in inp else None # Process network updates for message in getmessages(): message = parsemessage(message) #log.debug("message: %s", message) mtype, args = message[0], message[1:] if mtype == "login": login(*args) elif mtype == "message": print "message from server:", args[0] if args[0] in ("Node successfully unlocked", "Node unlocking unsuccessful"): clientstate.qstatus = None menu.loadmessage(*args) elif mtype == "you": clientstate.you.setstate(*args) elif mtype == "watch": vista.watch(*args) elif mtype == "completestate": clientstate.gridstate.setstate(*args) started = True elif mtype == "state": clientstate.gridstate.applystate(*args) started = True elif mtype == "delta": #log.debug("delta %s", args[0]) clientstate.applydelta(*args) elif mtype == "monsters": #log.debug("monsters %s", args[0]) clientstate.handlemonsters(*args) elif mtype == "effects": #log.debug("effects %s", args[0]) clientstate.handleeffects(*args) elif mtype == "qinfo": #log.debug("quest info %s", args[0]) menu.loadqinfo(*args) elif mtype == "qupdate": clientstate.qupdate(*args) elif mtype == "train": menu.loadtraining(*args) clientstate.you.trained = args[0] elif mtype == "cutscene": menu.loadcutscene(*args) elif mtype == "unlockboss": bosscode = args[0] open(data.filepath("bosscode.txt"), "w").write("%s\n" % bosscode) menu.loadunlockboss(bosscode) elif mtype == "error": log.warning("ERROR FROM SERVER: %s", args[0])
def resume(): sound.playmusic(info.music["menu"])