예제 #1
1
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.all_sprites_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()

        # Set up the player
        self.score = 0
        self.player = arcade.AnimatedWalkingSprite()

        filename = "images/character_sheet.png"

        image_location_list = [[0, 6, 59, 92]]
        self.player.stand_right_textures = \
            arcade.load_textures(filename, image_location_list, False)
        self.player.stand_left_textures = \
            arcade.load_textures(filename, image_location_list, True)

        image_location_list = [[591, 5, 64, 93],
                               [655, 10, 75, 88],
                               [730, 7, 54, 91],
                               [784, 3, 59, 95],
                               [843, 6, 56, 92]]
        self.player.walk_right_textures = \
            arcade.load_textures(filename, image_location_list, False)
        self.player.walk_left_textures = \
            arcade.load_textures(filename, image_location_list, True)

        self.player.texture_change_distance = 20

        self.player.center_x = SCREEN_WIDTH // 2
        self.player.center_y = SCREEN_HEIGHT // 2
        self.player.scale = 0.8

        self.all_sprites_list.append(self.player)

        for i in range(COIN_COUNT):
            coin = arcade.AnimatedTimeSprite(scale=0.5)
            coin.center_x = random.randrange(SCREEN_WIDTH)
            coin.center_y = random.randrange(SCREEN_HEIGHT)
            coin.textures = []
            coin.textures.append(arcade.load_texture("images/gold_1.png",
                                                     scale=COIN_SCALE))
            coin.textures.append(arcade.load_texture("images/gold_2.png",
                                                     scale=COIN_SCALE))
            coin.textures.append(arcade.load_texture("images/gold_3.png",
                                                     scale=COIN_SCALE))
            coin.textures.append(arcade.load_texture("images/gold_4.png",
                                                     scale=COIN_SCALE))
            coin.textures.append(arcade.load_texture("images/gold_3.png",
                                                     scale=COIN_SCALE))
            coin.textures.append(arcade.load_texture("images/gold_2.png",
                                                     scale=COIN_SCALE))
            coin.cur_texture_index = random.randrange(len(coin.textures))
            self.coin_list.append(coin)
            self.all_sprites_list.append(coin)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)
예제 #2
0
파일: app.py 프로젝트: Morillo9/BattlePong
    def __init__(self, width, height):
        super().__init__(width, height)

        self.ball_x_position = BALL_RADIUS
        self.ball_y_position = SCREEN_HEIGHT // 2
        self.ball_x_pixels_per_second = 70
        self.ball_velocity_x = random.uniform(0.5, 2.0)
        self.ball_velocity_y = random.choice([-2, 2])
        self.last_key = None
        self.contact_counter = 0
        self.paddle_ball_dif = 0.0
        self.rocket_count = 0
        self.invis_count = 0
        self.lightning_count = 0
        self.rocket_activate = False
        self.last_item = None
        self.board_speed_player = 2
        self.board_speed_computer = 2

        self.invis_timer = 0
        self.invis_activated = False
        self.invis_count = 0

        self.computer_score = 0
        self.player_score = 0

        self.all_sprites_list = None
        self.rocket_sprites_list = None
        self.item_sprites_list = None
        self.player_sprite = None
        self.computer_sprite = None

        arcade.set_background_color(arcade.color.WHITE)
예제 #3
0
    def __init__(self, width, height):
        super().__init__(width, height)
        self.hit_sound = arcade.load_sound("sounds/rockHit2.ogg")
        self.object_list = arcade.SpriteList()
        self.time = 0
        arcade.set_background_color(arcade.color.DARK_SLATE_GRAY)

        self.player = arcade.PhysicsAABB("images/character.png", [390, 400], [79 / 2, 125 / 2], [0, 0], .7, 3, 0.4)
        self.object_list.append(self.player)

        create_circles(self.object_list, 300, 300, 5, 2)

        a = arcade.PhysicsCircle("images/meteorGrey_med1.png", [400, 150], 20, [0, 0], .8, 2, 0.1)
        self.object_list.append(a)
        a = arcade.PhysicsCircle("images/meteorGrey_med2.png", [370, 120], 20, [0, 0], .8, 2, 0.1)
        self.object_list.append(a)
        a = arcade.PhysicsCircle("images/meteorGrey_med1.png", [430, 120], 20, [0, 0], .8, 2, 0.1)
        self.object_list.append(a)
        a = arcade.PhysicsCircle("images/meteorGrey_med1.png", [400, 90], 20, [0, 0], .8, 2, 0.1)
        self.object_list.append(a)

        create_boxes(self.object_list, 150, 250, 2, 20)
        create_boxes(self.object_list, 450, 250, 2, 20)
        create_boxes(self.object_list, 190, 250, 13, 2)
        create_boxes(self.object_list, 190, 450, 13, 2)
        create_boxes(self.object_list, 190, 610, 13, 2)
예제 #4
0
    def __init__(self, screen_width, screen_height):
        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, "Sprites and Bullets Demo")

        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.all_sprites_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()
        self.bullet_list = arcade.SpriteList()

        # Set up the player
        self.score = 0
        self.player_sprite = arcade.Sprite("images/character.png",
                                           SPRITE_SCALING)
        self.player_sprite.center_x = 50
        self.player_sprite.center_y = 70
        self.all_sprites_list.append(self.player_sprite)

        for i in range(50):

            # Create the coin instance
            coin = arcade.Sprite("images/coin_01.png", SPRITE_SCALING / 3)

            # Position the coin
            coin.center_x = random.randrange(screen_width)
            coin.center_y = random.randrange(120, screen_height)

            # Add the coin to the lists
            self.all_sprites_list.append(coin)
            self.coin_list.append(coin)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)
예제 #5
0
파일: snow.py 프로젝트: mquinson/arcade
    def start_snowfall(self):
        """ Set up snowfall and initialize variables. """
        self.snowflake_list = []

        for i in range(50):
            # Create snowflake instance
            snowflake = Snowflake()

            # Randomly position snowflake
            snowflake.x = random.randrange(SCREEN_WIDTH)
            snowflake.y = random.randrange(SCREEN_HEIGHT + 200)

            # Set other variables for the snowflake
            snowflake.size = random.randrange(4)
            snowflake.speed = random.randrange(20, 40)
            snowflake.angle = random.uniform(math.pi, math.pi * 2)

            # Add snowflake to snowflake list
            self.snowflake_list.append(snowflake)

        # Don't show the mouse pointer
        self.set_mouse_visible(False)

        # Set the background color
        arcade.set_background_color(arcade.color.BLACK)
예제 #6
0
    def __init__(self, width, height):
        super().__init__(width, height)

        self.ball_x_position = BALL_RADIUS
        self.ball_x_pixels_per_second = 70

        arcade.set_background_color(arcade.color.WHITE)
예제 #7
0
파일: pool.py 프로젝트: mikemhenry/arcade
    def __init__(self, width, height):
        super().__init__(width, height)
        self.object_list = arcade.SpriteList()
        self.time = 0
        arcade.set_background_color(arcade.color.DARK_SLATE_GRAY)

        self.player = arcade.PhysicsCircle("images/pool_cue_ball.png", [390, 400], 15, [0, 0], 1, 1, BALL_DRAG)
        self.object_list.append(self.player)

        for row in range(5):
            for column in range(row + 1):
                x = 500 - row * 15 + column * 30
                y = 500 + row * 15 * 2
                ball = arcade.PhysicsCircle("images/pool_cue_ball.png", [x, y], 15, [0, 0], 1, 1, BALL_DRAG)
                self.object_list.append(ball)

        for x in range(200, 800, 40):
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [x, 700], [40, 40], [0, 0], 1, 100, BALL_DRAG)
            wall.static = True
            self.object_list.append(wall)

        for y in range(100, 700, 40):
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [200, y], [40, 40], [0, 0], 1, 100, BALL_DRAG)
            wall.static = True
            self.object_list.append(wall)

        for y in range(100, 700, 40):
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [760, y], [40, 40], [0, 0], 1, 100, BALL_DRAG)
            wall.static = True
            self.object_list.append(wall)

        for x in range(200, 800, 40):
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [x, 60], [40, 40], [0, 0], 1, 100, BALL_DRAG)
            wall.static = True
            self.object_list.append(wall)
예제 #8
0
 def setup(self):
     """
     Set up the application.
     """
     arcade.set_background_color(arcade.color.WHITE)
     self.ball_x_position = BALL_RADIUS
     self.ball_x_pixels_per_second = 70
예제 #9
0
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.all_sprites_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()

        # Set up the player
        self.score = 0
        self.player_sprite = arcade.Sprite("images/character.png",
                                           SPRITE_SCALING)
        self.player_sprite.center_x = 50
        self.player_sprite.center_y = 50
        self.all_sprites_list.append(self.player_sprite)

        for i in range(50):

            # Create the coin instance
            coin = arcade.Sprite("images/coin_01.png", SPRITE_SCALING / 3)

            # Position the coin
            coin.center_x = random.randrange(SCREEN_WIDTH)
            coin.center_y = random.randrange(SCREEN_HEIGHT)

            # Add the coin to the lists
            self.all_sprites_list.append(coin)
            self.coin_list.append(coin)

        # Don't show the mouse cursor
        self.set_mouse_visible(False)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)
예제 #10
0
    def run(self):

        arcade.set_background_color((127, 127, 255))
        arcade.set_viewport(self.ortho_left, WINDOW_WIDTH + self.ortho_left,
                            0, WINDOW_HEIGHT)
        self.setup_game()

        arcade.run()
예제 #11
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()
    def __init__(self, screen_width, screen_height):
        """ Constructor """
        # Call the parent constructor. Required and must be the first line.
        super().__init__(screen_width, screen_height)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)

        # Start 'state' will be showing the first page of instructions.
        self.current_state = INSTRUCTIONS_PAGE_1
예제 #13
0
파일: window.py 프로젝트: xiro49/CELL_SIM
 def __init__(self):
     super().__init__(SCR_W, SCR_H)
     self.max_pop = 5
     self.frame_count = 0
     self.all_sprites_list = None
     self.cell_list = None
     self.player_sprite = None
     self.view_left = 0
     self.view_bottom = 0
     arcade.set_background_color(arcade.color.BLACK)
     self.time_run = 0      
예제 #14
0
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.all_sprites_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()

        # Set up the player
        self.score = 0
        self.player_sprite = arcade.Sprite("images/character.png",
                                           SPRITE_SCALING)
        self.player_sprite.center_x = 64
        self.player_sprite.center_y = 270
        self.all_sprites_list.append(self.player_sprite)

        map_array = get_map()

        for row_index, row in enumerate(map_array):
            for column_index, item in enumerate(row):

                if item == -1:
                    continue
                elif item == 0:
                    wall = arcade.Sprite("images/boxCrate_double.png",
                                         SPRITE_SCALING)
                elif item == 1:
                    wall = arcade.Sprite("images/grassLeft.png",
                                         SPRITE_SCALING)
                elif item == 2:
                    wall = arcade.Sprite("images/grassMid.png",
                                         SPRITE_SCALING)
                elif item == 3:
                    wall = arcade.Sprite("images/grassRight.png",
                                         SPRITE_SCALING)

                wall.right = column_index * 64
                wall.top = (7 - row_index) * 64
                self.all_sprites_list.append(wall)
                self.wall_list.append(wall)

        self.physics_engine = \
            arcade.PhysicsEnginePlatformer(self.player_sprite,
                                           self.wall_list,
                                           gravity_constant=GRAVITY)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)

        # Set the viewport boundaries
        # These numbers set where we have 'scrolled' to.
        self.view_left = 0
        self.view_bottom = 0

        self.game_over = False
예제 #15
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()
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.all_sprites_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()

        # Set up the player
        self.score = 0
        self.player_sprite = arcade.Sprite("images/character.png",
                                           SPRITE_SCALING)
        self.player_sprite.center_x = 50
        self.player_sprite.center_y = 70
        self.all_sprites_list.append(self.player_sprite)

        for i in range(50):

            # Create the coin instance
            coin = Coin("images/coin_01.png", SPRITE_SCALING / 3)

            # Specify the boundaries for where a coin can be.
            # Take into account that we are specifying a center x and y for the
            # coin, and the coin has a size. So we can't have 0, 0 as the
            # position because 3/4 of the coin would be off-screen. We have to
            # start at half the width of the coin.
            coin.left_boundary = coin.width // 2
            coin.right_boundary = SCREEN_WIDTH - coin.width // 2
            coin.bottom_boundary = coin.height // 2
            coin.top_boundary = SCREEN_HEIGHT - coin.height // 2

            # Create a random starting point for the coin.
            coin.center_x = random.randint(coin.left_boundary,
                                           coin.right_boundary)
            coin.center_y = random.randint(coin.bottom_boundary,
                                           coin.top_boundary)

            # Create a random speed and direction.
            # Note it is possible to get 0, 0 and have a coin not move at all.
            coin.change_x = random.randint(-3, 3)
            coin.change_y = random.randint(-3, 3)

            # Add the coin to the lists
            self.all_sprites_list.append(coin)
            self.coin_list.append(coin)

        # Don't show the mouse cursor
        self.set_mouse_visible(False)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)
예제 #17
0
    def setup(self):
        """
        Set up the application.
        """
        # Create a 2 dimensional array. A two dimensional
        # array is simply a list of lists.
        self.grid = []
        for row in range(10):
            # Add an empty array that will hold each cell
            # in this row
            self.grid.append([])
            for column in range(10):
                self.grid[row].append(0)  # Append a cell

        arcade.set_background_color(arcade.color.BLACK)
예제 #18
0
    def __init__(self):
        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, "Sprites and Bullets Demo")

        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.all_sprites_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()
        self.bullet_list = arcade.SpriteList()

        # Set up the player
        self.score = 0
        self.player_sprite = arcade.Sprite("images/character.png",
                                           SPRITE_SCALING)
        self.player_sprite.center_x = 50
        self.player_sprite.center_y = 70
        self.all_sprites_list.append(self.player_sprite)

        # Load sounds
        self.gun_sound = arcade.sound.load_sound("sounds/laser1.ogg")
        self.hit_sound = arcade.sound.load_sound("sounds/phaseJump1.ogg")

        for i in range(50):

            # Create the coin instance
            coin = arcade.Sprite("images/coin_01.png", SPRITE_SCALING / 3)

            # Position the coin
            coin.center_x = random.randrange(SCREEN_WIDTH)
            coin.center_y = random.randrange(120, SCREEN_HEIGHT)

            # Add the coin to the lists
            self.all_sprites_list.append(coin)
            self.coin_list.append(coin)

        # Don't show the mouse cursor
        self.set_mouse_visible(False)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.all_sprites_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()

        # Set up the player
        self.score = 0
        self.player_sprite = arcade.Sprite("images/character.png",
                                           SPRITE_SCALING)
        self.player_sprite.center_x = 50
        self.player_sprite.center_y = 70
        self.all_sprites_list.append(self.player_sprite)

        for i in range(50):

            # Create the coin instance
            coin = Coin("images/coin_01.png", SPRITE_SCALING / 3)

            # Position the center of the circle the coin will orbit
            coin.circle_center_x = random.randrange(SCREEN_WIDTH)
            coin.circle_center_y = random.randrange(SCREEN_HEIGHT)

            # Random radius from 10 to 200
            coin.radius = random.randrange(10, 200)

            # Random start angle from 0 to 2pi
            coin.angle = random.random() * 2 * math.pi

            # Add the coin to the lists
            self.all_sprites_list.append(coin)
            self.coin_list.append(coin)

        # Don't show the mouse cursor
        self.set_mouse_visible(False)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)
예제 #20
0
    def __init__(self, width, height):
        super().__init__(width, height)
        arcade.set_background_color(arcade.color.DARK_SLATE_GRAY)

        # -- Pymunk
        self.space = pymunk.Space()
        self.space.gravity = (0.0, -900.0)

        # Lists of sprites or lines
        self.sprite_list = arcade.SpriteList()
        self.static_lines = []

        # Used for dragging shapes aruond with the mouse
        self.shape_being_dragged = None
        self.last_mouse_position = 0, 0

        # Create the floor
        floor_height = 80
        body = pymunk.Body(body_type=pymunk.Body.STATIC)
        shape = pymunk.Segment(body, [0, floor_height], [SCREEN_WIDTH, floor_height], 0.0)
        shape.friction = 10
        self.space.add(shape)
        self.static_lines.append(shape)

        # Create the stacks of boxes
        for x in range(6):
            for y in range(12):
                size = 45
                mass = 12.0
                moment = pymunk.moment_for_box(mass, (size, size))
                body = pymunk.Body(mass, moment)
                body.position = pymunk.Vec2d(300 + x*50, (floor_height + size / 2) + y * (size +.01))
                shape = pymunk.Poly.create_box(body, (size, size))
                shape.friction = 0.3
                self.space.add(body,shape)

                sprite = BoxSprite(shape, "images/boxCrate_double.png", width=size, height=size)
                self.sprite_list.append(sprite)
예제 #21
0
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.all_sprites_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()

        # Set up the player
        self.score = 0
        self.player_sprite = arcade.Sprite("images/character.png",
                                           SPRITE_SCALING)
        self.player_sprite.center_x = 50
        self.player_sprite.center_y = 64
        self.all_sprites_list.append(self.player_sprite)

        # -- Set up the walls
        # Create a row of boxes
        for x in range(173, 650, 64):
            wall = arcade.Sprite("images/boxCrate_double.png", SPRITE_SCALING)
            wall.center_x = x
            wall.center_y = 200
            self.all_sprites_list.append(wall)
            self.wall_list.append(wall)

        # Create a column of boxes
        for y in range(273, 500, 64):
            wall = arcade.Sprite("images/boxCrate_double.png", SPRITE_SCALING)
            wall.center_x = 465
            wall.center_y = y
            self.all_sprites_list.append(wall)
            self.wall_list.append(wall)

        self.physics_engine = arcade.PhysicsEngineSimple(self.player_sprite,
                                                         self.wall_list)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)
예제 #22
0
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.all_sprites_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()

        # Set up the player
        self.score = 0
        self.player_sprite = arcade.Sprite("images/character.png",
                                           0.4)
        self.player_sprite.center_x = 64
        self.player_sprite.center_y = 270
        self.all_sprites_list.append(self.player_sprite)

        # -- Set up several columns of walls
        for x in range(200, 1650, 210):
            for y in range(0, 1000, 64):
                # Randomly skip a box so the player can find a way through
                if random.randrange(5) > 0:
                    wall = arcade.Sprite("images/boxCrate_double.png",
                                         SPRITE_SCALING)
                    wall.center_x = x
                    wall.center_y = y
                    self.all_sprites_list.append(wall)
                    self.wall_list.append(wall)

        self.physics_engine = arcade.PhysicsEngineSimple(self.player_sprite,
                                                         self.wall_list)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)

        # Set the viewport boundaries
        # These numbers set where we have 'scrolled' to.
        self.view_left = 0
        self.view_bottom = 0
    def __init__(self, screen_width, screen_height):
        """ Constructor """
        # Call the parent constructor. Required and must be the first line.
        super().__init__(screen_width, screen_height)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)

        # Start 'state' will be showing the first page of instructions.
        self.current_state = INSTRUCTIONS_PAGE_0

        self.all_sprites_list = None
        self.coin_list = None

        # Set up the player
        self.score = 0
        self.player_sprite = None

        self.instructions = []
        texture = arcade.load_texture("images/instructions_0.png")
        self.instructions.append(texture)

        texture = arcade.load_texture("images/instructions_1.png")
        self.instructions.append(texture)
 def setup(self):
     arcade.set_background_color(BACKGROUND_COLOR)
     self.pic_list = arcade.SpriteList()
     self.pic_list.append(AdaOrPotato())
예제 #25
0
import arcade
"""
this is a sample program to show how to draw using Python programming
language and the Arcade Library.
"""

# open a window to draw on

arcade.open_window(600, 600, "drawing example")

# set background color
arcade.set_background_color(arcade.color.AERO_BLUE)
# get ready to draw (render)
arcade.start_render()

# this is where drawing code goes
# Draw a rectangle
# Left of 5, right of 35
# Top of 590, bottom of 570
arcade.draw_lrtb_rectangle_filled(5, 35, 590, 570, arcade.color.BITTER_LIME)

# Different way to draw a rectangle
# Center rectangle at (100, 520) with a width of 45 and height of 25
arcade.draw_rectangle_filled(100, 520, 45, 25, arcade.color.BLUSH)

# Rotate a rectangle
# Center rectangle at (200, 520) with a width of 45 and height of 25
# Also, rotate it 45 degrees.
arcade.draw_rectangle_filled(200, 520, 45, 25, arcade.color.BLUSH, 45)

# Draw a point at (50, 580) that is 5 pixels large
예제 #26
0
    def setup(self):

        # Set background color to black
        arcade.set_background_color(arcade.color.BLACK)
예제 #27
0
    def setup(self, level):
        """ Set up the game here. Call this function to restart the game. """

        # Used to keep track of our scrolling
        self.view_bottom = 0
        self.view_left = 0

        # Keep track of the score
        self.score = 0

        # Create the Sprite lists
        self.player_list = arcade.SpriteList()
        self.foreground_list = arcade.SpriteList()
        self.background_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()

        # Set up the player, specifically placing it at these coordinates.
        self.player_sprite = arcade.Sprite("images/player_1/player_stand.png", CHARACTER_SCALING)
        self.player_sprite.center_x = PLAYER_START_X
        self.player_sprite.center_y = PLAYER_START_Y
        self.player_list.append(self.player_sprite)

        # --- Load in a map from the tiled editor ---

        # Name of the layer in the file that has our platforms/walls
        platforms_layer_name = 'Platforms'
        # Name of the layer that has items for pick-up
        coins_layer_name = 'Coins'
        # Name of the layer that has items for foreground
        foreground_layer_name = 'Foreground'
        # Name of the layer that has items for background
        background_layer_name = 'Background'
        # Name of the layer that has items we shouldn't touch
        dont_touch_layer_name = "Don't Touch"

        # Map name
        map_name = f"map2_level_{level}.tmx"
        # Read in the tiled map
        my_map = arcade.read_tiled_map(map_name, TILE_SCALING)

        # -- Walls
        # Grab the layer of items we can't move through
        map_array = my_map.layers_int_data[platforms_layer_name]

        # Calculate the right edge of the my_map in pixels
        self.end_of_map = len(map_array[0]) * GRID_PIXEL_SIZE

        # -- Background
        self.background_list = arcade.generate_sprites(my_map, background_layer_name, TILE_SCALING)

        # -- Foreground
        self.foreground_list = arcade.generate_sprites(my_map, foreground_layer_name, TILE_SCALING)

        # -- Platforms
        self.wall_list = arcade.generate_sprites(my_map, platforms_layer_name, TILE_SCALING)

        # -- Platforms
        self.wall_list = arcade.generate_sprites(my_map, platforms_layer_name, TILE_SCALING)

        # -- Coins
        self.coin_list = arcade.generate_sprites(my_map, coins_layer_name, TILE_SCALING)

        # -- Don't Touch Layer
        self.dont_touch_list = arcade.generate_sprites(my_map, dont_touch_layer_name, TILE_SCALING)

        self.end_of_map = (len(map_array[0]) - 1) * GRID_PIXEL_SIZE

        # --- Other stuff
        # Set the background color
        if my_map.backgroundcolor:
            arcade.set_background_color(my_map.backgroundcolor)

        # Create the 'physics engine'
        self.physics_engine = arcade.PhysicsEnginePlatformer(self.player_sprite,
                                                             self.wall_list,
                                                             GRAVITY)
예제 #28
0
    def game_setup(self, level):# 게임 화면 초기화(init)     #초기값 설정
        """ Set up the game here. Call this function to restart the game. """
        # Used to keep track of our scrolling
        self.view_bottom = 0
        self.view_left = 0

        #몬스터 리셋
        for i in range(len(self.monster)):
            del self.monster[0]
            del self.monster_sprite[0]
            del self.monster_physics_engine[0]
        #움직이는 플랫폼 리셋
        for i in range(len(self.platform)):
            del self.platform[0]
            del self.platform_sprite[0]
            del self.platform_physics_engine[0]

        # Create the Sprite lists
        self.player_list = arcade.SpriteList()
        self.button_list = arcade.SpriteList()
        self.foreground_list = arcade.SpriteList()
        self.background_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()
        self.monster_list = arcade.SpriteList()
        self.platform_list = arcade.SpriteList()

        self.ladder_list = None # 사다리 리스트

        level_list = {
            1: self.map_level_1,
            2: self.map_level_2,
            3: self.map_level_3,
            4: self.map_level_4,
            5: self.map_level_5,
            6: self.map_level_6,
            }


        #레벨함수 호출 (레벨마다의 설정)
        level_list[self.level]()

        #라이프가 초기화 되지 않게

        if self.bool_life == True:
            self.life = 10
        self.bool_life = False


        #캐릭터
        self.player_sprite = PlayerCharacter()
        self.player_sprite.center_x = PLAYER_START_X
        self.player_sprite.center_y = PLAYER_START_Y
        self.player_list.append(self.player_sprite)



        # --- Load in a map from the tiled editor ---

        # Name of the layer in the file that has our platforms/walls
        platforms_layer_name = 'Platforms'
        # Name of the layer that has items for pick-up
        coins_layer_name = 'Coins'
        # Name of the layer that has items for foreground
        foreground_layer_name = 'Foreground'
        # Name of the layer that has items for background
        background_layer_name = 'Background'
        # Name of the layer that has items we shouldn't touch
        dont_touch_layer_name = "Don't Touch"
        #사다리 레이어
        ladders_layer_name = "Ladders"

        #맵 이름
        map_name = f"map2_level_{level}.tmx"
        # Read in the tiled map
        my_map = arcade.read_tiled_map(map_name, TILE_SCALING)

        # -- Walls
        # Grab the layer of items we can't move through
        map_array = my_map.layers_int_data[platforms_layer_name]

        #맵에서 오른 쪽 끝자리를 계산 (다음 맵으로)
        self.end_of_map = len(map_array[0]) * GRID_PIXEL_SIZE - 120

        # -- Background(my_map, "background", 0.5)
        self.background_list = arcade.generate_sprites(my_map, background_layer_name, TILE_SCALING)

        # -- Foreground
        self.foreground_list = arcade.generate_sprites(my_map, foreground_layer_name, TILE_SCALING)

        # -- Platforms
        self.wall_list = arcade.generate_sprites(my_map, platforms_layer_name, TILE_SCALING)
        # -- Coins
        self.coin_list = arcade.generate_sprites(my_map, coins_layer_name, TILE_SCALING)

        # -- Don't Touch Layer
        #여기서 맵.tmx파일이랑 연동?
        self.dont_touch_list = arcade.generate_sprites(my_map, dont_touch_layer_name, TILE_SCALING)


        # --- Other stuff
        # Set the background color
        if my_map.backgroundcolor:
            arcade.set_background_color(my_map.backgroundcolor)

        # #사다리가 있는 4번 맵


        # #플레이어의 움직임
        self.ladder_list = arcade.generate_sprites(my_map, ladders_layer_name, TILE_SCALING)

        self.player_physics_engine = arcade.PhysicsEnginePlatformer(self.player_sprite,self.wall_list,gravity_constant=GRAVITY,ladders=self.ladder_list)
        print(self.player_physics_engine)


        #몬스터들은 중력에 영향이 없음
        for i in range(len(self.monster)):
            self.monster_physics_engine.append(arcade.PhysicsEnginePlatformer(self.monster_sprite[i], self.wall_list, 0))

        #플랫폼들은 중력에 영향이 없음(wall_list랑은 다름)
        for i in range(len(self.platform)):
            self.platform_physics_engine.append(arcade.PhysicsEnginePlatformer(self.platform_sprite[i],self.wall_list, 0))
예제 #29
0
파일: scrabble.py 프로젝트: Aeryan/Snakes
 def on_show_view(self):
     self.setup()
     arcade.set_background_color(arcade.color.WHITE)
예제 #30
0
파일: scrabble.py 프로젝트: Aeryan/Snakes
 def on_key_press(self, key, _modifiers):
     if key == arcade.key.ESCAPE:
         arcade.set_background_color(arcade.color.GREEN)
         self.scrabView.setup_ui()
         self.window.show_view(self.scrabView)
 def setup(self):
     arcade.set_background_color(BACKGROUND_COLOR)
     self.logo_list = arcade.SpriteList()
     self.logo_list.append(Cisc108Logo())
예제 #32
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()
예제 #33
0
파일: scrabble.py 프로젝트: Aeryan/Snakes
 def on_show_view(self):
     ui_manager.purge_ui_elements()
     arcade.set_background_color(arcade.color.WHITE)
예제 #34
0
def on_draw(delta_time):
    """ Use this function to draw everything to the screen. """

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

    # Draw shapes
    arcade.draw_all(shapes)


arcade.open_window("Drawing Example", 800, 600)

#sets the background color
arcade.set_background_color(arcade.color.SKY_BLUE)

shapes = []

#Green Hills in background
on_draw.hills = arcade.Ellipse(10,100,250,200,arcade.color.GREEN)
shapes.append(on_draw.hills)
on_draw.hills = arcade.Ellipse(400,10,250,200,arcade.color.GREEN)
shapes.append(on_draw.hills)
on_draw.hills = arcade.Ellipse(800,70,250,200,arcade.color.GREEN)
shapes.append(on_draw.hills)

#The cool sun
on_draw.sun = arcade.Circle(500,500,70,arcade.color.YELLOW)
shapes.append(on_draw.sun)
예제 #35
0
"""
This is a sample program to show how to draw using the Python programming
language and the Arcade library.
"""

# Import the "arcade" library
import arcade

# Open up a window.
# From the "arcade" library, use a function called "open_window"
# Set the window title to "Drawing Example"
# Set the and dimensions (width and height)
arcade.open_window(800, 600, "Drawing Example")

# Set the background color
arcade.set_background_color(arcade.color.AIR_SUPERIORITY_BLUE)

# Get ready to draw
arcade.start_render()

# Draw the grass
arcade.draw_lrtb_rectangle_filled(0, 800, 200, 0, arcade.color.BITTER_LIME)

# --- Draw the barn ---

# Barn cement base
arcade.draw_lrtb_rectangle_filled(30, 350, 210, 170, arcade.color.BISQUE)

# Bottom half
arcade.draw_lrtb_rectangle_filled(30, 350, 350, 210, arcade.color.BROWN)
예제 #36
0
    def __init__(self, width, height):
        super().__init__(width, height)

        arcade.set_background_color(arcade.color.AMAZON)
예제 #37
0
You must use multiple colors.
You must have a coherent picture. No abstract art with random shapes.
You must use multiple types of graphic functions (e.g. circles, rectangles, lines, etc.)
Somewhere you must include a WHILE or FOR loop to create a repeating pattern.
Do not just redraw the same thing in the same location 10 times. 
You can contain multiple drawing commands in a loop, so you can draw multiple train cars for example.
Please use comments and blank lines to make it easy to follow your program. 
If you have 5 lines that draw a robot, group them together with blank lines above and below. 
Then add a comment at the top telling the reader what you are drawing.
After you have showed your picture to your instructor, screenshot your picture,
name it firstname_lastname.jpg and use the submit button to e-mail it to your instructor
'''
import arcade, random
circle_x = 0
arcade.open_window(500, 500, "Picasso Project")  #Creates the window
arcade.set_background_color(
    arcade.color.SKY_BLUE)  #Makes background color sky color
arcade.start_render()
arcade.draw_circle_filled(300, 400, 100, arcade.color.SUNGLOW)

for i in range(6):  #Generates Clouds
    y = random.randrange(200, 450)
    x = random.randrange(1, 501)
    for i in range(random.randrange(4, 8)):
        arcade.draw_circle_filled(x, y, 30, arcade.color.LIGHT_GRAY)
        x += 30

for i in range(1):  #Generates the grass
    for i in range(25):
        arcade.draw_circle_filled(circle_x, 25, 25, arcade.color.GO_GREEN)
        circle_x += 25
예제 #38
0
 def __init__(self, width, height, title):
     super().__init__(width, height, title)
     self.set_mouse_visible(True)
     arcade.set_background_color(open_color.black)
     self.ball_list = []
예제 #39
0
 def on_show(self):
     """ This is run once when we switch to this view """
     arcade.set_background_color(arcade.csscolor.GREEN)
예제 #40
0
 def on_show(self):
     arcade.set_background_color(arcade.color.AMAZON)
예제 #41
0
 def __init__(self, width, height):
     super().__init__(width, height)
     arcade.set_background_color(arcade.color.AMAZON)
예제 #42
0
 def on_show(self):
     arcade.set_background_color(arcade.color.WHITE)
예제 #43
0
# Size of the rectangle
RECT_WIDTH = 50
RECT_HEIGHT = 50


def on_draw(delta_time):
    """
    Use this function to draw everything to the screen.
    This function will be called over and over because of the "schedule"
    command below.
    """

    arcade.start_render()

    # Draw a rectangle.
    arcade.draw_rectangle_filled(100, 50, RECT_WIDTH, RECT_HEIGHT,
                                 arcade.color.ALIZARIN_CRIMSON)


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

# The "schedule" command
# Tell the computer to call the draw command 80 times per second
arcade.schedule(on_draw, 1 / 80)

# Run the program
arcade.run()
예제 #44
0
import arcade
import Piece

SCREEN_W = 800
SCREEN_H = 600

arcade.open_window(SCREEN_W, SCREEN_H, "First shot !")
arcade.set_background_color((51, 153, 255))
arcade.start_render()

# Board 10*20
arcade.draw_rectangle_outline(300, 300, 252, 502, arcade.color.CERULEAN_BLUE,
                              2)

# 1 Shape
# TODO : position = possition possible on board
newPiece = Piece.Shape((300, 300))
newPiece.drawShape()

arcade.finish_render()
arcade.run()
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.wall_list = arcade.SpriteList()
        self.enemy_list = arcade.SpriteList()
        self.player_list = arcade.SpriteList()

        # Draw the walls on the bottom
        for x in range(0, SCREEN_WIDTH, SPRITE_SIZE):
            wall = arcade.Sprite(":resources:images/tiles/grassMid.png", SPRITE_SCALING)

            wall.bottom = 0
            wall.left = x
            self.wall_list.append(wall)

        # Draw the platform
        for x in range(SPRITE_SIZE * 3, SPRITE_SIZE * 8, SPRITE_SIZE):
            wall = arcade.Sprite(":resources:images/tiles/grassMid.png", SPRITE_SCALING)

            wall.bottom = SPRITE_SIZE * 3
            wall.left = x
            self.wall_list.append(wall)

        # Draw the crates
        for x in range(0, SCREEN_WIDTH, SPRITE_SIZE * 5):
            wall = arcade.Sprite(":resources:images/tiles/boxCrate_double.png", SPRITE_SCALING)

            wall.bottom = SPRITE_SIZE
            wall.left = x
            self.wall_list.append(wall)

        # -- Draw an enemy on the ground
        enemy = arcade.Sprite(":resources:images/enemies/wormGreen.png", SPRITE_SCALING)

        enemy.bottom = SPRITE_SIZE
        enemy.left = SPRITE_SIZE * 2

        # Set enemy initial speed
        enemy.change_x = 2
        self.enemy_list.append(enemy)

        # -- Draw a enemy on the platform
        enemy = arcade.Sprite(":resources:images/enemies/wormGreen.png", SPRITE_SCALING)

        enemy.bottom = SPRITE_SIZE * 4
        enemy.left = SPRITE_SIZE * 4

        # Set boundaries on the left/right the enemy can't cross
        enemy.boundary_right = SPRITE_SIZE * 8
        enemy.boundary_left = SPRITE_SIZE * 3
        enemy.change_x = 2
        self.enemy_list.append(enemy)

        # -- Set up the player
        self.player_sprite = arcade.Sprite(":resources:images/animated_characters/female_person/femalePerson_idle.png", SPRITE_SCALING)
        self.player_list.append(self.player_sprite)

        # Starting position of the player
        self.player_sprite.center_x = 64
        self.player_sprite.center_y = 270

        self.physics_engine = arcade.PhysicsEnginePlatformer(self.player_sprite,
                                                             self.wall_list,
                                                             gravity_constant=GRAVITY)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)
예제 #46
0
 def on_show(self):
     """ This is run once when we switch to this view """
     #tbd try catch clause
     arcade.set_background_color(const.SCREEN_COLOR)        
예제 #47
0
 def on_show(self):
     arcade.set_background_color(arcade.color.ORANGE)
예제 #48
0
    def __init__(self, width, height):
        super().__init__(width, height, title="Drawing Text Example")

        arcade.set_background_color(arcade.color.WHITE)
        self.text_angle = 0
        self.time_elapsed = 0.0
    def setup(self):
        """ Set up the game and initialize the variables. """

        self.wall_list = arcade.SpriteList()
        self.enemy_list = arcade.SpriteList()
        self.player_list = arcade.SpriteList()
        self.coin_list = arcade.SpriteList()

        for x in range(0, SCREEN_WIDTH, SPRITE_SIZE):
            wall = arcade.Sprite(
                "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/rpgTile019.png",
                SPRITE_SCALING)

            wall.bottom = 0
            wall.left = x
            self.wall_list.append(wall)

        # Draw the platform
        for x in range(SPRITE_SIZE * 3, SPRITE_SIZE * 8, SPRITE_SIZE):
            wall = arcade.Sprite(
                "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/rpgTile019.png",
                SPRITE_SCALING)

            wall.bottom = SPRITE_SIZE * 3
            wall.left = x
            self.wall_list.append(wall)

        # Draw the crates
        for x in range(0, SCREEN_WIDTH, SPRITE_SIZE * 5):
            wall = arcade.Sprite(
                "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/boxCrate_double.png",
                SPRITE_SCALING)

            wall.bottom = SPRITE_SIZE
            wall.left = x
            self.wall_list.append(wall)

        for i in range(7):

            # Create the coin instance
            coin = arcade.Sprite(
                "C:\Git\Skoli-haust-2020\Forritun\Verkefni með einkunn\Lokaverkefni\images\coinGold.png",
                SPRITE_SCALING / 2)

            # Position the coin
            coin.center_x = random.randrange(SCREEN_WIDTH)
            coin.center_y = random.randrange(600)

            # Add the coin to the lists
            self.coin_list.append(coin)
        # -- Draw an enemy on the ground
        enemy = arcade.Sprite(
            "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/character_zombie_idle.png",
            SPRITE_SCALING)

        enemy.bottom = SPRITE_SIZE
        enemy.left = SPRITE_SIZE * 2

        # Set enemy initial speed
        enemy.change_x = 2
        self.enemy_list.append(enemy)

        # -- Draw a enemy on the platform
        enemy = arcade.Sprite(
            "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/character_zombie_idle.png",
            SPRITE_SCALING)

        enemy.bottom = SPRITE_SIZE * 4
        enemy.left = SPRITE_SIZE * 4

        # Set boundaries on the left/right the enemy can't cross
        enemy.boundary_right = SPRITE_SIZE * 8
        enemy.boundary_left = SPRITE_SIZE * 3
        enemy.change_x = 2
        self.enemy_list.append(enemy)

        # -- Set up the player
        self.player_sprite = arcade.Sprite(
            "C:/Git/Skoli-haust-2020/Forritun/Verkefni með einkunn/Lokaverkefni/images/character1.png",
            SPRITE_SCALING)
        self.player_list.append(self.player_sprite)

        # Starting position of the player
        self.player_sprite.center_x = 64
        self.player_sprite.center_y = 270

        self.physics_engine = arcade.PhysicsEnginePlatformer(
            self.player_sprite, self.wall_list, gravity_constant=GRAVITY)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)
예제 #50
0
    def on_draw(self):
        arcade.start_render()
        if self.page_number == 0:
            arcade.draw_circle_filled(50, 50, 500, arcade.color.WHITE)
            arcade.set_background_color(arcade.color.GRAY)
            if time() - self.time_check >= 1:
                self.motion = randint(0, 2)
                self.time_check = time()
            pic = [
                arcade.load_texture('pics/menu/menu1.png'),
                arcade.load_texture('pics/menu/menu2.png', ),
                arcade.load_texture('pics/menu/menu3.png')
            ]
            # For menu pic
            for each_pic in pic:
                self.set_center(each_pic)
            arcade.draw_texture_rectangle(pic[self.motion].center_x,
                                          pic[self.motion].center_y,
                                          texture=pic[self.motion],
                                          height=700,
                                          width=900)
            #For 1.3.7
            #arcade.draw_text('Press ENTER to start the game', 0, 100, arcade.color.AMETHYST, width=self.width,
            #                    font_size=35)
            arcade.draw_text('Press ENTER to start the game',
                             0,
                             100,
                             arcade.color.AMETHYST,
                             font_size=35)
            arcade.draw_text('Just An Ordinary Dungeon Crawler game',
                             0,
                             200,
                             arcade.color.GOLD_FUSION,
                             font_size=50,
                             width=3500)

        elif self.page_number == -1:
            self.menu.draw()

        elif self.page_number == 1:
            arcade.draw_texture_rectangle(self.bg.center_x,
                                          self.bg.center_y,
                                          texture=self.bg,
                                          height=600,
                                          width=800)
            self.player.draw()
            self.enemy_type.draw()
            self.player.attack(self.time_check)
            self.map.map_component()
            arcade.draw_text(f'The current level is {self.level}',
                             self.width - 200, self.height - 100,
                             arcade.color.BLACK)
            arcade.draw_text(f'Current life {self.player.life}', 100,
                             self.height - 100, arcade.color.BLACK)
            arcade.draw_text(f'Current Money {self.MONEY}',
                             self.width // 2 - 50, self.height - 100,
                             arcade.color.BLACK)
            self.shield.draw()
            if self.hurt_status:
                arcade.draw_rectangle_outline(self.width // 2,
                                              self.height // 2, self.width,
                                              self.height, arcade.color.RED,
                                              10)
                if time() - self.hurt_time >= 1.5:
                    self.hurt_status = False

        elif self.page_number == -3 or self.page_number == -2:
            tutorial = arcade.load_texture('pics/scene/t2.png')
            if self.page_number == -2:
                tutorial = arcade.load_texture('pics/scene/t1.png')
            self.set_center(tutorial)
            arcade.draw_texture_rectangle(tutorial.center_x,
                                          tutorial.center_y,
                                          texture=tutorial,
                                          height=600,
                                          width=800)

        elif self.page_number == 3:
            bonus = arcade.load_texture('pics/game_over/game.png')
            self.set_center(bonus)
            arcade.draw_texture_rectangle(bonus.center_x,
                                          bonus.center_y,
                                          texture=bonus,
                                          height=700,
                                          width=900)
        self.dialog.on_draw(self.dialog_status)
예제 #51
0
    def start_new_game(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.all_sprites_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()

        # Set up the player
        self.score = 0
        self.player_sprite = arcade.Sprite("images/character.png",
                                           SPRITE_SCALING)
        self.player_sprite.center_x = 64
        self.player_sprite.center_y = 270
        self.all_sprites_list.append(self.player_sprite)

        map_array = get_map()

        map_items = ["images/boxCrate_double.png",
                     "images/grassCenter.png",
                     "images/grassCorner_left.png",
                     "images/grassCorner_right.png",
                     "images/grassHill_left.png",
                     "images/grassHill_right.png",
                     "images/grassLeft.png",
                     "images/grassMid.png",
                     "images/grassRight.png",
                     "images/stoneHalf.png"
                     ]
        for row_index, row in enumerate(map_array):
            for column_index, item in enumerate(row):

                if item == -1:
                    continue
                else:
                    wall = arcade.Sprite(map_items[item],
                                         SPRITE_SCALING)

                    # Change the collision polygon to be a ramp instead of
                    # a rectangle
                    if item == 4:
                        wall.points = ((-wall.width // 2, wall.height // 2),
                                       (wall.width // 2, -wall.height // 2),
                                       (-wall.width // 2, -wall.height // 2))
                    elif item == 5:
                        wall.points = ((-wall.width // 2, -wall.height // 2),
                                       (wall.width // 2, -wall.height // 2),
                                       (wall.width // 2, wall.height // 2))

                wall.right = column_index * 64
                wall.top = (7 - row_index) * 64
                self.all_sprites_list.append(wall)
                self.wall_list.append(wall)

        self.physics_engine = \
            arcade.PhysicsEnginePlatformer(self.player_sprite,
                                           self.wall_list,
                                           gravity_constant=GRAVITY)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)

        # Set the viewport boundaries
        # These numbers set where we have 'scrolled' to.
        self.view_left = 0
        self.view_bottom = 0

        self.game_over = False
예제 #52
0
language and the Arcade library.

Lab 01: First Program
"""

# Import the "arcade" library
import arcade

# Open up a window.
# From the "arcade" library, use a function called "open_window"
# Set the window title to "Drawing Example"
# Set the dimensions (width and height)
arcade.open_window(600, 600, "First Program")

# Set the background color
arcade.set_background_color(arcade.csscolor.SKY_BLUE)

# Get ready to draw
arcade.start_render()

# Draw a rectangle for the ground
# Left of 0, right of 599
# Top of 300, bottom of 0
arcade.draw_lrtb_rectangle_filled(0, 599, 300, 0, arcade.csscolor.GREEN)

# Tree trunk
# Center of 100, 320
# Width of 20
# Height of 60
arcade.draw_rectangle_filled(100, 320, 20, 60, arcade.csscolor.SIENNA)
예제 #53
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()
 def __init__(self, width, height):
     super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
     arcade.set_background_color(arcade.color.WHITE)
예제 #55
0
"""

# 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)

# Draw horizontal lines every 200 pixels
for y in range(0, 601, 200):
    arcade.draw_line(0, y, 800, y, arcade.color.WHITE, 2)

# Draw a point
arcade.draw_text("draw_point", 7, 405, arcade.color.WHITE, 12)
예제 #56
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()

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

#(x,y,width,height,color)
arcade.draw_ellipse_filled(365, 385, 15, 25, open_color.black)
arcade.draw_ellipse_filled(315, 385, 15, 25, open_color.black)
arcade.draw_circle_filled(365, 385, 3, open_color.gray_2)
arcade.draw_circle_filled(315, 385, 3, open_color.gray_2)

#(x,y,width,height,color,start_degrees,end_degrees,border_thickness)
arcade.draw_arc_outline(350, 350, 60, 50, open_color.black, 190, 350, 4)

# Finish the render
# Nothing will be drawn without this.
# Must happen after all draw commands
arcade.finish_render()
예제 #57
0
 def load(self):
     arcade.set_background_color(arcade.color.AMAZON)
     self.gameState = GameState.RUNNING
예제 #58
0
def main():
    global rows, x, y
    screen = Game(WIDTH, HEIGHT, "TicTacToe")
    game.set_background_color(Colors.black)

    game.run()