def switch_edit_mode(): global edit_mode edit_mode = not edit_mode if edit_mode: game.update_menu_entry( "main", Utils.white_bright("j/i/k/l"), Utils.green_bright("Place") + " the current object and then move cursor Left/Up/Down/Right", ) game.update_menu_entry( "main", Utils.white_bright("0 to 9"), Utils.green_bright("Select") + " an item in history to be the current item", ) else: game.update_menu_entry( "main", Utils.white_bright("j/i/k/l"), "Move cursor Left/Up/Down/Right and " + Utils.red_bright("Delete") + " anything that was at destination.", ) game.update_menu_entry( "main", Utils.white_bright("0 to 9"), Utils.red_bright("Remove") + " an item from history", )
def switch_edit_mode(): global edit_mode edit_mode = not edit_mode if edit_mode: game.update_menu_entry('main',Utils.white_bright('j/i/k/l'),Utils.green_bright('Place')+' the current object and then move cursor Left/Up/Down/Right') game.update_menu_entry('main',Utils.white_bright('0 to 9'),Utils.green_bright('Select')+' an item in history to be the current item') else: game.update_menu_entry('main',Utils.white_bright('j/i/k/l'),'Move cursor Left/Up/Down/Right and '+Utils.red_bright('Delete')+' anything that was at destination.') game.update_menu_entry('main',Utils.white_bright('0 to 9'),Utils.red_bright('Remove')+' an item from history')
i = 0 for sp in dir(Utils): if sp.endswith('_SQUARE') or sp.endswith('_RECT'): game.add_menu_entry('graphics_utils', str(i), '"' + getattr(Utils, sp) + '"', getattr(Utils, sp)) i += 1 i = 0 for sp in dir(Sprites): if not sp.startswith('__'): game.add_menu_entry('graphics_sprites', str(i), getattr(Sprites, sp), getattr(Sprites, sp)) i += 1 game.add_menu_entry('main', None, '\n=== Menu (' + menu_mode + ') ===') game.add_menu_entry('main', Utils.white_bright('Space'), 'Switch between edit/delete mode') game.add_menu_entry( 'main', Utils.white_bright('0 to 9'), Utils.green_bright('Select') + ' an item in history to be the current item') game.add_menu_entry('main', Utils.white_bright('a/w/s/d'), 'Move cursor Left/Up/Down/Right') game.add_menu_entry( 'main', Utils.white_bright('j/i/k/l'), Utils.green_bright('Place') + ' the current item and then move cursor Left/Up/Down/Right') game.add_menu_entry( 'main', Utils.white_bright('c'), 'Create a new board item (becomes the current item, previous one is placed in history)' )
import examples_includes # noqa: F401 # First import the Utils module import gamelib.Utils as Utils # Then get creative! # you directly print colored messages: print(Utils.magenta_bright("This is a rather flashy magenta...")) # Each color function has 3 variations : regular, dim and bright print(Utils.yellow_dim("This is dim.")) print(Utils.yellow("This is regular.")) print(Utils.yellow_bright("This is bright.")) # Now, the color functions are just that: functions. So you can store the # results in a variable and use them: blue = Utils.blue_bright("blue") white = Utils.white_bright("white") red = Utils.red_bright("red") print(f"France's flag is {blue} {white} {red}!")
# Build the menus i = 0 for sp in dir(Utils): if sp.endswith('_SQUARE') or sp.endswith('_RECT'): game.add_menu_entry('graphics_utils',str(i), '"'+getattr(Utils,sp)+'"', getattr(Utils,sp)) i += 1 i = 0 for sp in dir(Sprites): if not sp.startswith('__'): game.add_menu_entry('graphics_sprites',str(i), getattr(Sprites,sp), getattr(Sprites,sp) ) i += 1 game.add_menu_entry('main',None,'\n=== Menu ('+menu_mode+') ===') game.add_menu_entry('main',Utils.white_bright('Space'),'Switch between edit/delete mode') game.add_menu_entry('main',Utils.white_bright('0 to 9'),Utils.green_bright('Select')+' an item in history to be the current item') game.add_menu_entry('main',Utils.white_bright('a/w/s/d'),'Move cursor Left/Up/Down/Right') game.add_menu_entry('main',Utils.white_bright('j/i/k/l'),Utils.green_bright('Place')+' the current item and then move cursor Left/Up/Down/Right') game.add_menu_entry('main',Utils.white_bright('c'),'Create a new board item (becomes the current item, previous one is placed in history)') game.add_menu_entry('main',Utils.white_bright('p'),'Modify board parameters') game.add_menu_entry('main',Utils.white_bright('P'),'Set player starting position') game.add_menu_entry('main',Utils.white_bright('S'),'Save the current Board to hac-maps/'+game.current_board().name.replace(' ','_')+'.json') game.add_menu_entry('main',Utils.white_bright('+'),'Save this Board and create a new one') game.add_menu_entry('main',Utils.white_bright('L'),'Save this Board and load a new one') game.add_menu_entry('main',Utils.white_bright('m'),'Switch menu display mode between full or hidden') game.add_menu_entry('main',Utils.white_bright('Q'),'Quit the editor') game.add_menu_entry('board',None,'=== Board ===') game.add_menu_entry('board','1','Change '+Utils.white_bright('width')+' (only sizing up)') game.add_menu_entry('board','2','Change '+Utils.white_bright('height')+' (only sizing up)')
# level, print the new position and wait a little mygame.clear_screen() Utils.debug(f"Nazbrok is at position ({nazbrok.pos[0]},{nazbrok.pos[0]})" f" -- BEFORE changing level") # Now let's go to level 2 mygame.change_level(2) Utils.debug(f"Nazbrok is at position ({nazbrok.pos[0]},{nazbrok.pos[0]})" f" -- AFTER changing level to level 2") mygame.current_board().display() countdown() # And finally do that one last time to go to level 3 mygame.clear_screen() Utils.debug(f"Nazbrok is at position ({nazbrok.pos[0]},{nazbrok.pos[0]})" f" -- BEFORE changing level") # Now let's go to level 3 mygame.change_level(3) Utils.debug(f"Nazbrok is at position ({nazbrok.pos[0]},{nazbrok.pos[0]})" f" -- AFTER changing level to level 3") mygame.current_board().display() print( Utils.white_bright('As you can see even though we never actively' ' moved the player, the Game() object took care' ' of it for us while changing level.' '\nThe Game.change_level() method takes care of:\n -' ' placing the player at the board\'s' ' player_starting_position\n - cleanning the previous' ' board from the player presence.\n - setting the' ' Game.current_level instance variable'))
import examples_includes # First import the Utils module import gamelib.Utils as Utils # Then get creative! # you directly print colored messages: print("France flag is "+Utils.blue_bright('blue ')+Utils.white_bright('white ')+Utils.red_bright('red')+"!") # Each color function has 3 variations : regular, dim and bright print( Utils.yellow_dim('This is dim.')+Utils.yellow(' This is regular.')+Utils.yellow_bright(' This is bright.') ) # Now, the color functions are just that: functions. So you can store the results in a variable and use them: flashymagy = Utils.magenta_bright('This is a rather flashy magenta...') print('Now that is a colored message in a variable: '+flashymagy)
if sp.endswith("_SQUARE") or sp.endswith("_RECT"): game.add_menu_entry("graphics_utils", str(i), '"' + getattr(Utils, sp) + '"', getattr(Utils, sp)) i += 1 i = 0 for sp in dir(Sprites): if not sp.startswith("__"): game.add_menu_entry("graphics_sprites", str(i), getattr(Sprites, sp), getattr(Sprites, sp)) i += 1 game.add_menu_entry( "main", None, "\n=== Menu (" + game.config("settings")["menu_mode"] + ") ===") game.add_menu_entry("main", Utils.white_bright("Space"), "Switch between edit/delete mode") game.add_menu_entry( "main", Utils.white_bright("0 to 9"), Utils.green_bright("Select") + " an item in history to be the current item", ) game.add_menu_entry( "main", Utils.white_bright("\u2190/\u2191/\u2193/\u2192"), "Move cursor Left/Up/Down/Right", ) game.add_menu_entry( "main", Utils.white_bright("j/i/k/l"),
# level, print the new position and wait a little mygame.clear_screen() Utils.debug(f"Nazbrok is at position ({nazbrok.pos[0]},{nazbrok.pos[0]})" f" -- BEFORE changing level") # Now let's go to level 2 mygame.change_level(2) Utils.debug(f"Nazbrok is at position ({nazbrok.pos[0]},{nazbrok.pos[0]})" f" -- AFTER changing level to level 2") mygame.current_board().display() countdown() # And finally do that one last time to go to level 3 mygame.clear_screen() Utils.debug(f"Nazbrok is at position ({nazbrok.pos[0]},{nazbrok.pos[0]})" f" -- BEFORE changing level") # Now let's go to level 3 mygame.change_level(3) Utils.debug(f"Nazbrok is at position ({nazbrok.pos[0]},{nazbrok.pos[0]})" f" -- AFTER changing level to level 3") mygame.current_board().display() print( Utils.white_bright("As you can see even though we never actively" " moved the player, the Game() object took care" " of it for us while changing level." "\nThe Game.change_level() method takes care of:\n -" " placing the player at the board's" " player_starting_position\n - cleanning the previous" " board from the player presence.\n - setting the" " Game.current_level instance variable"))
import examples_includes # First import the Utils module import gamelib.Utils as Utils # Then get creative! # you directly print colored messages: print(Utils.magenta_bright('This is a rather flashy magenta...')) # Each color function has 3 variations : regular, dim and bright print(Utils.yellow_dim('This is dim.')) print(Utils.yellow('This is regular.')) print(Utils.yellow_bright('This is bright.')) # Now, the color functions are just that: functions. So you can store the # results in a variable and use them: blue = Utils.blue_bright('blue') white = Utils.white_bright('white') red = Utils.red_bright('red') print(f"France's flag is {blue} {white} {red}!")