Ejemplo n.º 1
0
def cmd_open (gamestate, name, args):
    if len(args) == 1:
        gamestate["filename"] = args[0]
    elif len(args) > 1:
        assert False, "Too many arguments to open!"
    elif "filename" not in gamestate:
        gamestate["filename"] = raw_input ("Please enter a scenario name: ")
    if "selected_button" in gamestate:
        gamestate["renderer"].draw_button (
                gamestate["selected_button"], False
            )
        del gamestate["selected_button"]
    infile = open (gamestate["fs"].locate_resource("scenario", gamestate["filename"]), "rb")
    for action in parser.parse_file (infile):
        run_cmd (gamestate, action[0], action[1])
    for action in gamestate["defaults"]:
        cmd, args = parser.parse_statement (action)
        run_cmd (gamestate, cmd, args)
    if not gamestate["editor"] and "filename" in gamestate:
        del gamestate["filename"]
Ejemplo n.º 2
0
        "fs":       fs.fs ("lof_data"),
        "defaults": [   "teamname red",
                        "editor false", 
                        "direction up", 
                        "piecetype unit", 
                        "unittype triangle", 
                        "autolayer",
                        "tiletype goal",
                        "pos 0 0"       ],
        "eachframe": [  "drawcursor",
                        "refresh",
                        "clearcursor"   ]
    }
gamestate["fs"].add_resource_type ("scenario", "scenarios", "lof")
for action in gamestate["defaults"]+["filename std", "openmap"]:
    cmd, args = parser.parse_statement(action)
    game.run_cmd (gamestate, cmd, args)

bindings.game_add_buttons(gamestate)

while True:
    r.update_inputstate (instate)
    actions = bindings.game_transform_controls(instate, gamestate)
    
    for action in actions:
        cmd, args = parser.parse_statement (action)
        game.run_cmd (gamestate, cmd, args)
    
    for action in gamestate["eachframe"]:
        cmd, args = parser.parse_statement (action)
        game.run_cmd (gamestate, cmd, args)