Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, width, height):
"""
Initializer
"""
super().__init__(width, height)
arcade.set_background_color(arcade.color.WHITE)
self.laser_wav = arcade.load_sound(":resources:sounds/laser1.wav")
self.laser_mp3 = arcade.load_sound(":resources:laser1.mp3")
self.laser_ogg = arcade.load_sound(":resources:laser1.ogg")
self.frame_count = 0
def on_draw(self):
# This command has to happen before we start drawing
arcade.start_render()
# Draw all the sprites.
self.coin_list.draw()
self.player_list.draw()
# Put the text on the screen.
output = "Score: " + str(self.score)
arcade.draw_text(output, 10, 20, arcade.color.WHITE, 14)
on_draw.oval.draw()
on_draw.ellipse.draw()
on_draw.circle.draw()
on_draw.square.draw()
arcade.draw_all(shapes)
#update shape positions
on_draw.rectangle.update()
on_draw.oval.update()
on_draw.ellipse.update()
on_draw.circle.update()
on_draw.square.update()
arcade.update_all(shapes)
arcade.open_window("Drawing Example", 800, 600)
arcade.set_background_color(arcade.color.WHITE)
on_draw.rectangle = arcade.Rectangle(400 , 100, 35, 50, arcade.color.PURPLE)
on_draw.rectangle.change_x = 3
on_draw.rectangle.change_y = 2
on_draw.oval = arcade.Oval(250, 250, 50, 25, arcade.color.ORANGE)
on_draw.oval.change_x = 1
on_draw.oval.change_y = -1
on_draw.ellipse = arcade.Ellipse(500, 0, 25, 50, arcade.color.COCONUT)
on_draw.ellipse.change_y = 2
on_draw.ellipse.change_angle = 15
on_draw.circle = arcade.Circle(350, 250, 15, arcade.color.BLUE)
on_draw.circle.change_x = 1
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)
# Draw all the sprites.
self.all_sprites_list.draw()
# Put the text on the screen.
# Adjust the text position based on the view port so that we don't
# scroll the text too.
distance = self.view_left + self.player_sprite.right
output = f"Distance: {distance}"
arcade.draw_text(output, self.view_left + 10, self.view_bottom + 20, arcade.color.WHITE, 14)
if self.game_over:
output = "Game Over"
arcade.draw_text(output, self.view_left + 200,
self.view_bottom + 200,
arcade.color.WHITE, 30)
# This command has to happen before we start drawing
arcade.start_render()
# Draw the sprites.
self.static_wall_list.draw()
self.moving_wall_list.draw()
self.player_list.draw()
# Put the text on the screen.
# Adjust the text position based on the viewport so that we don't
# scroll the text too.
distance = self.player_sprite.right
output = f"Distance: {distance}"
arcade.draw_text(output, self.view_left + 10, self.view_bottom + 20,
arcade.color.WHITE, 14)
# Start timing how long this takes
draw_start_time = timeit.default_timer()
# Draw all the sprites.
self.wall_list.draw()
self.player_list.draw()
# Draw info on the screen
sprite_count = len(self.wall_list)
output = f"Sprite Count: {sprite_count}"
arcade.draw_text(output,
self.view_left + 20,
SCREEN_HEIGHT - 20 + self.view_bottom,
arcade.color.WHITE, 16)
output = f"Drawing time: {self.draw_time:.3f}"
arcade.draw_text(output,
self.view_left + 20,
SCREEN_HEIGHT - 40 + self.view_bottom,
arcade.color.WHITE, 16)
output = f"Processing time: {self.processing_time:.3f}"
arcade.draw_text(output,
self.view_left + 20,
SCREEN_HEIGHT - 60 + self.view_bottom,
arcade.color.WHITE, 16)
self.draw_time = timeit.default_timer() - draw_start_time
def on_show(self):
arcade.set_background_color(arcade.color.WHITE)
def make_person(head_radius,
chest_height,
chest_width,
leg_width,
leg_height,
arm_width,
arm_length,
arm_gap,
shoulder_height):
shape_list = arcade.ShapeElementList()
# Head
shape = arcade.create_ellipse_filled(0, chest_height / 2 + head_radius, head_radius, head_radius,
arcade.color.WHITE)
shape_list.append(shape)
# Chest
shape = arcade.create_rectangle_filled(0, 0, chest_width, chest_height, arcade.color.BLACK)
shape_list.append(shape)
# Left leg
shape = arcade.create_rectangle_filled(-(chest_width / 2) + leg_width / 2, -(chest_height / 2) - leg_height / 2,
leg_width, leg_height, arcade.color.RED)
shape_list.append(shape)
# Right leg
shape = arcade.create_rectangle_filled((chest_width / 2) - leg_width / 2, -(chest_height / 2) - leg_height / 2,
leg_width, leg_height, arcade.color.RED)
shape_list.append(shape)
def on_draw(self):
""" Draw everything """
arcade.start_render()
self.coin_list.draw()
self.player_list.draw()
# Put the text on the screen.
output = f"Score: {self.score}"
arcade.draw_text(output, 10, 20, arcade.color.WHITE, 14)