コード例 #1
0
    def primitive_create(self):
        circle1 = arcade.create_ellipse_filled(self.x1, self.y1, self.mass1,
                                               self.mass1, self.color)
        circle2 = arcade.create_ellipse_filled(self.x2, self.y2, self.mass2,
                                               self.mass2, self.color)
        line1 = arcade.create_line(self.offsetX, self.offsetY, self.x1,
                                   self.y1, self.color, self.linewidth)
        line2 = arcade.create_line(self.x1, self.y1, self.x2, self.y2,
                                   self.color, self.linewidth)
        trail = arcade.create_line_strip(self.traillist, self.color,
                                         self.trailwidth)

        self.circle1 = arcade.ShapeElementList()
        self.circle1.append(circle1)

        self.circle2 = arcade.ShapeElementList()
        self.circle2.append(circle2)

        self.line1 = arcade.ShapeElementList()
        self.line1.append(line1)

        self.line2 = arcade.ShapeElementList()
        self.line2.append(line2)

        self.trail = arcade.ShapeElementList()
コード例 #2
0
    def draw_planes(self, planes=list):
        self.plane_list = None
        self.plane_list = arcade.ShapeElementList()
        for plane in planes:
            if self._draw_planes:
                for (i, j) in plane.edges:
                    p0 = plane.box_intersections[i]
                    p1 = plane.box_intersections[j]

                    dot = arcade.create_ellipse(*p0[:2], 5, 5,
                                                arcade.color.LIGHT_GRAY)
                    self.plane_list.append(dot)
                    dot = arcade.create_ellipse(*p1[:2], 5, 5,
                                                arcade.color.LIGHT_GRAY)
                    self.plane_list.append(dot)

                    line = arcade.create_line(*p0[:2], *p1[:2],
                                              arcade.color.LIGHT_GRAY, 1)
                    self.plane_list.append(line)

            point = arcade.create_ellipse(*plane.point[:2], 5, 5,
                                          arcade.color.LIGHT_GREEN)
            start = plane.point
            end1 = plane.point + 15 * plane.unitnormal
            end2 = plane.point - 15 * plane.unitnormal
            normal1 = arcade.create_line(*start[:2], *end1[:2],
                                         arcade.color.LIGHT_GREEN, 1)
            normal2 = arcade.create_line(*start[:2], *end2[:2],
                                         arcade.color.LIGHT_RED_OCHRE, 1)
            self.plane_list.append(point)
            self.plane_list.append(normal1)
            self.plane_list.append(normal2)

            self.draw_plane_holes(plane)
コード例 #3
0
ファイル: main.py プロジェクト: Hawa1999/finalwork
def main():
    file_name = input("Enter a file name: ")
    data = list()
    lines = open(file_name, 'r')
    for line in lines.readlines():
        split_line = line.split(":")
        split_line[0] = split_line[0].strip()
        split_line[1] = int(split_line[1].strip())
        data.append(split_line)
    lines.close()
    arcade.open_window(800, 800, "project3")
    arcade.set_background_color(arcade.color.FAWN)
    yaxis = arcade.create_line(30, 100, 30, 800, arcade.color.KOBE)
    xaxis = arcade.create_line(30, 100, 800, 100, arcade.color.AVOCADO)
    bar_width = 50
    y_scale = 30
    y_offset = 100
    x_offset = 100
    colors = [
        arcade.color.AVOCADO, arcade.color.BALL_BLUE,
        arcade.color.BANANA_MANIA, arcade.color.ARSENIC,
        arcade.color.ANTIQUE_WHITE, arcade.color.BITTERSWEET
    ]
    bars = []
    for i in range(len(data)):
        height = data[i][1]
        bars.append(
            arcade.create_rectangle_filled(
                x_offset + i * bar_width * 2,
                y_offset + int(height) / 4 * y_scale, bar_width,
                height / 2 * y_scale,
                colors[random.randint(0,
                                      len(colors) - 1)]))
    text_width = 15
    # paul = arcade.create_rectangle_filled(100, 100, 70, 100, arcade.color.AMARANTH_PURPLE)
    # haleh = arcade.create_rectangle_filled(200, 110, 70, 120, arcade.color.ANTIQUE_WHITE)
    # enping = arcade.create_rectangle_filled(300, 120, 70, 140, arcade.color.AVOCADO)
    # michael = arcade.create_rectangle_filled(400, 130, 70, 160, arcade.color.BALL_BLUE)
    # seikyung = arcade.create_rectangle_filled(500, 140, 70, 180, arcade.color.ARSENIC)
    # john = arcade.create_rectangle_filled(600, 150, 70, 200, arcade.color.BANANA_MANIA)
    # abdul = arcade.create_rectangle_filled(700, 160, 70, 220, arcade.color.BITTERSWEET)
    # text1 = arcade.draw_text("paul", 75, 30, arcade.color.AMARANTH_PURPLE)
    # text2 = arcade.draw_text("haleh", 175, 30, arcade.color.ANTIQUE_WHITE)
    # text3 = arcade.draw_text("enping", 270, 30, arcade.color.AVOCADO)
    # text4 = arcade.draw_text("michael", 370, 30, arcade.color.BALL_BLUE)
    # text5 = arcade.draw_text("seikyung", 470, 30, arcade.color.ARSENIC)
    # text6 = arcade.draw_text("john", 570, 30, arcade.color.BANANA_MANIA)
    # text7 = arcade.draw_text("abdul", 670, 30, arcade.color.BITTERSWEET)
    arcade.start_render()
    for bar in bars:
        bar.draw()
    for i in range(len(data)):
        arcade.draw_text(data[i][0], i * bar_width + x_offset, 80,
                         arcade.color.BARN_RED)
    yaxis.draw()
    xaxis.draw()
    arcade.finish_render()
    arcade.run()
コード例 #4
0
    def __init__(self, width=1000, height=600):
        super().__init__()

        color = (255, 255, 255)
        gate_width = 100
        gate_height = 300

        self.width = width
        self.width = height

        self.points = [[-width / 2, gate_height / 2, -width / 2, height / 2],
                       [-width / 2, height / 2, width / 2, height / 2],
                       [width / 2, height / 2, width / 2, gate_height / 2],
                       [-width / 2, -gate_height / 2, -width / 2, -height / 2],
                       [-width / 2, -height / 2, width / 2, -height / 2],
                       [width / 2, -height / 2, width / 2, -gate_height / 2]]

        for [s_x, s_y, e_x, e_y] in self.points:
            self.append(
                arcade.create_line(s_x,
                                   s_y,
                                   e_x,
                                   e_y,
                                   color=color,
                                   line_width=5))

        points = [(-width / 2 - gate_width, -gate_height / 2),
                  (-width / 2 - gate_width, +gate_height / 2),
                  (-width / 2, +gate_height / 2),
                  (-width / 2, -gate_height / 2)]
        self.gate_b = arcade.create_rectangle_filled_with_colors(
            point_list=points, color_list=[(40, 40, 200)] * len(points))

        self.gate_b.center_x = SCREEN_WIDTH / 2 - width / 2 - gate_width / 2
        self.gate_b.center_y = SCREEN_HEIGHT / 2

        points = [(width / 2 + gate_width, -gate_height / 2),
                  (width / 2 + gate_width, +gate_height / 2),
                  (width / 2, +gate_height / 2), (width / 2, -gate_height / 2)]
        self.gate_r = arcade.create_rectangle_filled_with_colors(
            point_list=points, color_list=[(200, 40, 40)] * len(points))

        self.gate_r.center_x = SCREEN_WIDTH / 2 + width / 2 + gate_width / 2
        self.gate_r.center_y = SCREEN_HEIGHT / 2

        self.center_x = SCREEN_WIDTH / 2
        self.center_y = SCREEN_HEIGHT / 2

        self.append(self.gate_b)
        self.append(self.gate_r)
        self.append(
            arcade.create_line(s_x, s_y, e_x, e_y, color=color, line_width=5))
        self.append(
            arcade.create_line(s_x, s_y, e_x, e_y, color=color, line_width=5))
コード例 #5
0
def main():
    arcade.open_window(800, 800, "Bar Graph")
    arcade.set_background_color(arcade.color.WHITE)

    #asking for input from user
    file_picker = input("What file should I graph?")
    #open and read .txt file
    infile1 = open(file_picker)
    #infile1 = open("input1.txt", 'r')
    readfile1 = infile1.readlines()

    arcade.start_render()

    colors_list = [
        arcade.color.BLACK, arcade.color.GREEN, arcade.color.RED,
        arcade.color.BLUE, arcade.color.YELLOW, arcade.color.ORANGE,
        arcade.color.PURPLE, arcade.color.TURQUOISE, arcade.color.BROWN,
        arcade.color.GRAY
    ]

    bar_sep = 0
    for item in readfile1:
        split_item = item.split(':')
        xpos = int(split_item[1])
        name = split_item[0]
        #height = int(split_item[2])
        current_color = random.choice(colors_list)
        #center_y = int(ypos+height)/2
        #arcade.draw_rectangle_filled(xpos, center_y, 50, height, current_color)
        from_bottom = 200
        rectangle_height = xpos * 10
        rectangle_width = 50
        print(name)
        bar_sep = bar_sep + 100
        #foo = arcade.create_rectangle_filled(counter, upstart + (xpos*10), 50, upstart, current_color)
        foo = arcade.create_rectangle_filled(
            bar_sep, from_bottom + rectangle_height / 2, rectangle_width,
            rectangle_height, current_color)
        foo.draw()
        arcade.draw_text(name, bar_sep - (rectangle_width / 2),
                         from_bottom - 30, arcade.color.DARK_GRAY, 15)

    xaxis = arcade.create_line(50, from_bottom, 750, from_bottom,
                               arcade.color.BLACK)
    yaxis = arcade.create_line(50, from_bottom, 50, 700, arcade.color.BLACK)

    xaxis.draw()
    yaxis.draw()
    arcade.finish_render()
    arcade.run()
コード例 #6
0
    def draw_plane_holes(self, plane):
        self.hole_list = None
        self.hole_list = arcade.ShapeElementList()
        if self.box.dimensions < 3:
            for hole in plane.holes:
                (point, radius) = hole
                pnormal = numpy.array(
                    [plane.unitnormal[1], -plane.unitnormal[0]])
                start = point - (radius * pnormal)
                end = point + (radius * pnormal)
                line = arcade.create_line(*start, *end, arcade.color.GO_GREEN,
                                          4)
                self.hole_list.append(line)
        else:
            for hole in plane.holes:
                (point, radius) = hole
                shape = FlatD3Shape()
                shape.regular_polygon_vertices(360)
                shape.rotate(plane.unitnormal)
                shape.scale(radius)
                shape.move(point)
                points = [v[:2] for v in shape.vertices]
                polygon = arcade.create_polygon(points, arcade.color.GO_GREEN)
                if plane.reflect:
                    pass

                self.hole_list.append(polygon)
コード例 #7
0
def main():
    arcade.open_window(800, 800, "first window example")
    arcade.set_background_color(arcade.color.ALMOND)

    #now create objects
    main_house = arcade.create_rectangle(400, 200, 400, 400,
                                         arcade.color.ANTIQUE_BRASS)
    door = arcade.create_rectangle(400, 75, 100, 150, arcade.color.ARMY_GREEN)
    window_1 = arcade.create_ellipse(300, 300, 50, 50, arcade.color.AERO_BLUE)
    window_2 = arcade.create_ellipse(500, 300, 50, 50, arcade.color.AERO_BLUE)
    roof_points = [(200, 400), (400, 600), (600, 400)]
    roof = arcade.create_polygon(roof_points, arcade.color.DARK_GRAY)
    line = arcade.create_line(200, 730, 510, 730, arcade.color.ROSE)

    #now we will begin to draw
    arcade.start_render()
    #draw everything here
    arcade.draw_text("boy is that an ugly house", 200, 750,
                     arcade.color.ALABAMA_CRIMSON, 22)

    main_house.draw()
    door.draw()
    window_1.draw()
    window_2.draw()
    roof.draw()
    line.draw()

    arcade.finish_render()

    arcade.run()
コード例 #8
0
def main ():
    arcade.open_window(800, 800, "Hey We Have a Window")
    arcade.set_background_color(arcade.color.ALMOND)
    # now create objects
    main_house = arcade.create_rectangle(400, 200, 400, 400, arcade.color.ANTIQUE_BRASS)
    door = arcade.create_rectangle(400, 75, 100, 150, arcade.color.ARMY_GREEN)
    window1 = arcade.create_ellipse(300, 300, 50, 50, arcade.color.BABY_BLUE)
    window2 = arcade.create_ellipse(500, 300, 50, 50, arcade.color.BABY_BLUE)
    roof_points = [(200, 400), (400, 600), (600, 400)]
    roof = arcade.create_polygon(roof_points, arcade.color.DARK_GRAY)
    line = arcade.create_line(175, 725, 550, 725, arcade.color.FALU_RED)

    # now we will begin to draw
    arcade.start_render()
    # draw everything here
    arcade.draw_text("Boy that was an ugly house", 200, 750, arcade.color.ALABAMA_CRIMSON, 22)
    main_house.draw()
    door.draw()
    window1.draw()
    window2.draw()
    roof.draw()
    line.draw()

    arcade.finish_render()

    arcade.run()
コード例 #9
0
ファイル: main.py プロジェクト: kad99kev/PyBoxCar
    def setup(self):
        '''
        Setting up the environment.
        '''
        # Setting up space.
        self.space = pymunk.Space()
        self.space.gravity = GRAVITY
        self.space.sleep_time_threshold = 1

        # Creating cars.
        self.cars = []
        for _ in range(NUM_CARS):
            self.cars.append(BoxCar(self.space))

        # Setting up terrain and checkpoints.
        self.terrain = Terrain(self.space)
        self.checkpoints = self.terrain.get_checkpoints()

        # Setting up extra UI elements.
        self.goal = arcade.create_line(self.checkpoints[-1].x - 40,
                                       self.checkpoints[-1].y,
                                       self.checkpoints[-1].x - 40,
                                       self.checkpoints[-1].y + 50,
                                       arcade.color.GREEN, 2)
        self.generation_number = 1
        self.best_score = 0
        self.plot_history = []
        self.score_history = []
        self.score_list = arcade.ShapeElementList()
コード例 #10
0
 def __init__(self, x1, y1, x2, y2):
     self.point_list = ((x1, y2), (x2, y2))
     self.graphic_shape = arcade.create_line(x1, y1, x2, y2,
                                             arcade.color.WHITE)
     self.body = pymunk.Body(body_type=pymunk.Body.STATIC)
     self.pymunk_shape = pymunk.Segment(self.body, [x1, y1], [x2, y2], 0.0)
     self.pymunk_shape.friction = 1
     self.pymunk_shape.elasticity = 0.9
コード例 #11
0
ファイル: main.py プロジェクト: pben95/space-rpg-v2
 def scene3_render(self):
     self.draw_list = arcade.ShapeElementList()
     # self.stars_render()
     self.draw_list.append(
         arcade.create_rectangle_filled(400, 0, 800, 200,
                                        arcade.color.BLUE_GRAY, 0))
     # self.draw_list.append(arcade.create_rectangle_filled(400, 800, 800, 200, arcade.color.BLUE_GRAY, 0))
     self.draw_list.append(
         arcade.create_rectangle_filled(400, 113, 800, 25,
                                        arcade.color.LIGHT_GRAY, 0))
     self.draw_list.append(
         arcade.create_line(2, 0, 2, 124, arcade.color.DARK_BLUE, 4))
     self.draw_list.append(
         arcade.create_line(200, 0, 200, 101, arcade.color.DARK_BLUE, 4))
     self.draw_list.append(
         arcade.create_line(400, 0, 400, 101, arcade.color.DARK_BLUE, 4))
     self.draw_list.append(
         arcade.create_line(600, 0, 600, 101, arcade.color.DARK_BLUE, 4))
     self.draw_list.append(
         arcade.create_line(798, 0, 798, 124, arcade.color.DARK_BLUE, 4))
     self.draw_list.append(
         arcade.create_line(0, 100, 800, 100, arcade.color.DARK_BLUE, 4))
     self.draw_list.append(
         arcade.create_line(0, 124, 800, 124, arcade.color.DARK_BLUE, 4))
     self.draw_list.append(
         arcade.create_rectangle_outline(100 + (self.battle_cursor * 200),
                                         50, 175, 75, colors["black"], 3))
     self.draw_list.append(
         arcade.create_ellipse_outline(400, 600, self.enemy.size_x,
                                       self.enemy.size_y, colors["db"], 4))
     self.draw_list.append(
         arcade.create_ellipse_filled(400, 600, self.enemy.size_x / 3,
                                      self.enemy.size_y / 3, colors["sky"]))
コード例 #12
0
ファイル: main.py プロジェクト: pben95/space-rpg-v2
 def scene1_render(self):
     self.draw_list = arcade.ShapeElementList()
     if self.player.waypoint and self.player.target:
         self.draw_list.append(
             arcade.create_line(
                 400, 400, 400 + self.player.target["x"] - self.player.x,
                 400 + self.player.target["y"] - self.player.y,
                 arcade.color.LIME_GREEN, 1))
     self.player.move(self)
     # self.player.draw(self, 400, 400)
     if self.player.x < 400:
         self.draw_list.append(
             arcade.create_line(400 - self.player.x, 400 - self.player.y,
                                400 - self.player.x, 800, colors["white"],
                                4))
     if self.player.y < 400:
         self.draw_list.append(
             arcade.create_line(400 - self.player.x, 400 - self.player.y,
                                800, 400 - self.player.y, colors["white"],
                                4))
     if self.player.x > self.mapX - 800:
         self.draw_list.append(
             arcade.create_line(400 + (self.mapX - self.player.x), 0,
                                400 + (self.mapX - self.player.x),
                                400 + (self.mapY - self.player.y),
                                colors["white"], 4))
     if self.player.y > self.mapY - 800:
         self.draw_list.append(
             arcade.create_line(0, 400 + (self.mapY - self.player.y),
                                400 + (self.mapX - self.player.x),
                                400 + (self.mapY - self.player.y),
                                colors["white"], 4))
     self.stars_render()
     for obj in self.object_list:
         if obj != self.player and (abs(self.player.x - obj.x) < 800) and (
                 abs(self.player.y - obj.y)) < 800:
             obj.draw(self, 400 - (self.player.x - obj.x),
                      400 - (self.player.y - obj.y))
             if obj.type == 0:
                 obj.target["x"], obj.target[
                     "y"] = self.player.x, self.player.y
                 obj.move(self)
                 obj.move_to_target(self)
                 obj.check_fuse(self)
コード例 #13
0
ファイル: segment.py プロジェクト: beardad1975/pie4t
 def lazy_setup(self):
     if not self.is_lazy_setup:
         #arcade part
         self.shape_element = arcade.ShapeElementList()
         a = self.a
         b = self.b
         self.line_shape = arcade.create_line(a[0], a[1], b[0], b[1],
                                              arcade.color.YELLOW_ORANGE,
                                              self.thickness)
         self.is_lazy_setup = True
    def __init__(self, x, y, width, height, angle, delta_x, delta_y,
                 delta_angle, color):

        super().__init__(x, y, width, height, angle, delta_x, delta_y,
                         delta_angle, color)

        shape = arcade.create_line(0, 0, self.width, self.height, self.color,
                                   2)
        self.shape_list = arcade.ShapeElementList()
        self.shape_list.append(shape)
コード例 #15
0
 def __init__(self, xpos, ypos):
     self._radius = 17.5
     super().__init__(xpos, ypos, self._radius, self._radius, 0,
                      arcade.color.BLUE)
     shape = arcade.create_ellipse_filled(0, 0, self.width, self.height,
                                          self.color, self.angle)
     lin = arcade.create_line(0, 0, 0 + self._radius, 0, arcade.color.WHITE,
                              5)
     self.shape_list = arcade.ShapeElementList()
     self.shape_list.append(shape)
     self.shape_list.append(lin)
コード例 #16
0
ファイル: terrain.py プロジェクト: kad99kev/PyBoxCar
    def __setup_draw(self):
        '''
        Setting up the terrain shapes to be rendered.
        '''

        self.visuals.center_x = 0
        self.visuals.center_y = 0

        for line in self.terrain_shapes:
            start_x, start_y = line.a
            end_x, end_y = line.b
            self.visuals.append(
                arcade.create_line(start_x, start_y, end_x, end_y,
                                   arcade.color.BLACK, 2))

        self.visuals.append(
            arcade.create_line(0, end_y - 40, BOX_WIDTH, end_y - 40,
                               arcade.color.BLACK, 2))
        self.visuals.append(
            arcade.create_line(BOX_WIDTH, end_y, BOX_WIDTH, end_y - 40,
                               arcade.color.BLACK, 2))
コード例 #17
0
    def create_divider(self, colour):
        """
        Create a dividing line between the game board & scoreboard.

        Return an object that can be rendered to the screen efficiently.
        """
        divider = arcade.create_line(
            settings.CELL - (settings.CELL / 8),
            settings.WINDOW_HEIGHT - (settings.CELL * 6),
            settings.WINDOW_WIDTH - (settings.CELL - (settings.CELL / 8)),
            settings.WINDOW_HEIGHT - (settings.CELL * 6), colour, 8)
        return divider
コード例 #18
0
ファイル: main.py プロジェクト: pben95/space-rpg-v2
 def scene4_render(self):
     self.draw_list = arcade.ShapeElementList()
     self.draw_list.append(
         arcade.create_rectangle_filled(400, 400, 600, 600, colors["db"],
                                        0))
     self.draw_list.append(
         arcade.create_line(200, 100, 200, 700, arcade.color.DARK_BLUE, 4))
     self.draw_list.append(
         arcade.create_rectangle_outline(
             menu_slots[self.station_cursor]["x"],
             menu_slots[self.station_cursor]["y"], 140, 140,
             arcade.color.DARK_BLUE, 3))
コード例 #19
0
    def setup(self):

        # Create the sprite lists.
        self.tetrimino = Arcade.SpriteList()
        self.blocks_list = Arcade.SpriteList()

        # The tallest occupied space by column.
        # The lower the number, the higher the block is on the screen.
        self.max_by_col = self.find_max_by_col()

        # Generate first queue of tetriminos.
        self.tetrimino_queue = self.generate_queue()

        # Get the first tetrimino and add it to the field.
        self.tetrimino = tetrimino.Tetrimino(type=tetrimino.Tetrimino.Type[
            self.tetrimino_queue.get()]).to_sprite_list()
        self.add_tetrimino_to_field(self.tetrimino)

        # Game area (with grid)
        self.game_area = Arcade.ShapeElementList()
        self.game_area.append(
            Arcade.create_rectangle_outline(
                Const.AREA_LEFT + (Const.AREA_RIGHT - Const.AREA_LEFT) / 2,
                Const.AREA_BOTTOM + (Const.AREA_TOP - Const.AREA_BOTTOM) / 2,
                Const.AREA_RIGHT - Const.AREA_LEFT,
                Const.AREA_TOP - Const.AREA_BOTTOM, Arcade.color.WHITE, 2))

        for x in range(Const.AREA_LEFT + Const.BLOCK_SIZE, Const.AREA_RIGHT,
                       Const.BLOCK_SIZE):
            self.game_area.append(
                Arcade.create_line(
                    x, Const.AREA_TOP, x, Const.AREA_BOTTOM,
                    (128, 128, 128, 128)))  # Gray with 50% opacity

        for y in range(Const.AREA_BOTTOM + Const.BLOCK_SIZE, Const.AREA_TOP,
                       Const.BLOCK_SIZE):
            self.game_area.append(
                Arcade.create_line(Const.AREA_LEFT, y, Const.AREA_RIGHT, y,
                                   (128, 128, 128, 128)))
コード例 #20
0
ファイル: ArcadeFunctions.py プロジェクト: tteddyy28/Week8
def create_shapes(win_width, win_height):
    shape_list = []
    win_width = win_width / 4
    rectangle = arcade.create_rectangle_filled(win_width, 350, 100, 200,
                                               arcade.color.BABY_PINK)
    circle = arcade.create_ellipse(win_width * 3, 350, 50, 50,
                                   arcade.color.PUCE_RED)
    line = arcade.create_line(win_width, 650, win_width * 3, 75,
                              arcade.color.CANARY_YELLOW)
    shape_list.append(rectangle)
    shape_list.append(circle)
    shape_list.append(line)
    return shape_list
コード例 #21
0
ファイル: functions.py プロジェクト: j4kaplan/week8inperson
def create_shapes(win_width, win_height):
    x_scale = win_width / 4
    win_height = win_height / 4
    shape_list = []
    rectangle = arcade.create_rectangle(x_scale, win_height, 100, win_height,
                                        arcade.color.COPPER_PENNY)
    circle = arcade.create_ellipse(x_scale * 3, win_height, 50, 50,
                                   arcade.color.DARK_TANGERINE)
    shape_list.append(rectangle)
    shape_list.append(circle)
    line = arcade.create_line(x_scale, 600, x_scale * 3, win_height,
                              arcade.color.ENGLISH_LAVENDER, 3)
    shape_list.append(line)
    return shape_list
コード例 #22
0
    def create_map_debug_grid(self) -> ShapeElementList:
        grid = ShapeElementList()
        h_offset = TILE_HEIGHT // 2
        w_offset = TILE_WIDTH // 2
        # horizontal lines:
        for i in range(self.game.map.rows):
            y = i * TILE_HEIGHT
            h_line = create_line(0, y, self.game.map.width, y, BLACK)
            grid.append(h_line)

            y = i * TILE_HEIGHT + h_offset
            h2_line = create_line(w_offset, y, self.game.map.width, y, WHITE)
            grid.append(h2_line)
        # vertical lines:
        for j in range(self.game.map.columns * 2):
            x = j * TILE_WIDTH
            v_line = create_line(x, 0, x, self.game.map.height, BLACK)
            grid.append(v_line)

            x = j * TILE_WIDTH + w_offset
            v2_line = create_line(x, h_offset, x, self.game.map.height, WHITE)
            grid.append(v2_line)
        return grid
コード例 #23
0
    def setup_track(self):
        self.track_element_list = arcade.ShapeElementList()

        for coord in self.track.straight_track_coordinates:
            coord[:2] = self.transform(*coord[:2])
            coord[2:4] = self.transform(*coord[2:])
            shape = arcade.create_line(*coord, arcade.color.BLACK)
            self.track_element_list.append(shape)

        for coord in self.track.turn_track_coordinates:
            coord[:2] = self.transform(*coord[:2])
            coord[2:4] = self.scale_length(coord[2]), self.scale_length(
                coord[3])
            shape = create_arc_outline.create_arc_outline(
                *coord[0:4], arcade.color.BLACK, *coord[4:6])
            self.track_element_list.append(shape)
コード例 #24
0
ファイル: main.py プロジェクト: pben95/space-rpg-v2
 def scene2_render(self):
     self.draw_list = arcade.ShapeElementList()
     #  self.stars_render()
     #  self.draw_list.append(arcade.create_rectangle_filled(400, 400, 800, 800, arcade.color.DARK_BLUE, 0))
     self.draw_list.append(
         arcade.create_rectangle_filled(400, 400, 600, 600, colors["white"],
                                        0))
     self.draw_list.append(
         arcade.create_line(300, 100, 300, 700, colors["black"], 4))
     for i in range(0, 5):
         self.draw_list.append(
             arcade.create_rectangle_filled(200, 600 - (100 * i), 50, 75,
                                            arcade.color.SILVER_LAKE_BLUE))
     self.draw_list.append(
         arcade.create_rectangle_outline(200, 200 + (self.cursor * 100), 50,
                                         75, colors["black"], 3))
コード例 #25
0
ファイル: player.py プロジェクト: salaxieb/footbal
    def update(self, delta_time, walls, ball, my_gate, enemy_gate, team_player, enemy_1, enemy_2):
        self.batches = defaultdict(_Batch)
        distances = np.min(self.distances(walls), axis=1)
        cut_sensors = np.multiply(np.resize(distances, (N_SENSORS, 1)), self.sensors)

        for [sx, sy, ex, ey] in cut_sensors:
            self.append(arcade.create_line(sx, sy, ex, ey, color=self.g_color))

        circ = arcade.create_ellipse_filled(0, 0, width=20, height=20, color=self.color)

        self.append(circ)
        self.append(circ)

        self.holding_ball = self.check_for_collision_with_ball(ball)
        self.on_wall = np.min(distances) < 0.05

        return self.generate_input(distances, ball, my_gate, enemy_gate, team_player, enemy_1, enemy_2)
コード例 #26
0
    def setup_draw(self):
        '''
        Creating the inital shapes to be rendered later by the BoxCar class.
        '''

        self.visuals.center_x = self.body.position.x
        self.visuals.center_y = self.body.position.y

        # Draws the wheel
        shape = arcade.create_ellipse_filled(0, 0, self.radius, self.radius,
                                             arcade.color.GRAY)
        self.visuals.append(shape)

        # Draws the orientation of wheel
        end = self.body.rotation_vector * self.radius
        shape = arcade.create_line(0, 0, end.x, end.y, arcade.color.BLACK, 2)
        self.visuals.append(shape)
コード例 #27
0
ファイル: __init__.py プロジェクト: rstgh/rstoys
    def render(self, et, dt):

        if self.shapes is None:

            self.shapes = arcade.ShapeElementList()

            for m in self.markers:
                (x, y) = self.map.project(m[0])
                self.shapes.append(
                    arcade.create_line(x, y, x, y + 24, (0, 0, 0, 128), 4))
                self.shapes.append(
                    arcade.create_ellipse_filled(x, y, 4, 4, (0, 0, 0, 128), 0,
                                                 18))
                self.shapes.append(
                    arcade.create_ellipse_filled(x, y + 24, 8, 8,
                                                 arcade.color.AMAZON, 0, 18))

        self.shapes.draw()
コード例 #28
0
 def _calc_view_distance(self, space: Space, base_x: float,
                         base_y: float) -> Optional[float]:
     """
     Calculate the distance between the base point, represented by base_x and base_y, and the furthest
     viewable object. If no object is in sight, return None.
     :param space: which holds the visible objects.
     :param base_x: x coordinate of the base point.
     :param base_y: y coordinate of the base point.
     :return: a floating point value representing the distance if object is viewable, else None.
     """
     x, y = self._calc_ray_cast_point(base_x, base_y)
     if DEBUG:
         line = create_line(x, y, base_x, base_y, RED, 5)
         self.robot.debug_shapes.append(line)
     query = space.segment_query_first((base_x, base_y), (x, y), 1,
                                       self.shape.filter)
     if query:
         return -self.sensor_half_height + distance_between_points(
             base_x, base_y, query.point.x, query.point.y)
     return None
コード例 #29
0
def make_objects():
    shape_list = arcade.ShapeElementList()

    center_x = 0
    center_y = 0
    width = 20
    height = 20
    shape = arcade.create_ellipse_filled(center_x, center_y, width, height,
                                         arcade.color.WHITE)
    shape_list.append(shape)

    center_x += 40
    shape = arcade.create_ellipse_outline(center_x,
                                          center_y,
                                          width,
                                          height,
                                          arcade.color.RED,
                                          border_width=1)
    shape_list.append(shape)

    center_x += 40
    shape = arcade.create_ellipse_outline(center_x,
                                          center_y,
                                          width,
                                          height,
                                          arcade.color.DARK_RED,
                                          border_width=1)
    shape_list.append(shape)

    shape = arcade.create_line(0, 0, 80, 0, arcade.color.BLUE, line_width=1)
    shape_list.append(shape)

    shape = arcade.create_line(0,
                               0,
                               80,
                               0,
                               arcade.color.LIGHT_BLUE,
                               line_width=1)
    shape_list.append(shape)

    center_x = 0
    center_y = 50
    width = 20
    height = 20
    outside_color = arcade.color.AERO_BLUE
    inside_color = arcade.color.AFRICAN_VIOLET
    tilt_angle = 45
    shape = arcade.create_ellipse_filled_with_colors(center_x, center_y, width,
                                                     height, outside_color,
                                                     inside_color, tilt_angle)
    shape_list.append(shape)

    center_x = 0
    center_y = -50
    width = 20
    height = 20
    shape = arcade.create_rectangle_filled(center_x, center_y, width, height,
                                           arcade.color.WHITE)
    shape_list.append(shape)
    shape = arcade.create_rectangle_outline(center_x,
                                            center_y,
                                            width,
                                            height,
                                            arcade.color.BLACK,
                                            border_width=1)
    shape_list.append(shape)
    shape = arcade.create_rectangle_outline(center_x,
                                            center_y,
                                            width,
                                            height,
                                            arcade.color.AMERICAN_ROSE,
                                            border_width=1)
    shape_list.append(shape)

    color1 = (215, 214, 165)
    color2 = (219, 166, 123)
    points = (70, 70), (150, 70), (150, 150), (70, 150)
    colors = (color1, color1, color2, color2)
    shape = arcade.create_rectangle_filled_with_colors(points, colors)
    shape_list.append(shape)

    points = (0, 0), (150, 150), (0, 150), (0, 250)
    shape = arcade.create_line_strip(points, arcade.color.AFRICAN_VIOLET)
    shape_list.append(shape)

    points = (0, 0), (75, 90), (60, 150), (90, 250)
    shape = arcade.create_line_generic(points, arcade.color.ALIZARIN_CRIMSON,
                                       gl.GL_TRIANGLE_FAN)
    shape_list.append(shape)

    return shape_list
コード例 #30
0
    def on_draw(self):
        arcade.start_render()
        if self.state == "Idle":
            arcade.draw_text("Tic Tac Toe", 300, 300, arcade.color.WHITE, font_size=50, anchor_x="center")
            arcade.draw_text("Press X or O to choose a sign..", 300, 250, arcade.color.WHITE, font_size=20, anchor_x="center")

        elif self.state == "GameOn":
            self.shape_list = arcade.ShapeElementList()
            arcade.draw_line(0, 400, 600, 400, arcade.color.WHITE, 5)
            arcade.draw_line(0, 200, 600, 200, arcade.color.WHITE, 5)
            arcade.draw_line(400, 0, 400, 600, arcade.color.WHITE, 5)
            arcade.draw_line(200, 0, 200, 600, arcade.color.WHITE, 5)

            for sign in self.board:
                if sign == "o":
                    if self.board[0] == "o":
                        self.shape = arcade.create_ellipse(100,500,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(100,500,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[1] == "o":
                        self.shape = arcade.create_ellipse(300,500,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(300,500,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[2] == "o":
                        self.shape = arcade.create_ellipse(500,500,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(500,500,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[3] == "o":
                        self.shape = arcade.create_ellipse(100,300,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(100,300,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[4] == "o":
                        self.shape = arcade.create_ellipse(300,300,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(300,300,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[5] == "o":
                        self.shape = arcade.create_ellipse(500,300,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(500,300,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[6] == "o":
                        self.shape = arcade.create_ellipse(100,100,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(100,100,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[7] == "o":
                        self.shape = arcade.create_ellipse(300,100,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(300,100,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[8] == "o":
                        self.shape = arcade.create_ellipse(500,100,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(500,100,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)

                elif sign == "x":
                    if self.board[0] == "x":
                        self.shape = arcade.create_line(0, 600, 200, 400, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(200, 600, 0, 400, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[1] == "x":
                        self.shape = arcade.create_line(200, 600, 400, 400, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(400, 600, 200, 400, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[2] == "x":
                        self.shape = arcade.create_line(400, 600, 600, 400, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(600, 600, 400, 400, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[3] == "x":
                        self.shape = arcade.create_line(0, 400, 200, 200, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(200, 400, 0, 200, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[4] == "x":
                        self.shape = arcade.create_line(200, 400, 400, 200, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(400, 400, 200, 200, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[5] == "x":
                        self.shape = arcade.create_line(400, 400, 600, 200, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(600, 400, 400, 200, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[6] == "x":
                        self.shape = arcade.create_line(0, 200, 200, 0, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(200, 200, 0, 0, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[7] == "x":
                        self.shape = arcade.create_line(200, 200, 400, 0, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(400, 200, 200, 0, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[8] == "x":
                        self.shape = arcade.create_line(400, 200, 600, 0, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(600, 200, 400, 0, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                self.shape_list.draw()

        elif self.state == "GameOver":
            if self.win == "p":
                arcade.draw_text("Congratulations, you won !", 300, 300, arcade.color.WHITE, font_size=40, anchor_x="center")
                arcade.draw_text("Click to continue", 300, 250, arcade.color.WHITE, font_size=20, anchor_x="center")

            elif self.win == "c":
                arcade.draw_text("Computer wins :(", 300, 300, arcade.color.WHITE, font_size=50, anchor_x="center")
                arcade.draw_text("Click to continue", 300, 250, arcade.color.WHITE, font_size=20, anchor_x="center")

            elif self.win == "d":
                arcade.draw_text("It's a draw..", 300, 300, arcade.color.WHITE, font_size=50, anchor_x="center")
                arcade.draw_text("Click to continue", 300, 250, arcade.color.WHITE, font_size=20, anchor_x="center")