def main(): """ This is the main program. """ # Open the window arcadeplus.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) # Start the render process. This must be done before any drawing commands. arcadeplus.start_render() # Call our drawing functions. draw_background() draw_pine_tree(50, 250) draw_pine_tree(350, 320) draw_bird(70, 500) draw_bird(470, 550) # Finish the render. # Nothing will be drawn without this. # Must happen after all draw commands arcadeplus.finish_render() # Keep the window up until someone closes it. arcadeplus.run()
def main(): arcadeplus.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, TITLE) arcadeplus.set_background_color(BACKGROUND_COLOR) arcadeplus.start_render() arcadeplus.draw_circle_filled(400, 250, 100, arcadeplus.color.BLACK) # load image image = arcadeplus.load_texture(resource_path('character.png')) arcadeplus.draw_texture_rectangle(200, 250, image.width, image.height, image) # load sound sound = arcadeplus.sound.load_sound(resource_path('cat-meow.wav')) arcadeplus.sound.play_sound(sound) arcadeplus.finish_render() arcadeplus.run() return
def test_window(): import arcadeplus width = 800 height = 600 title = "My Title" resizable = True arcadeplus.open_window(width, height, title, resizable) arcadeplus.set_background_color(arcadeplus.color.AMAZON) w = arcadeplus.get_window() assert w is not None # Make sure the arguments get passed to the window assert w.width == width assert w.height == height assert w.caption == title assert w.resizeable is resizable arcadeplus.set_window(w) p = arcadeplus.get_projection() assert p is not None v = arcadeplus.get_viewport() assert v[0] == 0 # The lines below fail. Why? # assert v[1] == width - 1 assert v[2] == 0 # assert v[3] == height - 1 arcadeplus.start_render() arcadeplus.finish_render() def f(): pass arcadeplus.schedule(f, 1 / 60) arcadeplus.pause(0.01) arcadeplus.close_window() arcadeplus.open_window(width, height, title, resizable) arcadeplus.quick_run(0.01)
def main(): """ This is the main program. """ # Open the window arcadeplus.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) # Start the render process. This must be done before any drawing commands. arcadeplus.start_render() # Call our drawing functions. draw_background() # Loop to draw ten birds in random locations. for bird_count in range(10): # Any random x from 0 to the width of the screen x = random.randrange(0, SCREEN_WIDTH) # Any random y from in the top 2/3 of the screen. # No birds on the ground. y = random.randrange(SCREEN_HEIGHT / 3, SCREEN_HEIGHT - 20) # Draw the bird. draw_bird(x, y) # Draw the top row of trees for x in range(45, SCREEN_WIDTH, 90): draw_pine_tree(x, SCREEN_HEIGHT / 3) # Draw the bottom row of trees for x in range(65, SCREEN_WIDTH, 90): draw_pine_tree(x, (SCREEN_HEIGHT / 3) - 120) # Finish the render. # Nothing will be drawn without this. # Must happen after all draw commands arcadeplus.finish_render() # Keep the window up until someone closes it. arcadeplus.run()
360, 45) # Draw an rectangle outline arcadeplus.draw_text("draw_rect", 243, 3, arcadeplus.color.BLACK, 10) arcadeplus.draw_rectangle_outline(295, 100, 45, 65, arcadeplus.color.BRITISH_RACING_GREEN) arcadeplus.draw_rectangle_outline(295, 160, 20, 45, arcadeplus.color.BRITISH_RACING_GREEN, 3, 45) # Draw a filled in rectangle arcadeplus.draw_text("draw_filled_rect", 363, 3, arcadeplus.color.BLACK, 10) arcadeplus.draw_rectangle_filled(420, 100, 45, 65, arcadeplus.color.BLUSH) arcadeplus.draw_rectangle_filled(420, 160, 20, 40, arcadeplus.color.BLUSH, 45) # Load and draw an image to the screen # Image from kenney.nl asset pack #1 arcadeplus.draw_text("draw_bitmap", 483, 3, arcadeplus.color.BLACK, 12) texture = arcadeplus.load_texture( ":resources:images/space_shooter/playerShip1_orange.png") scale = .6 arcadeplus.draw_scaled_texture_rectangle(540, 120, texture, scale, 0) arcadeplus.draw_scaled_texture_rectangle(540, 60, texture, scale, 45) # Finish the render. # Nothing will be drawn without this. # Must happen after all draw commands arcadeplus.finish_render() # Keep the window up until someone closes it. arcadeplus.run()