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

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

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

    # Call our drawing functions.
    draw_background()
    draw_pine_tree(50, 250)
    draw_pine_tree(350, 320)
    draw_bird(70, 500)
    draw_bird(470, 550)

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

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

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

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

    # Call our drawing functions.
    draw_background()
    draw_pine_tree(50, 250)
    draw_pine_tree(350, 320)
    draw_bird(70, 500)
    draw_bird(470, 550)
    draw_bird(175, 450)
    draw_bird(525, 475)
    draw_bird(415, 475)

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


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

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

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

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

    # Call our drawing functions.
    draw_background()

    # Loop to draw ten birds in random locations.
    for bird_count in range(10):
        # Any random x from 0 to the width of the screen
        x = random.randrange(0, SCREEN_WIDTH)

        # Any random y from in the top 2/3 of the screen.
        # No birds on the ground.
        y = random.randrange(SCREEN_HEIGHT / 3, SCREEN_HEIGHT - 20)

        # Draw the bird.
        draw_bird(x, y)

    # Draw the top row of trees
    for x in range(45, SCREEN_WIDTH, 90):
        draw_pine_tree(x, SCREEN_HEIGHT / 3)

    # Draw the bottom row of trees
    for x in range(65, SCREEN_WIDTH, 90):
        draw_pine_tree(x, (SCREEN_HEIGHT / 3) - 120)

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

    # Keep the window up until someone closes it.
    arcade.run()
Exemplo n.º 4
0
import arcade as ar
ar.open_window(600, 600, 'SNOWMAN')
ar.set_background_color(ar.color.BLUE)
ar.start_render()
ar.draw_lrtb_rectangle_filled(0, 600, 200, 0, ar.color.BABY_BLUE)
col_1 = ar.color.WHITE
col_2 = ar.color.BLACK


def gola(x, y, r, rang):
    ar.draw_circle_filled(x, y, r, rang)


gola(250, 200, 60, col_1)
gola(250, 287, 50, col_1)
gola(250, 360, 40, col_1)
gola(235, 370, 5, col_2)
gola(265, 370, 5, col_2)
ar.finish_render()
ar.run()
def main():
    """ Main method """
    window = MyGame()
    window.setup()
    arcade.finish_render()
    arcade.run()
Exemplo n.º 6
0
 def on_draw(self):
     arcade.start_render()
     for shape in self.shapes:
         shape.draw()
     self.player.draw()
     arcade.finish_render()
Exemplo n.º 7
0
cor_a2 = int(input("Digite o valor 2 para a cor da face: "))
if cor_a2 < 0 or cor_a2 > 255:
    print("\nValor para a cor 1 é invalido!! {}".format(cor_a2))
    cont = 0  # Contador do while
    while cor_a2 < 0 or cor_a2 > 255:
        cor_a2 = int(input("\nDigite novamente: "))
        if 0 < cor_a2 <= 255:
            print("\nValor correto! {}".format(cor_a2))
            break
    cont += 1
"""
Variavel que define a terceira cor do conjunto de cores para pintar o sorriso do desenho
"""
cor_a3 = int(input("Digite o valor 2 para a cor da face: "))
if cor_a3 < 0 or cor_a3 > 255:
    print("\nValor para a cor 1 é invalido!! {}".format(cor_a3))
    cont = 0  # Contador do while
    while cor_a3 < 0 or cor_a3 > 255:
        cor_a3 = int(input("\nDigite novamente: "))
        if 0 < cor_a3 <= 255:
            print("\nValor correto! {}".format(cor_a3))
            break
    cont += 1
arcade.draw_arc_outline(x, y, widht, height, (cor_a1, cor_a2, cor_a3),
                        start_angle, end_angle, 10)

arcade.finish_render()  # Função que finaliza o desenho e exibe o resultado

arcade.run(
)  # Função que mantem a janela aberta até que o botão 'fechar' seja pressionado
Exemplo n.º 8
0
                face_x,face_y = (x,y)
                smile_x,smile_y = (face_x + 0,face_y - 300)
                eye1_x,eye1_y = (face_x - 20,face_y + 30) 
                eye2_x,eye2_y = (face_x + 20,face_y + 30)
                catch1_x,catch1_y = (face_x - 18,face_y + 32) 
                catch2_x,catch2_y = (face_x +22,face_y + 32) 


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

                #(x,y,width,height,color)
                arcade.draw_ellipse_filled(eye1_x,eye1_y,15,25,open_color.black)
                arcade.draw_ellipse_filled(eye2_x,eye2_y,15,25,open_color.black)
                arcade.draw_circle_filled(catch1_x,catch1_y,3,open_color.gray_2)
                arcade.draw_circle_filled(catch2_x,catch2_y,3,open_color.gray_2)

                #(x,y,width,height,color,start_degrees,end_degrees,border_thickness)
                arcade.draw_arc_outline(smile_x,smile_y,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()
# Keep the window up until someone closes it.
arcade.run()
Exemplo n.º 9
0
	def m_createWindow(width, height, text, bgcolor):
		arcade.open_window(width, height, text)
		arcade.set_background_color(bgcolor)
		arcade.start_render()
		arcade.finish_render()
Exemplo n.º 10
0
def TriangleRender(Ax, Ay, Bx, By, Cx, Cy):
    import pointsDis
    import cosSinCalc
    AB, AC, BC = (pointsDis.PointsDis(Ax, Ay, Bx, By, Cx, Cy))
    A, B, C = cosSinCalc.CosSinCalc(AB, AC, BC)

    width = 800
    height = 800
    lineWidth = 5

    AxT = int(Ax)
    AyT = int(Ay)
    BxT = int(Bx)
    ByT = int(By)
    CxT = int(Cx)
    CyT = int(Cy)

    Ax = Ax + 400 + Ax * 30
    Ay = Ay + 400 + Ay * 30
    Bx = Bx + 400 + Bx * 30
    By = By + 400 + By * 30
    Cx = Cx + 400 + Cx * 30
    Cy = Cy + 400 + Cy * 30

    arcade.open_window(width, height, "Triangle Coordinate Drawer")
    arcade.set_background_color((255, 255, 255))

    #Draw axes
    arcade.draw_line(width / 2, 0, width / 2, height, (255, 255, 255),
                     lineWidth)
    arcade.draw_line(0, height / 2, width, height / 2, (255, 255, 255),
                     lineWidth)
    #draw point
    arcade.draw_point(Ax, Ay, (255, 180, 180), 13)
    arcade.draw_point(Bx, By, (255, 180, 180), 13)
    arcade.draw_point(Cx, Cy, (255, 180, 180), 13)

    #Draw line
    arcade.draw_line(Ax, Ay, Bx, By, (60, 180, 180), 4)
    arcade.draw_line(Ax, Ay, Cx, Cy, (60, 180, 180), 4)
    arcade.draw_line(Bx, By, Cx, Cy, (60, 180, 180), 4)

    #tekst med længde
    arcade.draw_text("Length of AB is " + str(AB), 25, 300, arcade.color.WHITE)
    arcade.draw_text("Length of AC is " + str(AC), 25, 280, arcade.color.WHITE)
    arcade.draw_text("Length of BC is " + str(BC), 25, 260, arcade.color.WHITE)

    #tekst med vinkler
    arcade.draw_text("Angle A is " + str(A) + "°", 25, 230, arcade.color.WHITE)
    arcade.draw_text("Angle B is " + str(B) + "°", 25, 210, arcade.color.WHITE)
    arcade.draw_text("Angle C is " + str(C) + "°", 25, 190, arcade.color.WHITE)

    #tekst ved punkterne
    arcade.draw_text("A(" + str(AxT) + "," + str(AyT) + ")", Ax - 10, Ay + 10,
                     arcade.color.WHITE)
    arcade.draw_text("B(" + str(BxT) + "," + str(ByT) + ")", Bx - 10, By + 10,
                     arcade.color.WHITE)
    arcade.draw_text("C(" + str(CxT) + "," + str(CyT) + ")", Cx - 10, Cy + 10,
                     arcade.color.WHITE)

    arcade.finish_render()
    arcade.run()
Exemplo n.º 11
0
def finishprogram():

    arcade.finish_render()
    arcade.run()
Exemplo n.º 12
0
 def on_draw(self):
     arcade.start_render()
     arcade.draw_text(self.last_msg, 10, 150, arcade.color.RED, 24)
     arcade.finish_render()
Exemplo n.º 13
0
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.
IN THE WINDOW TITLE PLEASE PUT YOUR NAME.
When you are finished Pull Request your file to your instructor.
'''

#BMW Logo
import arcade  #Setup Arcade
arcade.open_window(1280, 720, "Danny Halstead")
arcade.set_background_color(arcade.color.WHITE)
arcade.start_render()

arcade.draw_text("BMW Logo", 500, 650, arcade.color.PURPLE_MOUNTAIN_MAJESTY,
                 20, 220, "left", "Ariel", False, False, "left", "baseline",
                 0)  #Text at Top

arcade.draw_circle_filled(
    640, 360, 250, arcade.color.GRAY
)  #Circles from outer to inner, white inner part is circle but blue inner part is not
arcade.draw_circle_filled(640, 360, 240, arcade.color.BLACK)
arcade.draw_circle_filled(640, 360, 150, arcade.color.GRAY)
arcade.draw_circle_filled(640, 360, 140, arcade.color.WHITE)

for i in range(0, 181, 180):
    arcade.draw_arc_filled(640, 360, 140, 140, arcade.color.BLUE, 0, 90,
                           i)  #Blue Inner Quartercircles
# I know that may be the laziest loop in existance but I did et all the way through this before realizing that I had to have a loop so...

arcade.finish_render()  #Run Arcade
arcade.run()
def main():
    window = HelicopterGame(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
    arcade.finish_render()
    arcade.run()
    def on_update(self, x):
        """ Move everything """
        # Update the Stars
        for star in self.star_list:
            star.update()

        self.frame_count += 1

        # Call update on the beer_coins
        self.coin_sprite_list.update()

        # Add the beer_coins to a list of items colliding with the player.
        hit_list = arcade.check_for_collision_with_list(
            self.player_sprite, self.coin_sprite_list)

        # Loop through each colliding sprite, remove it, and add to the score.
        for coin in hit_list:
            coin.remove_from_sprite_lists()
            self.score += 111

        if not self.game_over:
            self.asteroid_list.update()
            self.bullet_list.update()
            self.player_sprite_list.update()

            for bullet in self.bullet_list:
                asteroids = arcade.check_for_collision_with_list(
                    bullet, self.asteroid_list)

                for asteroid in asteroids:
                    self.split_asteroid(
                        cast(AsteroidSprite, asteroid
                             ))  # expected AsteroidSprite, got Sprite instead
                    asteroid.remove_from_sprite_lists()
                    bullet.remove_from_sprite_lists()

                # Remove bullet if it goes off-screen
                size = max(bullet.width, bullet.height)
                if bullet.center_x < 0 - size:
                    bullet.remove_from_sprite_lists()
                if bullet.center_x > SCREEN_WIDTH + size:
                    bullet.remove_from_sprite_lists()
                if bullet.center_y < 0 - size:
                    bullet.remove_from_sprite_lists()
                if bullet.center_y > SCREEN_HEIGHT + size:
                    bullet.remove_from_sprite_lists()

            # After a collision, one life will be taken away from the players lives.
            if not self.player_sprite.respawning:
                asteroids = arcade.check_for_collision_with_list(
                    self.player_sprite, self.asteroid_list)
                if len(asteroids) > 0:
                    if self.lives > 0:
                        self.lives -= 1
                        self.player_sprite.respawn()
                        self.split_asteroid(cast(AsteroidSprite, asteroids[0]))
                        asteroids[0].remove_from_sprite_lists()

                        # Show "Crash!" for a few seconds when the player collides with a potato
                        i = 0.0
                        while i <= 20:
                            i += 0.1
                            start_x = SCREEN_WIDTH / 2
                            start_y = SCREEN_HEIGHT / 2
                            arcade.draw_text("Crash!",
                                             start_x,
                                             start_y,
                                             arcade.color.ANTIQUE_WHITE,
                                             120,
                                             rotation=15)
                            arcade.finish_render()

                    else:
                        self.game_over = True
        # Show Game_Over Screen when self.game_over is True
        if self.game_over == True:
            arcade.start_render()
            start_x = 200
            start_y = 200
            arcade.draw_text("Du hast verloren\nChristian!\n",
                             start_x,
                             start_y,
                             arcade.color.WHITE,
                             font_size=100,
                             align="center")
            arcade.finish_render()
Exemplo n.º 16
0
 def on_draw(self):
     arcade.start_render()
     self.player.draw()
     self.lasers_list.draw()
     self.window.flip()
     arcade.finish_render()
Exemplo n.º 17
0
def main():
    arcade.open_window(800, 600, "My sample window")

    # Background color
    arcade.set_background_color((arcade.color.AIR_SUPERIORITY_BLUE))
    arcade.start_render()

    draw_concrete()
    draw_car(320, 50)
    draw_car(680, 60)

    # Sky
    arcade.draw_lrtb_rectangle_filled(0, 799, 450, 200, arcade.color.SAE)
    arcade.draw_lrtb_rectangle_filled(0, 799, 375, 200, arcade.color.AMBER)
    arcade.draw_lrtb_rectangle_filled(0, 799, 225, 200,
                                      arcade.color.MEDIUM_VERMILION)

    draw_bird(550, 300)
    draw_bird(650, 320)
    draw_bird(680, 400)

    # Sun
    arcade.draw_circle_filled(550, 200, 80, arcade.color.MELLOW_YELLOW)
    arcade.draw_circle_filled(550, 200, 55, arcade.color.LEMON_CHIFFON)

    # Cloud 1
    arcade.draw_ellipse_filled(500, 550, 140, 70, arcade.color.ISABELLINE)

    #Cloud 2
    arcade.draw_ellipse_filled(650, 500, 100, 50, arcade.color.ISABELLINE)

    # Cloud 3
    arcade.draw_ellipse_filled(100, 530, 120, 70, arcade.color.ISABELLINE)

    # Grass
    arcade.draw_lrtb_rectangle_filled(0, 800, 200, 100,
                                      arcade.color.BITTER_LIME)

    # Sidewalk
    arcade.draw_polygon_filled(
        ((210, 120), (290, 120), (320, 100), (180, 100)),
        arcade.color.DIM_GRAY)

    # House building
    # Building
    arcade.draw_lrtb_rectangle_filled(75, 425, 400, 120,
                                      arcade.color.FRENCH_BEIGE)

    # Roof
    arcade.draw_triangle_filled(250, 500, 50, 400, 450, 400,
                                arcade.color.DARK_BROWN)

    # Left window
    arcade.draw_lrtb_rectangle_filled(130, 200, 340, 265, arcade.color.GLITTER)

    arcade.draw_line(165, 340, 165, 265, arcade.color.DIM_GRAY, 4)
    arcade.draw_line(130, 305, 200, 305, arcade.color.DIM_GRAY, 4)
    arcade.draw_lrtb_rectangle_outline(125, 205, 345, 260, arcade.color.WHITE,
                                       4)

    # Right window
    arcade.draw_lrtb_rectangle_filled(300, 370, 340, 265, arcade.color.GLITTER)
    arcade.draw_line(335, 340, 335, 265, arcade.color.DIM_GRAY, 4)
    arcade.draw_line(300, 305, 370, 305, arcade.color.DIM_GRAY, 4)
    arcade.draw_lrtb_rectangle_outline(295, 375, 345, 260, arcade.color.WHITE,
                                       4)

    # Door
    arcade.draw_lrtb_rectangle_filled(210, 290, 230, 120, arcade.color.CG_RED)

    # Door outline
    arcade.draw_lrtb_rectangle_filled(230, 270, 210, 140,
                                      arcade.color.CORAL_RED)

    # Door knob
    arcade.draw_ellipse_filled(275, 180, 10, 10, arcade.color.KOBE)

    # Left bush
    arcade.draw_ellipse_filled(140, 140, 115, 70, arcade.color.JUNE_BUD)

    # Right bush
    arcade.draw_ellipse_filled(360, 140, 115, 70, arcade.color.JUNE_BUD)

    draw_tree(600, 200)
    draw_tree(660, 180)

    arcade.finish_render()

    arcade.run()
Exemplo n.º 18
0
    def update(self, delta_time):
        """ All the logic to move, and the game logic goes here. """

        # Start task with rest trial
        if self.firstTrial is True:
            self.display_rest()
            self.firstTrial = False

        # Calculate where to move the player sprite
        self.player_sprite.change_x = 0
        self.player_sprite.change_y = 0

        # Buffer data for 750 ms and process to determine which direction to go
        step_time = time.time()  # want to take 1 second for step to update
        step_length = 1.750  # amount of time we want to use for calculation
        buffer = int(self.fs * step_length)
        data = np.zeros((buffer, self.channels))

        if self.EEGdevice == 7:
            self.streamer.clear_out_buffer()

        for idx in range(buffer):
            if self.EEGdevice == 7:
                # code to read in EEG from DSI-7 here
                tmp = 1  # just put something here to prevent indentation issues
                data[idx, :] = self.streamer.out_buffer_queue.get()[:-1]
            elif self.EEGdevice == 8:
                sample, timestamp = inlet.pull_sample()
                data[idx, :] = sample

        self.eeg_data = data
        self.classify_epoch()  # TO DO

        # Move the player sprite
        while time.time() - step_time < 2:
            tmp = 1  # just do something until time is up

        pulseValue = 0

        if self.move_left is True:
            # Left (eyes closed)
            self.player_sprite.set_position(
                self.player_sprite.center_x - (WIDTH + MARGIN),
                self.player_sprite.center_y)
            direction_moved = 'left'
            pulseValue = 1
        elif self.move_right is True:
            # Right (eyes open)
            self.player_sprite.set_position(
                self.player_sprite.center_x + WIDTH + MARGIN,
                self.player_sprite.center_y)
            direction_moved = 'right'
            pulseValue = 2

        # Call update on all sprites
        self.player_list.update()
        self.target_list.update()
        self.ITI_list.update()

        # Send pulses
        move_time = clock.getTime()

        # previous code -
        # if self.EEGdevice == 7:
        # # Audio beep to send pulse to sync box
        #     if self.move_left is True:
        #         play_sound('C')
        #     elif self.move_right is True:
        #         play_sound('E')
        # elif self.EEGdevice == 8:
        #     # Send pulse through LSL, 1 if left, 2 if right
        #     self.outlet.push_sample([pulseValue])
        #     if self.move_left is True:
        #         play_sound('C')
        #     elif self.move_right is True:
        #         play_sound('E')

        # modified - does it still work?
        if self.EEGdevice == 8:
            # Send pulse through LSL, 1 if left, 2 if right
            self.outlet.push_sample([pulseValue])
        if self.move_left is True:
            play_sound('C')
        elif self.move_right is True:
            play_sound('E')

        # Store task data
        taskData.loc[moveCount] = pd.Series([move_time, \
                    self.player_sprite.center_x, self.player_sprite.center_y, \
                    self.target_sprite.center_x, self.target_sprite.center_y, \
                    direction_moved, self.score], \
                    index=self.taskData_col_names)
        increment()

        # End trial if time is up
        if time.time() - self.trialTime >= self.trialLength:
            arcade.start_render()
            arcade.draw_rectangle_filled(center_x=self.player_sprite.center_x,
                                         center_y=self.player_sprite.center_y,
                                         width=WIDTH,
                                         height=HEIGHT,
                                         color=arcade.color.RED)
            arcade.finish_render()
            arcade.pause(1)
            # Play minor arpeggio downward
            play_sound(value='A', sec=0.1, octave=4)
            arcade.pause(0.1)
            play_sound(value='E', sec=0.1, octave=4)
            arcade.pause(0.1)
            play_sound(value='C', sec=0.1, octave=4)
            arcade.pause(0.1)
            play_sound(value='A', sec=0.1, octave=3)

            for target in self.target_list:
                target.kill()
            self.display_rest()
            self.create_target()

        # Generate list of all targets that collided with the player
        target_hit_list = arcade.check_for_collision_with_list(
            self.player_sprite, self.target_list)

        # Change color of cursor on top of target
        hitTarget = False
        for target in target_hit_list:
            hitTarget = True

        if hitTarget is True:
            arcade.start_render()
            arcade.draw_rectangle_filled(center_x=self.player_sprite.center_x,
                                         center_y=self.player_sprite.center_y,
                                         width=WIDTH,
                                         height=HEIGHT,
                                         color=arcade.color.GREEN)
            arcade.finish_render()
            arcade.pause(1)
            # Play major arpeggio upward
            play_sound(value='C', sec=0.1, octave=4)
            arcade.pause(0.1)
            play_sound(value='E', sec=0.1, octave=4)
            arcade.pause(0.1)
            play_sound(value='G', sec=0.1, octave=4)
            arcade.pause(0.1)
            play_sound(value='C', sec=0.1, octave=5)

        # Loop through each colliding sprite, removing it, and adding to the score
        for target in target_hit_list:
            target.kill()
            self.display_rest()
            self.score += 1
            self.create_target()
def draw_character(x, y):
    # This function will draw the main character, x and y are starting coordinates
    # Open window
    arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, "Main Character")

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

    # Get ready to draw
    arcade.start_render()

    # Draw Head
    # Hair
    arcade.draw_xywh_rectangle_filled(x + 4, y - 10, 40, 10,
                                      arcade.csscolor.BLACK)
    # Head itself
    arcade.draw_xywh_rectangle_filled(x + 4, y - 37, 40, 27,
                                      arcade.csscolor.SADDLE_BROWN)
    # Mouth
    arcade.draw_xywh_rectangle_filled(x + 30, y - 31, 14, 3,
                                      arcade.csscolor.BLACK)
    # Eyes
    arcade.draw_xywh_rectangle_filled(x + 36, y - 18, 8, 5,
                                      arcade.csscolor.BLACK)

    # Draw Neck
    arcade.draw_xywh_rectangle_filled(x + 19, y - 44, 11, 7,
                                      arcade.csscolor.SADDLE_BROWN)

    # Draw Body
    arcade.draw_xywh_rectangle_filled(x + 13, y - 79, 21, 35,
                                      arcade.csscolor.INDIANRED)
    arcade.draw_xywh_rectangle_outline(x + 13, y - 79, 21, 35,
                                       arcade.csscolor.DARK_GREY, 1)

    # Draw Arms
    # Right Arm
    arcade.draw_xywh_rectangle_filled(x + 22, y - 65, 7, 14,
                                      arcade.csscolor.INDIANRED)
    arcade.draw_xywh_rectangle_outline(x + 22, y - 65, 7, 14,
                                       arcade.csscolor.DARK_GREY, 1)
    # Left Arm
    arcade.draw_xywh_rectangle_filled(x + 34, y - 57, 14, 6,
                                      arcade.csscolor.INDIANRED)
    arcade.draw_xywh_rectangle_outline(x + 34, y - 57, 14, 6,
                                       arcade.csscolor.DARK_GREY, 1)
    # Right Hand
    arcade.draw_xywh_rectangle_filled(x + 22, y - 72, 7, 7,
                                      arcade.csscolor.BROWN)
    arcade.draw_xywh_rectangle_outline(x + 22, y - 72, 7, 7,
                                       arcade.csscolor.DARK_GREY, 1)
    # Left Hand
    arcade.draw_xywh_rectangle_filled(x + 48, y - 57, 4, 6,
                                      arcade.csscolor.BROWN)
    arcade.draw_xywh_rectangle_outline(x + 48, y - 57, 4, 6,
                                       arcade.csscolor.DARK_GREY, 1)

    # Draw Gun
    arcade.draw_polygon_filled(
        ((x + 52, y - 40), (x + 83, y - 40), (x + 83, y - 46),
         (x + 60, y - 46), (x + 60, y - 57), (x + 52, y - 57)),
        arcade.csscolor.GREY)
    arcade.draw_polygon_outline(
        ((x + 52, y - 40), (x + 83, y - 40), (x + 83, y - 46),
         (x + 60, y - 46), (x + 60, y - 57), (x + 52, y - 57)),
        arcade.csscolor.DARK_GREY, 1)

    # Draw Legs
    # Left Leg
    arcade.draw_xywh_rectangle_filled(x + 13, y - 115, 8, 36,
                                      arcade.csscolor.GRAY)
    # Left Shoe
    arcade.draw_polygon_filled(
        ((x + 13, y - 115), (x + 21, y - 115), (x + 25, y - 118),
         (x + 25, y - 123), (x + 12, y - 123)), arcade.csscolor.GREY)
    # Right Leg
    arcade.draw_xywh_rectangle_filled(x + 26, y - 115, 8, 36,
                                      arcade.csscolor.GRAY)
    # Right Shoe
    arcade.draw_polygon_filled(
        ((x + 26, y - 115), (x + 34, y - 115), (x + 38, y - 118),
         (x + 39, y - 123), (x + 26, y - 123)), arcade.csscolor.GREY)

    # Between Legs
    arcade.draw_xywh_rectangle_filled(x + 21, y - 88, 5, 9,
                                      arcade.csscolor.GRAY)

    # Draw Floor
    arcade.draw_xywh_rectangle_filled(0, 0, SCREEN_WIDTH, 47,
                                      arcade.csscolor.GREEN)

    # Finish drawing
    arcade.finish_render()

    # Keep the window up until someone closes it.
    arcade.run()
Exemplo n.º 20
0
    def display_rest(self):
        self.inISI = True
        """ Displays a fixation cross for a predetermined amount of time for rest (inter-trial interval; ITI)"""
        center_x = (WIDTH + MARGIN) * (COLUMN_COUNT / 2) + MARGIN / 2
        center_y = (HEIGHT + MARGIN) * (ROW_COUNT / 2) + MARGIN / 2

        self.ITI_item = arcade.Sprite('Images/empty.png',
                                      image_height=SCREEN_HEIGHT,
                                      image_width=SCREEN_WIDTH,
                                      center_x=center_x,
                                      center_y=center_y)
        self.ITI_list.append(self.ITI_item)
        self.ITI_item = arcade.Sprite('Images/cross.png',
                                      center_x=center_x,
                                      center_y=center_y)
        self.ITI_list.append(self.ITI_item)

        # Cover whole window with a black box and add white fixation cross
        arcade.start_render()
        self.ITI_list.draw()
        arcade.finish_render()

        # Collect baseline data while waiting
        if self.EEGdevice == 7:
            # Audio beep to send pulse to sync box
            print('Need to send that rest is starting')
        elif self.EEGdevice == 8:
            # Send pulse through LSL, 1 if left, 2 if right
            pulseValue = 3  # indicate start of baseline
            self.outlet.push_sample([pulseValue])

        # Wait x number of seconds, then destroy the box and fixation cross
        rest_time = uniform(1.75, 2.25)
        rest_start = time.time()

        step_length = rest_time  # amount of time we want to use for calculation
        buffer = int(self.fs * step_length)

        data = np.zeros((buffer, self.channels))
        for idx in range(buffer):
            if self.EEGdevice == 7:
                # code to read in EEG from DSI-7 here
                tmp = 1  # just put something here to prevent indentation issues
            elif self.EEGdevice == 8:
                sample, timestamp = inlet.pull_sample()
                data[idx, :] = sample

        filtered = filter_data(data.T, sfreq=self.fs, l_freq=7, h_freq=31)
        self.baseline = filtered.T

        while time.time() - rest_start < rest_time:
            tmp = 1  # just do something until time is up

        #arcade.pause(rest_time)
        for item in self.ITI_list:
            item.kill()

        self.inISI = False

        # Reset cursor to center
        self.player_sprite.center_x = center_x
        self.player_sprite.center_y = center_y
        self.player_list.append(self.player_sprite)

        # Reset trial time-out timer
        self.trialTime = time.time()

        # Send pulse to signify end of rest period
        if self.EEGdevice == 7:
            # Audio beep to send pulse to sync box
            print('Need to send that rest is ending')
        elif self.EEGdevice == 8:
            # Send pulse through LSL, 1 if left, 2 if right
            pulseValue = 4  # indicate the end of baseline
            self.outlet.push_sample([pulseValue])
Exemplo n.º 21
0
arcade.open_window(WIDTH, HEIGHT, "My Random Art")

# Use white canvas, see possible colors here: http://arcade.academy/arcade.color.html
arcade.set_background_color(arcade.color.DARK_BLUE)

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

# Draw dots in a random position with a random color, inside the window
number_of_dots = 200
for i in range(0, number_of_dots):
    x = random.randint(0, WIDTH)
    y = random.randint(0, HEIGHT)

    red = random.randint(50, 255)
    green = random.randint(50, 255)
    blue = random.randint(100, 255)
    alpha = random.randint(100, 255)

    color = (red, green, blue, alpha)

    dot_size = random.randint(15, 50)

    if i % 2 == 0:
        arcade.draw_point(x, y, color, dot_size)
    else:
        arcade.draw_circle_filled(x, y, dot_size, color)

arcade.finish_render()  # Need this to put the drawing to the screen

arcade.run()  # This keep the window open until closed by the user
Exemplo n.º 22
0
 def initial_display_state(self):
     arcade.start_render()
     self.gui.draw(self.gamestate)
     arcade.finish_render()
Exemplo n.º 23
0
import arcade
import os

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

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

arcade.set_background_color(arcade.color.WHITE)

arcade.start_render()

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

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

arcade.finish_render()

arcade.run()
Exemplo n.º 24
0
def graphics_draw(shards_arr):
    arcade.start_render()
    for shard in shards_arr:
        shard.draw()

    arcade.finish_render()