def main(): global avr, tcount os.system("") b_map = se.Map(background=" ") text = se.Text("0") avr = se.Text("0") rectangle = se.Square('\033[34ma\033[0m', 50, 10) text.add(b_map, round((b_map.width-len(text.text))/2-10), round(b_map.height/2)-1) avr.add(b_map, round((b_map.width-len(text.text))/2-10), round(b_map.height/2)) rectangle.add(b_map, 0, 0) tcount = 0 times = 0 time2 = 0 b_map.show() while True: time0 = time.time() times += time2 for ob in rectangle.obs: ob.set(random.choice([ob.x, ob.x+1, ob.x-1]), random.choice([ob.y, ob.y+1, ob.y-1])) text.rechar(str(time2)) avr.rechar(str(times/tcount if tcount != 0 else 1)) b_map.show() tcount += 1 time2 = time.time()-time0
def effect(self): self.ob.ico.map.outp.outp( f'{self.ob.name}({"you" if self.ob.player else "enemy"}) is still ' ) self.ob.ico.map.outp.append( se.Text(self.name, esccode=self.str_esccode, state="float"), se.Text(" and can\'t attack!", state="float")) time.sleep(0.5) return 1
def remove(self): if random.randint(0, self.rem_chance) == 0: self.ob.ico.map.outp.outp( f'{self.ob.name}({"you" if self.ob.player else "enemy"}) isn\'t ' ) self.ob.ico.map.outp.append( se.Text(self.name, esccode=self.str_esccode, state="float"), se.Text(" anymore!", state="float")) i = self.ob.effects.index(self) del self.ob.effects[i] self.cleanup(i) self.ob = None time.sleep(2)
def __init__(self, infotext, introtext, text, max_len, map=None): height = len(infotext.split("\n")) + 3 width = sorted([len(i) for i in infotext.split("\n")] + [len(introtext) + 1 + max_len])[-1] + 4 super(InfoBox, self).__init__(height, width) self.map = map self.infotext = se.Text(infotext) self.introtext = se.Text(introtext) self.text = se.Text(text) self.add_ob(self.infotext, 2, 1) self.add_ob(self.introtext, 2, len(infotext.split("\n")) + 1) self.add_ob(self.text, self.introtext.rx + len(introtext) + 1, self.introtext.ry)
def __init__(self, text, map=None): height = len(text.split("\n")) + 2 width = sorted([len(i) for i in text.split("\n")])[-1] + 4 super().__init__(height, width) self.text = se.Text(text) self.add_ob(self.text, 2, 1) self.map = map
def add(self, ob): if all(type(i) is not type(self) for i in ob.effects): self.ob = ob self.ob.effects.append(self) self.add_label() self.ob.ico.map.outp.rechar( f'{ob.name}({"you" if ob.player else "enemy"}) is now ') self.ob.ico.map.outp.append( se.Text(self.name, esccode=self.str_esccode, state="float"), se.Text("!", state="float")) else: ob.ico.map.outp.rechar( f'{ob.name}({"you" if ob.player else "enemy"}) is allready ') ob.ico.map.outp.append( se.Text(self.name, esccode=self.str_esccode, state="float"), se.Text("!", state="float")) time.sleep(2)
def __init__(self, height, width, name="", info=""): super().__init__(height, width) self.frame = se.Frame(width=width, height=height, corner_chars=["┌", "┐", "└", "┘"], horizontal_chars=["─", "─"], vertical_chars=["│", "│"], state="float") self.inner = se.Square(char=" ", width=width - 2, height=height - 2, state="float") self.name_label = se.Text(name, state="float") self.info_label = se.Text(info, state="float") # adding self.add_ob(self.frame, 0, 0) self.add_ob(self.inner, 1, 1) self.add_ob(self.name_label, 2, 0) self.add_ob(self.info_label, 2, self.height - 1)
os.system("") width, height = os.get_terminal_size() t=ev=v=0 g=0.015 panelindex=0 framenum=0 genframe=0 map=se.Map(height-1, width+12, " ") smap=se.Submap(map, 0, 0) player=se.Object("t") block=PanelItem("#") panel=Panel("#", 10, 1, ob_class=PanelItem) ground=se.Square("#", map.width, 5) h=se.Text("00 00") player.add(map, round(smap.width/2), round(map.height/2)) block.add(map, map.width-11, map.height-6) panel.add(map, map.width-11, map.height-10) ground.add(map, 0, map.height-5) h.add(smap, 0, 0) moving=[ob for ob in panel.obs]+[block] recognising=threading.Thread(target=recogniser) recognising.daemon=True recognising.start() smap.remap() smap.show(init=True) main()
Path(home+"/.cache/scrape/scrape").touch(exist_ok=True) # reads mode from file data={i: j for i, j in zip(modes+["currend_mode"], [0 for i in modes]+[mode])} with open(home+"/.cache/scrape/scrape", "r") as file: exec("global data_from_file; "+file.read()) for i in modes+["currend_mode"]: if i not in data: data[i]=0 if i != "currend_mode" else "normal" with open(home+"/.cache/scrape/scrape", "w+") as file1: file1.write("data="+str(data)) mode=data["currend_mode"] if data["currend_mode"] in modes else "normal" # objects for dead deadmap=se.Map(background=" ") deadbox=se.Box(13, 28) deadtext=se.Text("You dead!") scoretext=se.Text("You scored 0 points") highscoretext=se.Text("Highscore: 0") deadmenutext0=se.Text("Mode: "+mode) deadmenutext1=se.Text("Try again") deadmenutext2=se.Text("Exit") deadmenuind=se.Object("*") deadbox.add_ob(deadtext, 9, 0) deadbox.add_ob(scoretext, int((deadbox.width-len(scoretext.text))/2), 2) deadbox.add_ob(highscoretext, int((deadbox.width-len(highscoretext.text))/2), 3) deadbox.add_ob(deadmenutext0, int((deadbox.width-len(deadmenutext0.text))/2), 7) deadbox.add_ob(deadmenutext1, 9, 9) deadbox.add_ob(deadmenutext2, 11, 11) deadbox.add_ob(deadmenuind, 7, 9) deadbox.add(deadmap, int((deadmap.width-deadbox.width)/2), 1+int((deadmap.height-deadbox.height)/2))
def __init__(self, name, rem_chance, str, str_esccode="", ob=None): self.name = name self.rem_chance = rem_chance self.str_esccode = str_esccode self.label = se.Text(str, state="float", esccode=str_esccode) self.ob = ob
#!/usr/bin/python3 import scrap_engine as se map = se.Map(background=" ") t = se.Text("Hello") t.add(map, 0, 0) k = se.Text(" You", esccode="\033[31m") t += k map.show()
def gen_wiki(): with open("Changelog.md", "r") as file: ver = file.readline() md_str = f"""v{ver} # Pokete wiki This wiki/documentation is a compilation of all Poketes/attacks/types present in the Pokete game. This wiki can be generated using ```$ gen-wiki.py```. ## Table of contents 1. [Poketes](#poketes) """ # Table of contents for j, poke in enumerate(sorted([i for i in pokes][1:])): md_str += f""" {j+1}. [{pokes[poke]["name"]}](#{poke})\n""" md_str += "2. [Attacks](#attacks)\n" for j, atc in enumerate(sorted(attacks)): md_str += f""" {j+1}. [{attacks[atc]["name"]}](#{atc.replace("_", "-")})\n""" md_str += """3. [Types](#types) 4. [Items](#items) """ for j, item in enumerate(sorted(items)): md_str += f""" {j+1}. [{items[item]["pretty_name"]}](#{item.replace("_", "-")})\n""" # Poketes md_str += """ ## Poketes In the following all Poketes with their attributes are displayed. """ for poke in sorted([i for i in pokes][1:]): evolve_txt = f"""- Evolves to [{pokes[pokes[poke]["evolve_poke"]]["name"]}](#{pokes[poke]["evolve_poke"]}) at level {pokes[poke]["evolve_lvl"]}""" if pokes[poke]["evolve_poke"] != "" else "- Does not evolve" md_attacks = "" for atc in pokes[poke]["attacks"]: md_attacks += f"""\n + [{attacks[atc]["name"]}](#{atc.replace("_", "-")})""" # ico map = se.Map(4, 11, background=" ") for ico in pokes[poke]["ico"]: se.Text(ico["txt"], state="float", ignore=" ").add(map, 0, 0) ico = "" for arr in map.map: line = "" for i in arr: line += i ico += line+"\n" md_str += f""" ### {pokes[poke]["name"]} {pokes[poke]["desc"]} ``` {ico} ``` - Type: [{pokes[poke]["type"].capitalize()}](#types) - Health points: {pokes[poke]["hp"]} - Attack factor: {pokes[poke]["atc"].replace("self.lvl()", "level")} - Defense factor: {pokes[poke]["defense"].replace("self.lvl()", "level")} - Initiative: {pokes[poke]["initiative"].replace("self.lvl()", "level")} - Missing chance: {pokes[poke]["miss_chance"]} - Rarity: {pokes[poke]["rarity"]} - Loosing experience: {pokes[poke]["lose_xp"]} - Attacks:{md_attacks} {evolve_txt} """ # Attacks md_str += """ ## Attacks Those are all attacks present in the game. """ for atc in sorted(attacks): md_str += f""" ### {attacks[atc]["name"]} {attacks[atc]["desc"]} - Type: [{attacks[atc]["type"].capitalize()}](#types) - Minimum Level: {attacks[atc]["min_lvl"]} - Attack factor: {attacks[atc]["factor"]} - Missing chance: {attacks[atc]["miss_chance"]} - Attack points: {attacks[atc]["ap"]} """ # Types md_str += """ ## Types Those are all the Pokete/Attack types that are present in the game with all their (in)effectivities against other types. Type|Effective against|Ineffective against ---|---|--- """ for type in types: effective = "" for i in types[type]["effective"]: effective += i.capitalize()+(", " if i != types[type]["effective"][-1] else "") ineffective = "" for i in types[type]["ineffective"]: ineffective += i.capitalize()+(", " if i != types[type]["ineffective"][-1] else "") md_str += f"{type.capitalize()}|{effective}|{ineffective}\n" # Items md_str += """ ## Items Those are all items present in the game, that can be traded or found. """ for item in sorted(items): md_str += f""" ### {items[item]["pretty_name"]} {items[item]["desc"]} - Price: {items[item]["price"]} - Can be used in fights: {"Yes" if items[item]["fn"] != None else "No"} """ # writing to file with open("wiki.md", "w+") as file: file.write(md_str)
exec("bullets.append(bullet" + str(bullet_num) + ")") # Creating Objects lui = se.Object( char="L") # Objects are just objects that can be added to a map rock = se.Object(char="A") menuind = se.Object("*") player = Player(char="T") player0 = Player(char="F") pad = Pad( char="i", state="float" ) # The state="float" means that other Objects can be placed over it, default is "solid" testob = se.Object(char="t") testob2 = se.Object(char="t") testtext = se.Text("Hey!") box = se.Box(10, 10) box.add_ob(testob, 5, 5) box.add_ob(testob2, 6, 6) box.add_ob(testtext, 7, 7) box.add(map, 100, 10) # Creating Groups menutext1 = se.Text( "Resume", float) # The Text class creates a Group with the text in it menutext2 = se.Text("How to play", float) menutext3 = se.Text("Exit", float) howtotext = se.Text( "How to play this game ou ask?\nIf you haven't already understood,\nyou can move your character with w, a, s and d.\nTo open the menu press m", float) text = se.Text("hello", float, esccode="\033[1m")