def __init__(self): # Call the parent class and set up the window super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) # These are 'lists' that keep track of our sprites. Each sprite should # go into a list. self.coin_list = None self.wall_list = None self.player_list = None # Separate variable that holds the player sprite self.player_sprite = None # Our physics engine self.physics_engine = None # Used to keep track of our scrolling self.view_bottom = 0 self.view_left = 0 # Keep track of the score self.score = 0 # Load sounds self.collect_coin_sound = arcadeplus.load_sound(":resources:sounds/coin1.wav") self.jump_sound = arcadeplus.load_sound(":resources:sounds/jump1.wav") arcadeplus.set_background_color(arcadeplus.csscolor.CORNFLOWER_BLUE)
def __init__(self): """ Initializer """ # Call the parent class initializer super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) # Variables that will hold sprite lists self.player_list = None self.enemy_list = None self.player_bullet_list = None self.enemy_bullet_list = None self.shield_list = None # Textures for the enemy self.enemy_textures = None # State of the game self.game_state = PLAY_GAME # Set up the player info self.player_sprite = None self.score = 0 # Enemy movement self.enemy_change_x = -ENEMY_SPEED # Don't show the mouse cursor self.set_mouse_visible(False) # Load sounds. Sounds from kenney.nl self.gun_sound = arcadeplus.load_sound(":resources:sounds/hurt5.wav") self.hit_sound = arcadeplus.load_sound(":resources:sounds/hit5.wav") arcadeplus.set_background_color(arcadeplus.color.AMAZON)
def __init__(self): """ Initializer """ # Call the parent class initializer super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) # Set the working directory (where we expect to find files) to the same # directory this .py file is in. You can leave this out of your own # code, but it is needed to easily run the examples using "python -m" # as mentioned at the top of this program. file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) # Variables that will hold sprite lists self.player_list = None self.coin_list = None self.bullet_list = None # Set up the player info self.player_sprite = None self.score = 0 # Don't show the mouse cursor self.set_mouse_visible(False) # Load sounds. Sounds from kenney.nl self.gun_sound = arcadeplus.load_sound(":resources:sounds/hurt5.wav") self.hit_sound = arcadeplus.load_sound(":resources:sounds/hit5.wav") arcadeplus.set_background_color(arcadeplus.color.AMAZON)
def __init__(self): super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) # Set the working directory (where we expect to find files) to the same # directory this .py file is in. You can leave this out of your own # code, but it is needed to easily run the examples using "python -m" # as mentioned at the top of this program. file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) self.frame_count = 0 self.game_over = False # Sprite lists self.all_sprites_list = arcadeplus.SpriteList() self.asteroid_list = arcadeplus.SpriteList() self.bullet_list = arcadeplus.SpriteList() self.ship_life_list = arcadeplus.SpriteList() # Set up the player self.score = 0 self.player_sprite = None self.lives = 3 # Sounds self.laser_sound = arcadeplus.load_sound(":resources:sounds/hurt5.wav") self.hit_sound1 = arcadeplus.load_sound( ":resources:sounds/explosion1.wav") self.hit_sound2 = arcadeplus.load_sound( ":resources:sounds/explosion2.wav") self.hit_sound3 = arcadeplus.load_sound(":resources:sounds/hit1.wav") self.hit_sound4 = arcadeplus.load_sound(":resources:sounds/hit2.wav")
def __init__(self): """ Initializer for the game """ # Call the parent class and set up the window super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) # Set the path to start with this program file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) # Track the current state of what key is pressed self.left_pressed = False self.right_pressed = False self.up_pressed = False self.down_pressed = False self.jump_needs_reset = False # These are 'lists' that keep track of our sprites. Each sprite should # go into a list. self.coin_list = None self.wall_list = None self.background_list = None self.ladder_list = None self.player_list = None # Separate variable that holds the player sprite self.player_sprite = None # Our 'physics' engine self.physics_engine = None # Used to keep track of our scrolling self.view_bottom = 0 self.view_left = 0 self.end_of_map = 0 # Keep track of the score self.score = 0 # Load sounds self.collect_coin_sound = arcadeplus.load_sound(":resources:sounds/coin1.wav") self.jump_sound = arcadeplus.load_sound(":resources:sounds/jump1.wav") self.game_over = arcadeplus.load_sound(":resources:sounds/gameover1.wav")
def __init__(self): # Call the parent class and set up the window super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) # These are 'lists' that keep track of our sprites. Each sprite should # go into a list. self.coin_list = None self.wall_list = None self.foreground_list = None self.background_list = None self.dont_touch_list = None self.player_list = None # Separate variable that holds the player sprite self.player_sprite = None # Our physics engine self.physics_engine = None # Used to keep track of our scrolling self.view_bottom = 0 self.view_left = 0 # Keep track of the score self.score = 0 # Where is the right edge of the map? self.end_of_map = 0 # Level self.level = 1 # Load sounds self.collect_coin_sound = arcadeplus.load_sound( ":resources:sounds/coin1.wav") self.jump_sound = arcadeplus.load_sound(":resources:sounds/jump1.wav") self.game_over = arcadeplus.load_sound( ":resources:sounds/gameover1.wav")
""" Sound Demo If Python and arcadeplus are installed, this example can be run from the command line with: python -m arcadeplus.examples.sound """ import arcadeplus import os # Set the working directory (where we expect to find files) to the same # directory this .py file is in. You can leave this out of your own # code, but it is needed to easily run the examples using "python -m" # as mentioned at the top of this program. file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) arcadeplus.open_window(300, 300, "Sound Demo") laser_sound = arcadeplus.load_sound(":resources:sounds/laser1.wav") arcadeplus.play_sound(laser_sound) arcadeplus.run()
captured = [False] # Create resource directories try: os.makedirs("data/frames") print("Directory \"data/frames\" Created") except: print("Directory \"data/frames\" Already Exists") try: os.makedirs("data/scenes") print("Directory \"data/scenes\" Created") except: print("Directory \"data/scenes\" Already Exists") # Load sound(s) snd_btn_press = arcadeplus.load_sound("res/audio/btn_press.mp3") def list_scenes(): path = sys.argv[0][:-20] + "/data/scenes" files = [] for r, d, f in os.walk(path): for f1 in f: f1 = str(f1).replace(".png", "") files.append(f1) return files def get_chosen_color(): global chosen_color_column, chosen_color_row, colors_col1, colors_col2