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
genframe+=15 time.sleep(0.05) smap.remap() smap.show() framenum+=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]
def main(): global ev, inc, map, walkstep, walkframe, snake, genframe0, genframe1, framenum, apples, berrys, start, snakes, snake_state genframe0=genframe1=inc=framenum=0 snakes=[] snake_state="solid" walkstep=5 width, height = os.get_terminal_size() map=se.Map(height-1, width, " ") exec("level_"+mode+"_init()") snake=se.ObjectGroup([]) snake.symbol="#" start=Start(snake.symbol, snake_state) runner0=Start(snake.symbol, snake_state) runner1=Start(snake.symbol, snake_state) runner0.add(map, int(map.width/2), int(map.height/2)+1) runner1.add(map, int(map.width/2), int(map.height/2)+2) start.add(map, int(map.width/2), int(map.height/2)) snake.add_obs([start, runner0, runner1]) start.key_t="'w'" start.key_b="'s'" start.key_l="'a'" start.key_r="'d'" start.is_set=False snake.color="white" snake.walkframe=0 snake.walkstep=walkstep snakes.append(snake) apples=se.ObjectGroup([]) berrys=se.ObjectGroup([]) _i = 0 start.direction="t" map.show() while True: time0=time.time() while len(ev) > 0: for group in snakes: for arr in [[group.obs[0].key_t, "b", "t"], [group.obs[0].key_l, "r", "l"], [group.obs[0].key_b, "t", "b"], [group.obs[0].key_r, "l", "r"]]: if len(ev) != 0 and ev[0] == arr[0]: if group.obs[0].direction != arr[1] and not group.obs[0].is_set: group.obs[0].direction=arr[2] group.obs[0].is_set=True ev.pop(0) if "'m'" in ev: menu() mapresize() map.show(init=True) ev=[] elif "exit" in ev: ev=[] raise KeyboardInterrupt elif "'e'" in ev: ev=[] dead() elif len(ev) != 0 and _i == 0: _i = 1 elif len(ev) != 0 and _i == 1: ev.pop(0) _i = 0 start.oldx=start.oldy=0 for group in snakes: if group.walkframe+group.walkstep == framenum: oldx=group.obs[0].x oldy=group.obs[0].y if group.obs[0].direction == "t": group.obs[0].set(group.obs[0].x, group.obs[0].y-1) elif group.obs[0].direction == "b": group.obs[0].set(group.obs[0].x, group.obs[0].y+1) elif group.obs[0].direction == "l": group.obs[0].set(group.obs[0].x-1, group.obs[0].y) elif group.obs[0].direction == "r": group.obs[0].set(group.obs[0].x+1, group.obs[0].y) if len(group.obs) == 0: dead() group.obs[0].oldx=oldx group.obs[0].oldy=oldy for ob in group.obs[1:]: ob.oldx=ob.x ob.oldy=ob.y ob.set(oldx, oldy) oldx=ob.oldx oldy=ob.oldy group.walkframe+=group.walkstep group.obs[0].is_set=False exec("level_"+mode+"()") mapresize() map.show() time1=time.time()-time0 time.sleep(0.01-(time1 if time1 < 0.01 else 0.01)) framenum+=1
home=str(Path.home()) Path(home+"/.cache/scrape").mkdir(parents=True, exist_ok=True) 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)
#!/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)
# Because of some wierd windows shit this is required to let colors work os.system("") # Some vars luisframe = 0 luisview = "r" framenum = 0 bullet_num = 0 bullets = [] ev = ev2 = 0 obcount = 0 # Adding Maps map = se.Map( width=200, background=" " ) # Maps are kind of the "playground" which you can add Objects and Groups to smap = se.Submap(map, 0, 0) # This one is just a small part of the real (map) Map menumap = se.Map(background=" ") howtomap = se.Map(background=" ") # Defining the "action" function for the Pad class wich is a modified Object class, which is triggert, when another Object is in the same spot as the Object it self class Pad(se.Object): def action(self, ob): ob.remove() # Same as above, but the player is set to the middle of the map when he bumps into an solid Object class Player(se.Object):
#!/usr/bin/env python3 import scrap_engine as se import time, os, threading, sys os.system("") width, height = os.get_terminal_size() t = ev = v = 0 g = 0.015 map = se.Map(height - 1, 1000, " ") smap = se.Submap(map, 0, 0) block = se.Object("#") panel = se.Square("#", 10, 1) ground = se.Square("#", map.width, 5) player = se.Object("t") h = se.Text("00 00") block.add(map, 200, map.height - 6) panel.add(map, 100, map.height - 10) ground.add(map, 0, map.height - 5) player.add(map, round(smap.width / 2), round(map.height / 2)) h.add(smap, 0, 0) def on_press(key): global ev ev = str(key) if sys.platform == "linux": # Use another (not on xserver relying) way to read keyboard input, to make this shit work in tty or via ssh, where no xserver is available