def start(): global running while running: if player.data['name'] is None: print( 'Type one of the following commands: save, load, create, exit') cmd = str(input()) if cmd == 'load': player.data = PlayerData.load() print(player.data) if cmd == 'create': create_account() if cmd == 'exit': running = False else: if player.data['current_room'] == 'shop': print( 'Type one of the following commands: inspect item_name, heal, battle, shop, save, exit' ) else: print( 'Type one of the following commands: heal, battle, shop, save, exit' ) cmd = str(input()) if cmd == 'save': PlayerData.save(player) if cmd == 'exit': running = False if cmd == 'heal': player.restore_hp(1000) if cmd == 'battle': enemy = Enemy() enemy.data['current_hp'] = enemy.data['max_hp'] enemy.data['name'] = 'Skeleton' print(enemy.data) Battle.render_battle(player, enemy) # del enemy # print('test') if cmd == 'shop': player.data['current_room'] = 'shop' shop.get_items() if 'inspect' in cmd: cmds = cmd.split() item = cmds[1] shop_items = [item.name for item in shop.items] if item in shop_items: print(item) player.clamp_hp() render(player) if player.data['current_xp'] >= player.data['req_xp']: player.level_up() print('You leveled up!')
def main(): p = argparse.ArgumentParser('standalone RPC stub generator') p.add_argument('--input', '-i', type=argparse.FileType('r'), default=sys.stdin, help='interface specification') p.add_argument('--output', '-o', type=argparse.FileType('w'), default=sys.stdout, help='file to write output to') p.add_argument('--procedure', '-p', help='procedure to operate on ' '(defaults to the first available)') p.add_argument('--template', '-t', type=argparse.FileType('r'), required=True, help='template to use') opts = p.parse_args() # Parse the input specification. try: spec = parser.parse_to_ast(opts.input.read()) except parser.CAmkESSyntaxError as e: sys.stderr.write('syntax error: %s\n' % str(e)) return -1 # Find the procedure the user asked for. If they didn't explicitly specify # one, we just take the first. for obj in spec: if isinstance(obj, ast.Procedure): if opts.procedure is None or opts.procedure == obj.name: proc = obj break else: sys.stderr.write('no matching procedure found\n') return -1 # Simplify the CAmkES AST representation into a representation involving # strings and simpler objects. proc = simplify(proc) # Render the template. opts.output.write(render(proc, opts.template.read())) return 0
def main(): p = argparse.ArgumentParser('standalone RPC stub generator') p.add_argument('--input', '-i', type=argparse.FileType('r'), default=sys.stdin, help='interface specification') p.add_argument('--output', '-o', type=argparse.FileType('w'), default=sys.stdout, help='file to write output to') p.add_argument('--procedure', '-p', help='procedure to operate on ' \ '(defaults to the first available)') p.add_argument('--template', '-t', type=argparse.FileType('r'), required=True, help='template to use') opts = p.parse_args() # Parse the input specification. try: spec = parser.parse_to_ast(opts.input.read()) except parser.CAmkESSyntaxError as e: print >>sys.stderr, 'syntax error: %s' % str(e) return -1 # Find the procedure the user asked for. If they didn't explicitly specify # one, we just take the first. for obj in spec: if isinstance(obj, ast.Procedure): if opts.procedure is None or opts.procedure == obj.name: proc = obj break else: print >>sys.stderr, 'no matching procedure found' return -1 # Simplify the CAmkES AST representation into a representation involving # strings and simpler objects. proc = simplify(proc) # Render the template. print >>opts.output, render(proc, opts.template.read()) return 0
# render(ref_X, Tetras, shape=shape, filename='ref') # render(def_X, Tetras, shape=shape, filename='def') B, W = precompute(ref_X, Tetras) # Initialize velocities to 0 # V = [[0,0,0]] * len(ref_X) V = np.zeros((len(ref_X), 3)) filenames = [] for step in range(N_STEPS): # Update config (X) and new velocities (V) # return F for debugging F = update_XV(def_X, Tetras, V, B, W) if step % STEP_PER_FRAME == 0: print('Rendering ', step, '/', N_STEPS) filename = render(def_X, Tetras, F, shape, os.path.join('out', str(step))) filenames.append(filename) make_video(filenames)
#World initialization world = World(SCREEN_WIDTH, SCREEN_HEIGHT, LIMIT_FPS) #Make Player world.createObject(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2, '@', (255, 255, 255)) #Make NPC world.createObject(SCREEN_WIDTH // 2 - 5, SCREEN_HEIGHT // 2, '@', (255, 255, 0)) #Make Map world.createMap(MAP_WIDTH, MAP_HEIGHT) #Main Game Loop while not tdl.event.is_window_closed(): #Draw all objects render(world, color_dark_wall, color_dark_ground) #Flush screen every frame, required for tdl loops tdl.flush() #Erase objects old locations for obj in world.getObjects(): obj.clear(world.console) #Read input and close game if escape is pressed exit_game = playerInput(tdl, world.getObjects()[0], world.getMap()) if exit_game: break
# 2. Precomputation and initialization B, W = precompute(X, T) X = Deform.translate_z(X, 0.2) V = np.zeros((len(X), 3)) # initialize velocities to 0 # 3. Main update loop now = 0 # current time frame_counter = 0 # number of frames rendered rendered_images = [] # filenames of rendered images while now < DURATION: # Update positions (X) and velocities (V) # return F for debugging F = update_XV(X, T, V, B, W, DELTA_TIME) # Render to image file video_sample_time = frame_counter / FPS * PLAYBACK_RATE # the time (in the simulation world) from which next frame is rendered if now >= video_sample_time: print("Rendering frame", frame_counter, "/", int(DURATION / DELTA_TIME / PLAYBACK_RATE * FPS)) filename = os.path.join("out", str(frame_counter) + ".png") render(X, T, filename=filename) rendered_images.append(filename) frame_counter += 1 now += DELTA_TIME print("Generating video...") make_video(rendered_images, os.path.join("out", "out.avi"), FPS)