当前位置: 首页>>代码示例>>Python>>正文


Python World类代码示例

本文整理汇总了Python中World的典型用法代码示例。如果您正苦于以下问题:Python World类的具体用法?Python World怎么用?Python World使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了World类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: exitGame

 def exitGame(self):
     ImageManager.unloadSet("debug")
     AudioManager.unloadSfxSet("debug")
     World.cleanupCompletely()
     Globals.PLAYER = None
     pygame.mixer.music.fadeout(1000)
     if Globals.CURRENT_LEVEL == "one":
         Globals.CURRENT_LEVEL = "two"
         if Globals.LEVELS_BEAT < 1:
             Globals.LEVELS_BEAT = 1
     elif Globals.CURRENT_LEVEL == "two":
         Globals.CURRENT_LEVEL = "three"
         if Globals.LEVELS_BEAT < 2:
             Globals.LEVELS_BEAT = 2
     elif Globals.CURRENT_LEVEL == "three":
         Globals.CURRENT_LEVEL = "four"
         if Globals.LEVELS_BEAT < 3:
             Globals.LEVELS_BEAT = 3
     elif Globals.CURRENT_LEVEL == "four":
         Globals.CURRENT_LEVEL = "five"
         if Globals.LEVELS_BEAT < 4:
             Globals.LEVELS_BEAT = 4
     Globals.MINI_SUNS_INLVL = 0
     Globals.STATE = WinScreen.WinScreen()
     Globals.CHECKPOINT_SET = False
开发者ID:davidkoh316,项目名称:gyration_games,代码行数:25,代码来源:GameScreen.py

示例2: run

def run():
    global discount
    time.sleep(1)
    alpha = 1
    t = 1
    while True:
        # Pick the right action
        s = World.player
        max_act, max_val = max_Q(s)
        (s, a, r, s2) = do_action(max_act)

        # Update Q
        max_act, max_val = max_Q(s2)
        inc_Q(s, a, alpha, r + discount * max_val)

        # Check if the game has restarted
        t += 1.0
        if World.has_restarted():
            World.restart_game()
            time.sleep(0.01)
            t = 1.0

        # Update the learning rate
        alpha = pow(t, -0.1)

        # MODIFY THIS SLEEP IF THE GAME IS GOING TOO FAST.
        time.sleep(0.1)
开发者ID:cold-blue,项目名称:q_learning_demo,代码行数:27,代码来源:Learner.py

示例3: enter_entry

 def enter_entry(self):
     if not Globals.PLAYER is None:
         Globals.PLAYER.kill(False)
         Globals.PLAYER = None
         World.cleanupCompletely()
     Globals.CURRENT_LEVEL = "one"
     Globals.initSunTracker(True)
     Globals.PLAYER_MAX_HEALTH = 15
     SKILL_MAX_HEALTH = 0
     PLAYER_REGEN_TIME = 7
     PLAYER_DAMAGE = 5
     SKILL_DAMAGE = 0
     PLAYER_MAX_MP = 10
     PLAYER_SKILL = 0
     PLAYER_JUMP = 610.0
     SKILL_JUMP = 0
     ARROW_VELOCITY = 700.0
     ARROW_HITS = 1
     ARROW_DAMAGE = 2
     BOW_COOLDOWN = 0.7
     MAX_SKILL = 9
     MINI_SUNS = 0
     LEVELS_BEAT = 0
     SCORE = 0
     TIME = 120
     Globals.STATE = ControlScreen.ControlScreen()
开发者ID:davidkoh316,项目名称:gyration_games,代码行数:26,代码来源:MainScreen.py

示例4: generate_structure

 def generate_structure(self, structure, x):
     if structure["type"] == "column":
         height = random.randint(structure["minheight"], structure["maxheight"])
         for y in range(self.heights[x] - height, self.heights[x]):
             self.blocks[y][x] = World.get_block(structure["block"])
     elif structure["type"] == "json":
         structure_file = open(structure["location"])
         structure_json = json.load(structure_file)
         curr_y = self.heights[x] - len(structure_json["shape"])
         for line in structure_json["shape"]:
             curr_world_x = Convert.chunk_to_world(x, self)
             for char in line:
                 #find the right chunk
                 chunk = self #world.chunks[Convert.world_to_chunk(x)[1]]- can't really do this...
                 curr_chunk_x = Convert.world_to_chunk(curr_world_x)[0]
                 if curr_chunk_x < WIDTH:
                     if char == " ":
                         block = "water"
                     else:
                         block = structure_json["blocks"][char]
                     chunk.blocks[curr_y][curr_chunk_x] = World.get_block(block)
                 curr_world_x += 1
             curr_y += 1
         structure_file.close()
     elif structure["type"] == "other":
         #why did I write this?
         pass
开发者ID:rystills,项目名称:Oceania,代码行数:27,代码来源:Chunk.py

示例5: update

 def update(self, time):
     if Globals.WIN:
         if Globals.CURRENT_LEVEL == "five":
             if self.bossWinTimer > 0.0:
                 self.bossWinTimer -= time
             else:
                 self.exitFinal()
                 return
         else:
             if Globals.TIME > 0:
                 Globals.SCORE = Globals.SCORE + 10 * int(Globals.TIME)
             self.exitGame()
             return
     if Globals.PLAYER.isDead:
         self.timer -= time
         if self.timer <= 0:
             self.deadScreen()
             return
     if InputManager.getPressed("esc"):
         self.exitScreen()
         return
     Globals.TIME = Globals.TIME - time
     World.update(time)
     if not Globals.CHECKPOINT_SET and\
             Globals.CURRENT_LEVEL in Globals.CHECKPOINT_POS:
         if Globals.PLAYER.rect.x > Globals.getCheckpointPos()[0]:
             Globals.CHECKPOINT_SET = True
开发者ID:davidkoh316,项目名称:gyration_games,代码行数:27,代码来源:GameScreen.py

示例6: __init__

 def __init__(self, name, port, approved, usingGlacier2, glacier2Host, glacier2Port,
              client_prx, ip_string, reporter = None, threshold = 300):
     """
     Initialize a main-to-game session.
     @param name Server's name.
     @param port Port that the server listens for clients on.
     @param approved True if the server is 'approved' by this server, otherwise False.
     @param usingGlacier2 [bool] True if clients must use Glacier2 to connect.
     @param glacier2Host Host name of the Glacier2 router.
     @param glacier2Port Port number that the Glacier2 router listens on.
     @param client_prx Proxy to the client's callback.
     @param ip_string IP obtained from the current.con.toString() method.
     @param reporter Debug reporter. Optional.
     """
     Base_Servant.__init__(self, ip_string, Client_Types.THEATRE_CLIENT_TYPE, 0, reporter);
     
     self.name = name;
     self.port = port;
     self.config = World.get_world().get_config();
     self.database = World.get_world().get_database();
     self.approved = approved;
     self.client_prx = MainToGameSession.ClientSessionPrx.uncheckedCast(client_prx.ice_timeout(8000));
     self.usingGlacier2 = usingGlacier2;
     self.glacier2Host = glacier2Host;
     self.glacier2Port = glacier2Port;
     
     self.player_limit = 100;
     self.forced_limit = False;
     self.player_list = {};
     self.threshold = threshold;
     self.current_map = "";
     self.current_mode = VTankObject.GameMode.DEATHMATCH;
开发者ID:summer-of-software,项目名称:vtank,代码行数:32,代码来源:MTGSession.py

示例7: run

def run():
    global discount
    time.sleep(1)
    alpha = 1
    t = 1
    episode_hist = []
    while True:
        # Pick the right action
        s = World.player
        max_act, max_val = max_Q(s)
        chosen_act = policy(max_act)
        (s, a, r, s2) = do_action(chosen_act)
        episode_hist.append((s, a, r, s2))

        # Update Q
        max_act, max_val = max_Q(s2)
        inc_Q(s, a, alpha, r + discount * max_val)

        # Check if the game has restarted
        t += 1.0
        if World.has_restarted():
            backPropagate(episode_hist, alpha)
            World.restart_game()
            time.sleep(0.01)
            t = 1.0
            episode_hist = []

        # Update the learning rate
        alpha = pow(t, -0.1)

        # MODIFY THIS SLEEP IF THE GAME IS GOING TOO FAST.
        time.sleep(0.05)
开发者ID:PhilippeMorere,项目名称:BasicReinforcementLearning,代码行数:32,代码来源:NewLearner_Q_with_eligibility_trace.py

示例8: generate_structure

 def generate_structure(self, structure, x):
     #TODO: add background blocks defined separately
     if structure["type"] == "column":
         height = random.randint(structure["minheight"], structure["maxheight"])
         for y in range(self.heights[x] - height, self.heights[x]):
             self.set_block_at(x, y, World.get_block(structure["block"]), False)
     elif structure["type"] == "json":
         structure_file = open(structure["location"])
         structure_json = json.load(structure_file)
         curr_y = self.heights[x] - len(structure_json["shape"])
         for line in structure_json["shape"]:
             curr_world_x = Convert.chunk_to_world(x, self)
             for char in line:
                 #find the right chunk
                 chunk = self #world.chunks[Convert.world_to_chunk(x)[1]]- can't really do this...
                 curr_chunk_x = Convert.world_to_chunk(curr_world_x)[0]
                 if curr_chunk_x < WIDTH:
                     if char == " ":
                         block_name = "water"
                     else:
                         block_name = structure_json["blocks"][char]
                     block = World.get_block(block_name)
                     #TODO: add background
                     chunk.set_block_at(curr_chunk_x, curr_y, block, False)
                     if block["entity"] != "":
                         #generate the block entity
                         EntityClass = getattr(importlib.import_module("ent." + block["entity"]), block["entity"])
                         instance = EntityClass([curr_world_x, curr_y], self)
                         self.entities.append(instance)
                 curr_world_x += 1
             curr_y += 1
         structure_file.close()
     elif structure["type"] == "singleblock":
         self.set_block_at(x, self.heights[x] - 1, World.get_block(structure["block"]), False)
开发者ID:kaikue,项目名称:Oceania,代码行数:34,代码来源:Chunk.py

示例9: get_block_at

 def get_block_at(self, x, y, background):
     if y < 0 or y >= World.HEIGHT:
         return "air"
     if background:
         return World.get_id_name(self.background_blocks[y][x])
     else:
         return World.get_id_name(self.foreground_blocks[y][x])
开发者ID:kaikue,项目名称:Oceania,代码行数:7,代码来源:Chunk.py

示例10: move

	def move(self, dx, dy):
		if World.tile_exists(self.location_x + dx, self.location_y + dy):
                        self.location_x += dx
                        self.location_y += dy
                        print(World.tile_exists(self.location_x, self.location_y).intro_text())
                else:
                        print("You bump into an invisible wall.")
开发者ID:Captain-Eli,项目名称:Cranberries,代码行数:7,代码来源:Player.py

示例11: set_blocks_from_noise

 def set_blocks_from_noise(self, x, y, noise, background):
     #TODO: variable thresholds from biome
     if noise > -0.4:
         self.set_block_at(x, y, World.get_block(self.biome["base"]), background)
     elif noise > -0.5:
         self.set_block_at(x, y, World.get_block(self.biome["surface"]), background)
     else:
         self.set_block_at(x, y, World.get_block("water"), background)
开发者ID:kaikue,项目名称:Oceania,代码行数:8,代码来源:Chunk.py

示例12: render_block

 def render_block(self, x, y, screen, viewport, background):
     #don't render air
     if background:
         block = World.get_block_from_id(self.background_blocks[y][x])
     else:
         block = World.get_block_from_id(self.foreground_blocks[y][x])
     if block["name"] != "air":
         Game.get_world().render_block(block["id"], [Convert.chunk_to_world(x, self), y], block["connectedTexture"], screen, viewport, background, self)
开发者ID:kaikue,项目名称:Oceania,代码行数:8,代码来源:Chunk.py

示例13: adjacent_moves

	def adjacent_moves(self):
		"""Returns all move actions for adjacent tiles."""
		moves =[]
		if World.tile_exists(self.x + 1, self.y):
			moves.append(Actions.MoveEast())
		if World.tile_exists(self.x - 1, self.y):
			moves.append(Actions.MoveWest())
		if World.tile_exists(self.x, self.y + 1):
			moves.append(Actions.MoveNorth())
		if World.tile_exists(self.x, self.y - 1):
			moves.append(Actions.MoveSouth())
		return moves
开发者ID:IceProdigyHaku,项目名称:Adventure,代码行数:12,代码来源:tiles.py

示例14: exitFinal

 def exitFinal(self):
     ImageManager.unloadSet("debug")
     AudioManager.unloadSfxSet("debug")
     World.cleanupCompletely()
     AudioManager.loadMusic("title")
     pygame.mixer.music.play(-1)
     if Globals.LEVELS_BEAT < 5:
         Globals.LEVELS_BEAT = 5
     Globals.SCORE = Globals.SCORE + 5000*Globals.MINI_SUNS
     Globals.PLAYER = None
     Globals.STATE = CompletedGameScreen.CompletedGameScreen()
     Globals.CHECKPOINT_SET = False
开发者ID:davidkoh316,项目名称:gyration_games,代码行数:12,代码来源:GameScreen.py

示例15: play

def play():
    global gamemode
    gamemode = PLAYING
    World.load_data()
    global viewport
    viewport = pygame.Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)
    global player
    player = Player.Player([0, 140], "img/player.png")
    global world
    world = World.World("defaultworld", player)
    #improve this later
    global img_target
    img_target = pygame.image.load("img/target.png").convert_alpha()
开发者ID:rystills,项目名称:Oceania,代码行数:13,代码来源:Game.py


注:本文中的World类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。