Пример #1
0
 def draw(self):
     """Method draw background, pipes, score board, bird"""
     arcade.draw_texture_rectangle(self.width // 2, self.height // 2, self.width, self.height, self.background, alpha=200 )
     self.pipe_sprites.draw()
     self.score_board.draw()
     self.bird.draw()
     arcade.draw_scaled_texture_rectangle(self.width // 2, self.instruction.height * 0.65, self.instruction)
Пример #2
0
 def draw(self):
     delay = 5
     if self.red: delay = 0.5
     if self.timer < global_variables.BULLET_TIMER - delay:
         arcade.draw_scaled_texture_rectangle(self.center.x, self.center.y,
                                              self.texture, self.scale,
                                              self.rotation, self.alpha)
Пример #3
0
 def on_draw(self):
     arcade.start_render()
     arcade.draw_lrwh_rectangle_textured(
         0, 0,
         constants.LEVEL_WIDTH, self.window.h,  # 100 x 9 level
         self.background)
     self.platform_list.draw()
     self.enemy_list.draw()
     self.cashier.draw()
     self.player_list.draw()
     self.window.item_list.draw()
     tp_amount = arcade.load_texture(
         "assets/amounts/toilet_paper_amount.png")
     scale = 1
     arcade.draw_scaled_texture_rectangle(
         max(120, self.view_left + 70), self.window.h - 35, tp_amount, scale, 0)
     score_text = f"{self.window.score}"
     arcade.draw_text(score_text, max(94, self.view_left + 44), self.window.h - 50,
                      arcade.csscolor.BLACK, 18)
     if self.window.score < self.window.goal and arcade.check_for_collision(self.player, self.cashier):
         arcade.draw_text("Come back with 15 items", self.view_left + self.window.w / 2, self.window.h - 50,
                          arcade.csscolor.CRIMSON, 24, anchor_x="center")
     elif self.window.score >= self.window.goal:
         arcade.draw_text("Find the cashier to checkout", self.view_left + self.window.w / 2, self.window.h - 50,
                          arcade.csscolor.CRIMSON, 24, anchor_x="center")
Пример #4
0
    def draw_gamestate_screens(self):
        mouse_x = self.mouse_position.x
        mouse_y = self.mouse_position.y

        if self.is_main_menu():
            self.screens.main_menu_screen.draw()
            self.screens.main_menu_screen.check_mouse_hovering_over_button(
                mouse_x, mouse_y)
            if self.mouse_pressed:
                self.screens.main_menu_screen.check_mouse_clicked(
                    mouse_x, mouse_y)

        if self.is_pause():
            self.screens.pause_screen.draw()

        if self.is_new_level():
            self.screens.new_level_screen.draw()

        if self.is_ship_was_hit():
            self.screens.ship_was_hit_msg.draw()

        if self.is_game_over():
            self.screens.game_over_screen.draw()
            if self.score_name_record:
                # self.write_high_score()
                self.score_name_record = False

        if self.is_resume():
            arcade.draw_scaled_texture_rectangle(
                global_variables.SCREEN_RIGHT_X - 50, 10,
                arcade.load_texture(
                    global_variables.PAUSE_HINT_IMAGE_FILENAME),
                global_variables.DEFAULT_TEXTURE_SCALE / 2,
                global_variables.DEFAULT_TEXTURE_ANGLE,
                global_variables.DEFAULT_TEXTURE_ALPHA)
Пример #5
0
    def draw(self):

        for i in range(3):
            arcade.draw_scaled_texture_rectangle(
                self.x + (i - 1) * Strikes.BOX_WIDTH, self.y,
                Strikes.STRIKE_IMAGE if i < self.strikes else
                Strikes.NOT_STRIKE_IMAGE, Strikes.SCALE, 0)
Пример #6
0
    def on_draw(self):
        """ Render the screen. """

        arcade.start_render()

        self.ground_list.draw()
        self.wall_list.draw()
        self.tree_list.draw()
        self.decor_list.draw()
        self.player_list.draw()
        self.treetops_list.draw()
        self.enemy_list.draw()
        self.bullet_list.draw()
        self.crosshair.draw()

        # Put the health on the screen.
        for i in range(self.player_sprite.player_health):
            arcade.draw_scaled_texture_rectangle(30 + 35 * i, 615, self.heart,
                                                 1.5)

        # Put the score on the screen.
        output = f"Score: {self.score}"
        arcade.draw_text(output, 10, 10, arcade.color.WHITE, 14)
        if self.wave_transition:
            waveMsg = f"Wave {self.Wave}"
            arcade.draw_text(waveMsg,
                             SCREEN_WIDTH / 2,
                             SCREEN_HEIGHT / 2,
                             arcade.color.BLACK,
                             font_size=75,
                             anchor_x="center")
Пример #7
0
 def on_draw(self):
     """ Draw the menu """
     arcade.start_render()
     arcade.draw_lrwh_rectangle_textured(
         bottom_left_x=self.game_view.view_left,
         bottom_left_y=self.game_view.view_bottom,
         width=SCREEN_WIDTH,
         height=SCREEN_HEIGHT,
         texture=arcade.load_texture("images/JWDLx5AZBtI.jpg"),
         alpha=200)
     arcade.draw_scaled_texture_rectangle(
         self.game_view.view_left + 400,
         self.game_view.view_bottom + 150,
         arcade.load_texture("images/Tiles/lockRed.png"),
         scale=1.4)
     arcade.draw_text("GAME OVER",
                      self.game_view.view_left + 400,
                      self.game_view.view_bottom + 400,
                      arcade.color.BLACK,
                      font_size=50,
                      anchor_x="center")
     arcade.draw_text("PRESS ENTER TO REPLAY",
                      self.game_view.view_left + 400,
                      self.game_view.view_bottom + 300,
                      arcade.color.ORANGE_PEEL,
                      font_size=30,
                      anchor_x="center")
     PauseView(self.game_view).draw_menu_gameplay()
     self.game_view.update_score()
Пример #8
0
    def draw_board(self):
        # Draw a grid
        # Draw vertical lines every 256 pixels
        for x in [256]:
            arcade.draw_line(x, 0, x, self.board_height, arcade.color.BLACK, 2)

        # Draw horizontal lines every 256 pixels
        for y in [256, 512, self.screen_height]:
            arcade.draw_line(0, y, self.screen_width, y, arcade.color.BLACK, 2)

        # Prep x,y pairs for where to print icons
        pos_list = []

        for x in [1, 3]:
            for y in [1, 3]:
                pos_list.append(
                    [self.screen_width * (x / 4), self.board_height * (y / 4)])

        # Load and draw all icons
        for ind, texture in enumerate(self.texture_list):
            freq = self.flicker_frequency[ind]
            pos = pos_list[ind]
            scale = .8
            # if self.tick % freq == 0 and self.tick != 0:
            if freq[self.tick % PATTERN_LENGTH]:
                arcade.draw_scaled_texture_rectangle(pos[0], pos[1], texture,
                                                     scale, 0)
Пример #9
0
 def draw_controls(self):
     arcade.draw_scaled_texture_rectangle(
         global_variables.SCREEN_CENTER_X + 225,
         global_variables.SCREEN_CENTER_Y - 150,
         self.game_controls_image_texture,
         global_variables.DEFAULT_TEXTURE_SCALE / 2,
         global_variables.DEFAULT_TEXTURE_ANGLE,
         global_variables.DEFAULT_TEXTURE_ALPHA)
Пример #10
0
    def setup(self):
        # Adding buttons
        self.ui_menager.purge_ui_elements()
        button_play_again = buttons.PlayAgainButton(self.width // 2,
                                                    self.height // 4,
                                                    self.play_again_texture,
                                                    self.difficulty,
                                                    self.high_scores)
        button_exit = buttons.ExiteButton(
            self.width - self.exit_texture.width // 2,
            self.exit_texture.height * 0.6, self.exit_texture)
        button_menu = buttons.MenuButton(self.menu_texture.width // 2,
                                         self.menu_texture.height * 0.6)
        self.ui_menager.add_ui_element(button_play_again)
        self.ui_menager.add_ui_element(button_exit)
        self.ui_menager.add_ui_element(button_menu)
        # Start drawing
        arcade.start_render()
        arcade.draw_texture_rectangle(self.width // 2, self.height // 2,
                                      self.width, self.height, self.background)
        self.piepes.draw()
        self.bird.draw()
        arcade.draw_scaled_texture_rectangle(
            self.width // 2,
            self.game_over.height,
            self.game_over,
        )
        # Setup score
        self.score_y = (
            self.height - self.game_over.height - button_play_again.height //
            2) // 2 + button_play_again.height // 2 + self.height // 4
        self.score_x = (self.width - self.score_width -
                        self.score_texture.width // 10) // 2
        arcade.draw_scaled_texture_rectangle(self.score_x, self.score_y,
                                             self.score_texture)
        left = self.score_x + self.score_texture.width // 2 + self.number_width
        for digit in str(self.score):
            arcade.draw_scaled_texture_rectangle(
                center_x=left + self.number_width * 1.2 // 2,
                center_y=self.score_y,
                texture=arcade.load_texture(SCORE[digit + 'b']))
            left += self.number_width * 1.2

        # Setup high score
        arcade.draw_scaled_texture_rectangle(
            self.width // 2, button_play_again.top - button_play_again.height,
            arcade.load_texture(LABELS['high_score']))
        score_length = len(str(self.high_scores[self.difficulty]))
        score_width = self.number_width * 1.2 * score_length
        left = (self.width - score_width) // 2

        for digit in str(self.high_scores[self.difficulty]):
            arcade.draw_scaled_texture_rectangle(
                center_x=left + self.number_width * 1.2 // 2,
                center_y=arcade.load_texture(SCORE['1b']).height * 0.6,
                texture=arcade.load_texture(SCORE[digit + 'b']))
            left += self.number_width * 1.2
Пример #11
0
 def draw_new_ball(self):
     scale = 2
     arcade.draw_scaled_texture_rectangle(
         self.player_sprite.center_x,
         self.player_sprite.center_y,
         self.ball_texture,
         scale,
         0,
     )
Пример #12
0
    def draw(self):
        arcade.draw_scaled_texture_rectangle(self.x, self.y, self.texture, 1,
                                             self.rotation)

        if self.held_item is not None:
            rad = math.radians(self.rotation) + self.item_r
            arcade.draw_scaled_texture_rectangle(
                self.x + math.cos(rad) * self.item_d,
                self.y + math.sin(rad) * self.item_d, self.held_item.texture,
                Item.SCALE, self.rotation + math.degrees(self.item_or))
Пример #13
0
    def on_draw(self):
        """ This is the method called when the drawing time comes."""
        # Render all objects
        arcade.start_render()
        self.draw()
        left = self.bird.width // 2

        for _ in range(self.life):
            arcade.draw_scaled_texture_rectangle(left, self.height - self.bird.height//2, self.bird.texture)
            left += self.bird.width
Пример #14
0
def draw_menu_button():
    arcade.draw_scaled_texture_rectangle(BUTTONS['menu'][1],
                                         BUTTONS['menu'][2],
                                         BUTTONS['menu'][0],
                                         scale=1.4)
    arcade.draw_text("MENU",
                     SCREEN_WIDTH / 15.5,
                     SCREEN_HEIGHT / 9.5,
                     arcade.color.BLACK,
                     font_size=20,
                     align="right")
Пример #15
0
    def draw(self):
        # draw buttons
        self.draw_buttons()

        # draw message
        arcade.draw_scaled_texture_rectangle(
            global_variables.SCREEN_CENTER_X,
            global_variables.SCREEN_CENTER_Y + 20,
            self.new_level_screen_texture,
            global_variables.DEFAULT_TEXTURE_SCALE / 2,
            global_variables.DEFAULT_TEXTURE_ANGLE,
            global_variables.DEFAULT_TEXTURE_ALPHA)
Пример #16
0
 def draw(self):
     arcade.draw_scaled_texture_rectangle(self.x, self.y, self.texture,
                                          Clock.SCALE, 0)
     arcade.draw_text(self.time_as_str(),
                      self.x,
                      self.y,
                      arcade.color.RED,
                      40,
                      align="center",
                      anchor_x="center",
                      anchor_y="center",
                      font_name="res/font/DIGITALDREAMNARROW.ttf")
Пример #17
0
    def draw(self):
        # draw buttons
        self.draw_buttons()

        # draw game over message
        arcade.draw_scaled_texture_rectangle(
            global_variables.SCREEN_CENTER_X,
            global_variables.SCREEN_CENTER_Y + 20,
            self.game_over_msg_image_texture,
            global_variables.DEFAULT_TEXTURE_SCALE / 2,
            global_variables.DEFAULT_TEXTURE_ANGLE,
            global_variables.DEFAULT_TEXTURE_ALPHA)
Пример #18
0
 def draw_menu_gameplay(self):
     arcade.draw_scaled_texture_rectangle(
         self.game_view.view_left + 80,
         self.game_view.view_bottom + 67,
         arcade.load_texture("images/HUD/hudJewel_yellow.png"),
         scale=1.4)
     arcade.draw_text("MENU",
                      self.game_view.view_left + 50,
                      self.game_view.view_bottom + 60,
                      arcade.color.BLACK,
                      font_size=20,
                      align="center")
Пример #19
0
    def draw_checkerboards(self):
        # Load and draw all checkerboards
        for ind, last_state in enumerate(self.last_state):
            freq = self.flicker_frequency[ind]
            pos = self.checkerboard_pos_list[ind]
            texture = self.texture_list[last_state]

            # if this is a switch state, change checkerboard state:
            if freq[self.tick % len(freq)]:
                self.last_state[ind] = not last_state

            arcade.draw_scaled_texture_rectangle(pos[0], pos[1], texture, self.draw_scale, 0)
Пример #20
0
    def draw_control_buttons(self):
        arcade.draw_scaled_texture_rectangle(BUTTONS['big_left'][1],
                                             BUTTONS['big_left'][2],
                                             BUTTONS['big_left'][0],
                                             scale=1.4)
        arcade.draw_scaled_texture_rectangle(BUTTONS['big_right'][1],
                                             BUTTONS['big_right'][2],
                                             BUTTONS['big_right'][0],
                                             scale=1.4)
        arcade.draw_text("EXIT",
                         SCREEN_WIDTH / 10,
                         SCREEN_HEIGHT / 10,
                         arcade.color.BLACK,
                         font_size=20,
                         anchor_x="center")
        arcade.draw_text("SELECT LEVEL",
                         SCREEN_WIDTH / 1.1,
                         SCREEN_HEIGHT / 10,
                         arcade.color.BLACK,
                         font_size=17,
                         anchor_x="center")

        arcade.draw_scaled_texture_rectangle(BUTTONS['author'][1],
                                             BUTTONS['author'][2],
                                             BUTTONS['author'][0],
                                             scale=0.7)
        arcade.draw_scaled_texture_rectangle(BUTTONS['instruction'][1],
                                             BUTTONS['instruction'][2],
                                             BUTTONS['instruction'][0],
                                             scale=0.7)
        arcade.draw_scaled_texture_rectangle(BUTTONS['scores'][1],
                                             BUTTONS['scores'][2],
                                             BUTTONS['scores'][0],
                                             scale=0.7)
        arcade.draw_text("?",
                         BUTTONS['instruction'][1],
                         BUTTONS['instruction'][2] - 15,
                         arcade.color.BLACK,
                         font_size=25,
                         anchor_x="center")
        arcade.draw_text("Scores",
                         BUTTONS['scores'][1],
                         BUTTONS['scores'][2] - 5,
                         arcade.color.BLACK,
                         font_size=10,
                         anchor_x="center")
        arcade.draw_text("A",
                         BUTTONS['author'][1],
                         BUTTONS['author'][2] - 15,
                         arcade.color.BLACK,
                         font_size=25,
                         anchor_x="center")
Пример #21
0
 def draw(self) -> None:
     """Draw the background environment."""
     arcade.start_render()
     arcade.draw_lrwh_rectangle_textured(0, 0, constants.SCREEN_WIDTH,
                                         constants.SCREEN_HEIGHT,
                                         self.background)
     arcade.draw_scaled_texture_rectangle(
         constants.SCREEN_WIDTH / 2, constants.SCREEN_HEIGHT * .8,
         self.pond, constants.SCREEN_WIDTH / self.pond.image.width)
     arcade.draw_scaled_texture_rectangle(constants.SCREEN_WIDTH * .67,
                                          constants.SCREEN_HEIGHT * .78,
                                          self.pondhouse)
     super().draw()
Пример #22
0
    def on_draw(self):
        try:
            arcade.start_render()

            x = 50
            y = 50
            scale = 1.0

            assert arcade.get_pixel(50, 50) == (59, 122, 87)
            arcade.draw_scaled_texture_rectangle(x, y, self.texture, scale)
            assert arcade.get_pixel(50, 50) == (255, 204, 0)

        except Exception as e:
            assert e is None
Пример #23
0
    def draw(self):
        # draw buttons
        self.draw_buttons()

        # draw controls hints
        self.draw_controls()

        # draw 'paused' message
        arcade.draw_scaled_texture_rectangle(
            global_variables.SCREEN_CENTER_X,
            global_variables.SCREEN_CENTER_Y + 20, self.paused_image_texture,
            global_variables.DEFAULT_TEXTURE_SCALE / 2,
            global_variables.DEFAULT_TEXTURE_ANGLE,
            global_variables.DEFAULT_TEXTURE_ALPHA)
Пример #24
0
 def draw(self):
     if self.display:
         if not self.mouse_hover or not self.mouse_click:
             arcade.draw_scaled_texture_rectangle(
                 self.center.x, self.center.y, self.texture,
                 global_variables.BUTTON_DEFAULT_SCALE * 1.5,
                 global_variables.DEFAULT_TEXTURE_ANGLE,
                 global_variables.DEFAULT_TEXTURE_ALPHA)
         else:
             arcade.draw_scaled_texture_rectangle(
                 self.center.x, self.center.y, self.mh_texture,
                 global_variables.BUTTON_DEFAULT_SCALE * 1.5,
                 global_variables.DEFAULT_TEXTURE_ANGLE,
                 global_variables.DEFAULT_TEXTURE_ALPHA)
Пример #25
0
    def draw(self):
        if self.day == 1:
            arcade.draw_scaled_texture_rectangle(self.x, self.y,
                                                 Note.PICTURE_IMAGE,
                                                 Note.SCALE, 0)

            arcade.draw_scaled_texture_rectangle(self.x - 20, self.y + 60,
                                                 assets.items[self.item],
                                                 Note.SCALE * .30, 35)
        elif self.day == 2:
            arcade.draw_scaled_texture_rectangle(self.x, self.y,
                                                 Note.NOTE_IMAGE, Note.SCALE,
                                                 0)
            arcade.draw_text(self.text,
                             self.x - 50,
                             self.y,
                             arcade.color.BLACK,
                             55,
                             align="center",
                             anchor_x="center",
                             anchor_y="center",
                             font_name="res/font/Billys_Hand_Thin.ttf")
        elif self.day == 3:
            arcade.draw_scaled_texture_rectangle(
                self.x, self.y, Note.KALLELLSE_WRONG_IMAGE if self.fake_type
                == "Card" else Note.KALLELLSE_IMAGE, Note.SCALE, 0)
            arcade.draw_text(self.name.replace("_", " ").capitalize(),
                             self.x - 33,
                             self.y + 58,
                             arcade.color.BLACK,
                             22,
                             align="center",
                             anchor_x="center",
                             anchor_y="center",
                             font_name="res/font/Hand_Power.ttf",
                             rotation=5)
            item = self.item.replace("_", " ")
            if item.startswith("balloon"):
                item = " ".join(item.split()[::-1])
            arcade.draw_text(item,
                             self.x,
                             self.y - 10,
                             arcade.color.BLACK,
                             22,
                             align="center",
                             anchor_x="center",
                             anchor_y="center",
                             font_name="res/font/Hand_Power.ttf",
                             rotation=5)
            arcade.draw_text(self.date,
                             self.x + 200,
                             self.y - 60,
                             arcade.color.BLACK,
                             22,
                             align="center",
                             anchor_x="center",
                             anchor_y="center",
                             font_name="res/font/Hand_Power.ttf",
                             rotation=7)
Пример #26
0
    def draw(self):
        # draw buttons
        self.draw_buttons()

        # draw controls
        self.draw_controls()

        # draw title
        arcade.draw_scaled_texture_rectangle(
            global_variables.SCREEN_CENTER_X,
            global_variables.SCREEN_CENTER_Y + 100,
            self.asteroids_logo_image_texture,
            global_variables.DEFAULT_TEXTURE_SCALE,
            global_variables.DEFAULT_TEXTURE_ANGLE,
            global_variables.DEFAULT_TEXTURE_ALPHA)
Пример #27
0
    def on_draw(self):
        arcade.start_render()

        scale = .6
        arcade.draw_texture_rectangle(540, 120,
                                      self.texture.image.width * scale,
                                      self.texture.image.height * scale,
                                      self.texture, angle=45)

        arcade.draw_xywh_rectangle_textured(10, 400, 64, 64, self.texture)

        for i in range(15):
            arcade.draw_scaled_texture_rectangle(i * 50 + 20, 220,
                                                 self.texture,
                                                 scale,
                                                 angle=45, alpha=i * 15)
Пример #28
0
    def on_mouse_motion(self, x, y, key, modifiers):
        """
        Called when user moves the mouse
        """
        # handle mouse motion
        if DEBUG: print("game.on_mouse_motion() called")
        if DEBUG: print(f"new game.mouse_position == Point({x}, {y})")
        self.mouse_position.x = x
        self.mouse_position.y = y

        arcade.draw_scaled_texture_rectangle(
            x, y,
            arcade.load_texture(
                global_variables.ASTEROIDS_LOGO_IMAGE_FILENAME),
            global_variables.DEFAULT_TEXTURE_SCALE,
            global_variables.DEFAULT_TEXTURE_ANGLE,
            global_variables.DEFAULT_TEXTURE_ALPHA)
Пример #29
0
    def draw(self):
        # draw ship (or air horn)
        scale = self.scale
        texture = self.texture
        rotation = self.rotation

        if self.troll_mode:
            scale /= 2
            texture = self.air_horn_texture
            if self.is_ship_life_icon: rotation -= 90

        if self.thrust:
            texture = self.ship_with_flames_texture

        arcade.draw_scaled_texture_rectangle(self.center.x, self.center.y,
                                             texture, scale, rotation,
                                             self.alpha)
Пример #30
0
 def on_draw(self):
     arcade.start_render()
     arcade.draw_text("Pirate Plunder",
                      SCREEN_WIDTH / 2,
                      SCREEN_HEIGHT / 2,
                      arcade.color.BLACK,
                      font_size=75,
                      anchor_x="center")
     arcade.draw_text("CLICK TO START",
                      SCREEN_WIDTH / 2,
                      SCREEN_HEIGHT / 2 - 50,
                      arcade.color.BLACK,
                      font_size=40,
                      anchor_x="center")
     arcade.draw_scaled_texture_rectangle(SCREEN_WIDTH / 2,
                                          SCREEN_HEIGHT / 2 - 200,
                                          self.background, .1)
     self.crosshair.draw()