Esempio n. 1
0
def main():
    """
    This is the main program.
    """

    # Open the window
    arcade.open_window("Drawing With Functions", SCREEN_WIDTH, SCREEN_HEIGHT)

    # Start the render process. This must be done before any drawing commands.
    arcade.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)
    draw_bird(175, 450)
    draw_bird(525, 475)
    draw_bird(415, 475)

    # My drawing of PACMAN
    arcade.draw_arc_filled(225, 230, 36, 36,
                       arcade.color.YELLOW, 90, 360, -45)


    # Finish the render.
    # Nothing will be drawn without this.
    # Must happen after all draw commands
    arcade.finish_render()

    # Keep the window up until someone closes it.
    arcade.run()
Esempio n. 2
0
def main():
    """
    This is the main program.
    """

    # Open the window
    arcade.open_window("Drawing With Functions", 600, 600)

    # Start the render process. This must be done before any drawing commands.
    arcade.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
    arcade.finish_render()

    # Keep the window up until someone closes it.
    arcade.run()
Esempio n. 3
0
def main():
    # Open up our window
    arcade.open_window("Bouncing Rectangle Example", SCREEN_WIDTH, SCREEN_HEIGHT)
    arcade.set_background_color(arcade.color.WHITE)

    # Tell the computer to call the draw command at the specified interval.
    arcade.schedule(on_draw, 1 / 80)

    # Run the program
    arcade.run()
Esempio n. 4
0
def main():
    # Open up our window
    arcade.open_window("Bouncing Ball", SCREEN_WIDTH, SCREEN_HEIGHT)
    arcade.set_background_color(arcade.color.WHITE)

    # Tell the computer to call the draw command at the specified interval.
    arcade.schedule(draw, 1 / 80)

    # Run the program
    arcade.run()

    # When done running the program, close the window.
    arcade.close_window()
Esempio n. 5
0
def main():
    """
    This is the main program.
    """

    # Open the window
    arcade.open_window("Drawing With Loops", SCREEN_WIDTH, SCREEN_HEIGHT)

    # Start the render process. This must be done before any drawing commands.
    arcade.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
    arcade.finish_render()

    # Keep the window up until someone closes it.
    arcade.run()
Esempio n. 6
0
    # Appear in first column
    arcade.draw_circle_filled(100, 100, 50, arcade.color.YELLOW)

    # Appear in second column
    arcade.draw_small_filled_circle(300, 100, arcade.color.YELLOW)
    arcade.draw_medium_filled_circle(300, 300, arcade.color.YELLOW)
    arcade.draw_large_filled_circle(300, 500, arcade.color.YELLOW)

    # Appear in third column
    arcade.draw_standard_circle(500, 100,
                                arcade.color.YELLOW, "LARGE", "filled")
    arcade.draw_standard_circle(500, 300,
                                arcade.color.YELLOW, "m", "filled")
    arcade.draw_standard_circle(500, 500,
                                arcade.color.YELLOW, "small", "filled")

    # Appear in fourth column
    arcade.draw_circle_outline(700, 300, 50, arcade.color.YELLOW)

    arcade.draw_circle(700, 100, 50, arcade.color.YELLOW)

arcade.open_window("Test Circles", 800, 600)
arcade.set_background_color(arcade.color.RED)

arcade.schedule(on_draw, 1/80)

arcade.run()

arcade.close_window()
Esempio n. 7
0
    x = SWEEP_LENGTH * math.sin(on_draw.angle) + CENTER_X
    y = SWEEP_LENGTH * math.cos(on_draw.angle) + CENTER_Y

    # Start the render. This must happen before any drawing
    # commands. We do NOT need an stop render command.
    arcade.start_render()

    # Draw the radar line
    arcade.draw_line(CENTER_X, CENTER_Y, x, y, arcade.color.OLIVE, 2)

    # Draw the outline of the radar
    arcade.draw_circle_outline(CENTER_X, CENTER_Y, SWEEP_LENGTH,
                               arcade.color.DARK_GREEN, 3)

# These are function-specific variables. Before we
# use them in our function, we need to give them initial
# values.
on_draw.angle = 0

# Open up our window
arcade.open_window("Radar Sweep Example", SCREEN_WIDTH, SCREEN_HEIGHT)
arcade.set_background_color(arcade.color.BLACK)

# Tell the computer to call the draw command at the specified interval.
arcade.schedule(on_draw, 1 / 60)

# Run the program
arcade.run()

# When done running the program, close the window.
arcade.close_window()
Esempio n. 8
0
'''
Instructions:
1) Review and run the 0_2_drawing_primitives.py file and investigate how the different shapes, text, and images
are drawn to the screen.

2) In this file, try to use the different arcade commands to draw your favourite emoji.  You should explore
* drawing filled shapes
* drawing shape outlines
* drawing text
'''


import arcade
import os

# change the window dimensions if you need to
arcade.open_window(600, 600, "My Emoji Attempt")


arcade.set_background_color(arcade.color.WHITE)


arcade.start_render()

# place all your drawing commands in between the start_render() and finish_render() commands

arcade.finish_render()


arcade.run()
Esempio n. 9
0
    # of this as our speed and direction.)
    on_draw.x += on_draw.delta_x
    on_draw.y += on_draw.delta_y

    # Figure out if we hit the edge and need to reverse.
    if on_draw.x < RECT_WIDTH // 2 or on_draw.x > SCREEN_WIDTH - RECT_WIDTH // 2:
        on_draw.delta_x *= -1
    if on_draw.y < RECT_HEIGHT // 2 or on_draw.y > SCREEN_HEIGHT - RECT_HEIGHT // 2:
        on_draw.delta_y *= -1

# These are function-specific variables. Before we
# use them in our function, we need to give them initial
# values.
on_draw.x = 100
on_draw.y = 50
on_draw.delta_x = 3
on_draw.delta_y = 2

# Open up our window
arcade.open_window("Drawing Example", SCREEN_WIDTH, SCREEN_HEIGHT)
arcade.set_background_color(arcade.color.WHITE)

# Tell the computer to call the draw command at the specified interval.
arcade.schedule(on_draw, 1 / 80)

# Run the program
arcade.run()

# When done running the program, close the window.
arcade.close_window()
Esempio n. 10
0
'''
Step 2: create a variable for each line of text of your meme,  assign text to the variables
'''
# put your code here

'''
Step 3: define a height and width variable and set them to the height and width of your meme image

'''
# put your code here

'''
Step 4: change the open_window command to use your height and width variables for the dimensions of the window
'''
arcade.open_window(600, 600, "Meme Generator")


arcade.start_render()

'''
Step 5:
Investigate the usage of the  arcade.load_texture command in the 0_2_drawing_primitives.py program.
Use the arcade.load_texture to set a texture variable to the image file of your meme.
'''
# put your code here

'''
Step 6: investigate and use the arcade.draw_texture_rectangle command to place your image in the center of the window
'''
# put your code here
Esempio n. 11
0
import arcade
import os

#arcade uses pixels to measure eveything, so the below line of code
#create a game window that is 600 pixels wide and 600 pixels high
#the last variable gives the window its name
arcade.open_window(600, 600, "ArcadeIntroduction")

#you need this line of code to start drawing
arcade.start_render()

#this is where you type all the code you want to use to draw
#try and work out what each number does
#http://arcade.academy/arcade.html#drawing-commands may give you some hints
arcade.draw_circle_filled(300, 300, 200, arcade.color.BLACK)

#this command tells the program you are done writing all your drawing commands
arcade.finish_render()

#this line runs your game
arcade.run()
"""
Example "Arcade" library code.

Showing how to do nested loops.
"""

# Library imports
import arcade

COLUMN_SPACING = 60
ROW_SPACING = 40

TEXT_SIZE = 12

# Open the window and set the background
arcade.open_window("Complex Loops - Bottom Left Triangle", 600, 400)

arcade.set_background_color(arcade.color.WHITE)

# Start the render process. This must be done before any drawing commands.
arcade.start_render()

# Loop for each row
for row in range(10):
    # Loop for each column
    # Change the number of columns depending on the row we are in
    for column in range(10 - row):
        # Calculate our location
        x = column * COLUMN_SPACING
        y = row * ROW_SPACING
Esempio n. 13
0
#!/usr/bin/env python3

import utils, open_color, arcade

utils.check_version((3, 7))

# Open the window. Set the window title and dimensions (width and height)
arcade.open_window(800, 600, "Smiley Face Example")
arcade.set_background_color(open_color.white)

# Start the render process. This must be done before any drawing commands.
arcade.start_render()

#start at 100, go to 799, counting by 150
for x in range(100, 800, 150):
    #start at 100, go to 599, counting by 150
    for y in range(100, 600, 150):
        face_x, face_y = (400, 300)
        smile_x, smile_y = (face_x + 0, face_y - 0)
        eye1_x, eye1_y = (face_x - 40, face_y + 35)
        eye2_x, eye2_y = (face_x + 30, face_y + 35)
        catch1_x, catch1_y = (face_x - 40, face_y + 35)
        catch2_x, catch2_y = (face_x + 30, face_y + 35)

        # Draw the smiley face:
        # (x,y,radius,color)
        arcade.draw_circle_filled(face_x, face_y, 100, open_color.yellow_3)
        # (x,y,radius,color,border_thickness)
        arcade.draw_circle_outline(face_x, face_y, 100, open_color.black, 4)

        #(x,y,width,height,color)
Esempio n. 14
0
yet.

API documentation for the draw commands can be found here:
https://pythonhosted.org/arcade/arcade.html#module-arcade.draw_commands

A video explaining this example can be found here:
https://vimeo.com/167158158
"""

# Import the Arcade library. If this fails, then try following the instructions
# for how to install arcade:
# https://pythonhosted.org/arcade/installation.html
import arcade

# Open the window. Set the window title and dimensions (width and height)
arcade.open_window("Drawing Example", 600, 600)

# Set the background color to white
# For a list of named colors see
# https://pythonhosted.org/arcade/arcade.color.html
# Colors can also be specified in (red, green, blue) format and
# (red, green, blue, alpha) format.
arcade.set_background_color(arcade.color.BLUE_GRAY)

# Start the render process. This must be done before any drawing commands.
arcade.start_render()

# Draw a grid
# Draw vertical lines every 120 pixels
for x in range(0, 601, 120):
    arcade.draw_line(x, 0, x, 600, arcade.color.WHITE, 2)
Esempio n. 15
0
# ?
import arcade
import os

# ?
arcade.open_window(600, 600, "My First Arcade Program")

# ?
arcade.set_background_color(arcade.color.WHITE)

# ?
arcade.start_render()

# ?
arcade.draw_text("draw_circle_filled", 363, 207, arcade.color.BLACK, 10)
arcade.draw_circle_filled(420, 285, 18, arcade.color.GREEN)

# ?
arcade.finish_render()

# ?
arcade.run()
Esempio n. 16
0
"""
Example "Arcade" library code.

Showing how to do nested loops.
"""

# Library imports
import arcade

COLUMN_SPACING = 60
ROW_SPACING = 40

TEXT_SIZE = 12

# Open the window and set the background
arcade.open_window("Complex Loops - Box", 600, 400)

arcade.set_background_color(arcade.color.WHITE)

# Start the render process. This must be done before any drawing commands.
arcade.start_render()

# Loop for each row
for row in range(10):
    # Loop for each column
    for column in range(10):
        # Calculate our location
        x = column * COLUMN_SPACING
        y = row * ROW_SPACING

        # Draw the item
Esempio n. 17
0
import arcade
arcade.open_window("Sprite Example", 800, 600)
player = arcade.PlatformerSpriteSheetSprite()
top_trim = 100
ltrim = 2
rtrim = 2
image_location_list = [
 [520 + ltrim, 516 + top_trim, 128 - ltrim - rtrim, 256 - top_trim],
 [520 + ltrim, 258 + top_trim, 128 - ltrim - rtrim, 256 - top_trim],
 [520 + ltrim, 0 + top_trim, 128 - ltrim - rtrim, 256 - top_trim],
 [390 + ltrim, 1548 + top_trim, 128 - ltrim - rtrim, 256 - top_trim],
 [390 + ltrim, 1290 + top_trim, 128 - ltrim - rtrim, 256 - top_trim],
 [390 + ltrim, 516 + top_trim, 128 - ltrim - rtrim, 256 - top_trim],
 [390 + ltrim, 258 + top_trim, 128 - ltrim - rtrim, 256 - top_trim]]
filename = "doc/source/examples/images/spritesheet_complete.png"
texture_info_list = arcade.load_textures(filename, image_location_list)
for texture_info in texture_info_list:
     texture = texture_info
     player.append_texture(texture)
texture_info_list = arcade.load_textures(\
filename, image_location_list, True)
for texture_info in texture_info_list:
     texture = texture_info
     player.append_texture(texture)
player.set_left_walk_textures([12, 13])
player.set_right_walk_textures([5, 6])
player.set_left_jump_textures([10])
player.set_right_jump_textures([3])
player.set_left_stand_textures([11])
player.set_right_stand_textures([4])
player.texture_change_distance = 5
Esempio n. 18
0
# Import the Arcade library. If this fails, then try following the instructions
# for how to install arcade:
# http://arcade.academy/installation.html
import arcade
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)

# Open the window. Set the window title and dimensions (width and height)
arcade.open_window(600, 600, "Drawing Primitives Example")

# Set the background color to white
# For a list of named colors see
# http://arcade.academy/arcade.color.html
# Colors can also be specified in (red, green, blue) format and
# (red, green, blue, alpha) format.
arcade.set_background_color(arcade.color.WHITE)

# Start the render process. This must be done before any drawing commands.
arcade.start_render()

# Draw a grid
# Draw vertical lines every 120 pixels
for x in range(0, 601, 120):
    arcade.draw_line(x, 0, x, 600, arcade.color.BLACK, 2)
Esempio n. 19
0
                        spx = random.uniform(-1.0, 1.0)
                        spy = random.uniform(-1.0, 1.0)
                        spz = random.uniform(-1.0, 1.0)
                        absquared = spx**2 + spy**2 + spz**2
                        if absquared <= 1:
                            break

                    spx = shard_speed * spx / math.sqrt(absquared)
                    spy = shard_speed * spy / math.sqrt(absquared)
                    radius = random.randint(1, 4)
                    shardlist.append(
                        Shard(
                            shard.x,
                            shard.y,
                            # math.sin(theta) * math.cos(phi) * shard_speed,
                            # math.sin(theta) * math.sin(phi) * shard_speed,
                            spx,
                            spy,
                            time_ratio))
                    shardlist[len(shardlist) - 1].radius = radius
                shardlist.remove(shard)
        for shard in to_be_removed:
            shardlist.remove(shard)

        to_be_removed.clear()


if __name__ == '__main__':
    arcade.open_window(1000, 800, 'fireworks')
    explosion_simulation()
"""
Example "Arcade" library code.

Showing how to do nested loops.
"""

# Library imports
import arcade

COLUMN_SPACING = 60
ROW_SPACING = 40

TEXT_SIZE = 12

# Open the window and set the background
arcade.open_window("Complex Loops - Top Right Triangle", 600, 400)

arcade.set_background_color(arcade.color.WHITE)

# Start the render process. This must be done before any drawing commands.
arcade.start_render()

# Loop for each row
for row in range(10):
    # Loop for each column
    # Change the number of columns depending on the row we are in
    for column in range(9 - row, 10):
        # Calculate our location
        x = column * COLUMN_SPACING
        y = row * ROW_SPACING
Esempio n. 21
0
    if draw.y < CIRCLE_RADIUS and draw.delta_y < 0:
        # If we bounce with a decent velocity, do a normal bounce.
        # Otherwise we won't have enough time resolution to accurate represent
        # the bounce and it will bounce forever. So we'll divide the bounciness
        # by half to let it settle out.
        if draw.delta_y * -1 > GRAVITY_CONSTANT * 15:
            draw.delta_y *= -BOUNCINESS
        else:
            draw.delta_y *= -BOUNCINESS / 2

# These are function-specific variables. Before we
# use them in our function, we need to give them initial
# values.
draw.x = CIRCLE_RADIUS
draw.y = SCREEN_HEIGHT - CIRCLE_RADIUS
draw.delta_x = 2
draw.delta_y = 0

# Open up our window
arcade.open_window("Bouncing Ball", SCREEN_WIDTH, SCREEN_HEIGHT)
arcade.set_background_color(arcade.color.WHITE)

# Tell the computer to call the draw command at the specified interval.
arcade.schedule(draw, 1 / 80)

# Run the program
arcade.run()

# When done running the program, close the window.
arcade.close_window()
Esempio n. 22
0
        on_draw.center_line.end_y = 125

        on_draw.left_arc.center_x = 236
        on_draw.left_arc.center_y = 105

        on_draw.right_arc.center_x = 236
        on_draw.right_arc.center_y = 105

        on_draw.right_arm_2.tilt_angle = 130

        on_draw.ball_move_x = 2
        on_draw.ball_move_y = 2


# open new window and set the background
arcade.open_window("Basketball Example", 800, 600)
arcade.set_background_color(arcade.color.WHITE)

# all shapes created will require the prefix 'on_draw' in order to be
# accessible to the on_draw function

# this is the ball
on_draw.ball = arcade.Circle(236, 105, 20, arcade.color.ORANGE)
on_draw.center_line = arcade.Line(236, 85, 236, 125, arcade.color.BLACK, 1)
on_draw.right_arc = arcade.Arc(236, 105, 20, 15,
                               arcade.color.BLACK, 0, 180, 1, 270)
on_draw.left_arc = arcade.Arc(236, 105, 20, 15,
                              arcade.color.BLACK, 0, 180, 1, 90)

# this is the floor
on_draw.floor = arcade.Line(0, 5, 800, 5, arcade.color.BLACK, 5)
Esempio n. 23
0
import arcade
import os

# set the text for the meme
line1 = "1goodVariableName"
line2 = "good_variable_name1"

# set the dimensions of the window, based on the image
height = 640
width = 550
arcade.open_window(height, width, "Meme Generator")

arcade.set_background_color(arcade.color.WHITE)

arcade.start_render()

# load the image
texture = arcade.load_texture("images/drake_meme.jpg")
arcade.draw_texture_rectangle(texture.width//2, texture.height//2, texture.width,
                              texture.height, texture, 0)

# render the text
arcade.draw_text(line1, width//2 + 100, height - height//3, arcade.color.BLACK, 12)
arcade.draw_text(line2, width//2 + 100, height//2 - height//4,
                 arcade.color.BLACK, 12)

arcade.finish_render()

arcade.run()
Esempio n. 24
0
"""
Example "Arcade" library code.

Showing how to do nested loops.
"""

# Library imports
import arcade

COLUMN_SPACING = 20
ROW_SPACING = 20
LEFT_MARGIN = 110
BOTTOM_MARGIN = 110

# Open the window and set the background
arcade.open_window(400, 400, "Complex Loops - Top Right Triangle")

arcade.set_background_color(arcade.color.WHITE)

# Start the render process. This must be done before any drawing commands.
arcade.start_render()

# Loop for each row
for row in range(10):
    # Loop for each column
    # Change the number of columns depending on the row we are in
    for column in range(9 - row, 10):
        # Calculate our location
        x = column * COLUMN_SPACING + LEFT_MARGIN
        y = row * ROW_SPACING + BOTTOM_MARGIN