Пример #1
0
    def on_draw(self):
        """ Use this function to draw everything to the screen. """

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

        # Calculate minutes
        minutes = int(self.total_time) // 60

        # Calculate seconds by using a modulus (remainder)
        seconds = int(self.total_time) % 60

        # Figure out our output
        output = "Time minutes:" + format(minutes) + " seconds:" + format(
            seconds) + "   "

        # See if the output is the same as last frame. If not, generate a new
        # text object.
        if not self.timer_text or self.timer_text.text != output:
            self.timer_text = arcade.create_text(output, arcade.color.BLACK,
                                                 30)

        # Output the timer text.
        arcade.render_text(self.timer_text, 300, 300)
Пример #2
0
    def on_draw(self):
        """
        Render the screen.
        """

        # This command has to happen before we start drawing
        arcade.start_render()

        # Draw the background texture
        arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2,
                                      SCREEN_WIDTH, SCREEN_HEIGHT,
                                      self.background)

        # Draw all the sprites.
        self.coin_list.draw()
        self.player_sprite.draw()

        # Put the text on the screen.
        output = "Score: " + format(self.score)

        # Is this the same text as last frame? If not, set up a new text object
        if not self.score_text or output != self.score_text.text:
            self.score_text = arcade.create_text(output, arcade.color.WHITE,
                                                 14)
        # Render the text
        arcade.render_text(self.score_text, 10, 20)
Пример #3
0
 def draw(self):
     self.label_location_map.clear()
     from .app import app
     center_x = app.window.width // 2
     y = super(Menu, self).draw()
     y += self.label_height // 2
     for i, label in enumerate(self.labels):
         focused = i == self.selected_action_index
         self.label_location_map[(center_x, y)] = i
         arcade.draw_rectangle_filled(color=arcade.color.BABY_BLUE if
                                      focused else arcade.color.BLUE_GRAY,
                                      center_x=center_x,
                                      center_y=app.window.height - y,
                                      width=self.label_width,
                                      height=self.label_height)
         arcade.draw_rectangle_outline(
             color=arcade.color.BLUE if focused else arcade.color.BLACK,
             center_x=center_x,
             center_y=app.window.height - y,
             width=self.label_width,
             height=self.label_height)
         arcade.render_text(label,
                            start_x=center_x - label.content_width // 2,
                            start_y=app.window.height - y)
         y += self.label_height + self.label_step_size
Пример #4
0
 def on_draw(self):
     arcade.start_render()
     self.all_sprites_list.draw()  #วาดทุกอย่างที่สร้าง
     output = f"Score : {self.score}"  #scoreboard
     if not self.score_text or output != self.score_text.text:
         self.score_text = arcade.create_text(output, arcade.color.WHITE,
                                              17)
     arcade.render_text(self.score_text, SCREEN_WIDTH / 25,
                        SCREEN_HEIGHT * 2.44 / 25)
     output2 = f"Player's HP : {self.hp}"  #hp
     if not self.hp_text or output2 != self.hp_text.text:
         self.hp_text = arcade.create_text(output2, arcade.color.WHITE, 17)
     arcade.render_text(self.hp_text, SCREEN_WIDTH / 25, SCREEN_HEIGHT / 25)
     if self.BOSS == True:  #bosshp
         output3 = f"{self.currentbossname} : {self.boss_hp}"
         if not self.boss_hp_text or output3 != self.boss_hp_text.text:
             self.boss_hp_text = arcade.create_text(output3,
                                                    arcade.color.RED, 17)
         arcade.render_text(self.boss_hp_text, SCREEN_WIDTH * 16.5 / 25,
                            SCREEN_HEIGHT / 25)
     output4 = f"Level : {self.current_lv}"  #level ปัจจุบัน
     if not self.current_lv_text or output4 != self.current_lv_text.text:
         self.current_lv_text = arcade.create_text(output4,
                                                   arcade.color.WHITE, 17)
     arcade.render_text(self.current_lv_text, SCREEN_WIDTH / 25,
                        SCREEN_HEIGHT * 3.12 / 25)
     output5 = f"Fenceproof : {self.fenceproof}"  #รั้ว
     if not self.fenceproof_text or output5 != self.fenceproof_text.text:
         self.fenceproof_text = arcade.create_text(output5,
                                                   arcade.color.WHITE, 17)
     arcade.render_text(self.fenceproof_text, SCREEN_WIDTH / 25,
                        SCREEN_HEIGHT * 1.72 / 25)
Пример #5
0
 def draw_text(self):
     from .app import app
     p1, p2 = self.get_text_placement()
     center = (p1 + p2) // 2
     arcade.draw_rectangle_filled(color=arcade.color.WHITE,
                                  **app.get_screen_pos_args((p1, p2)))
     if self.edit_mode:
         txt = "-- Edit mode -- Room %r" % (tuple(
             self.cur_room.world_coord), )
     elif self.human_player:
         txt = "Score: %i, lives: %i" % (self.human_player.scores,
                                         self.human_player.lives)
     else:
         txt = "No player"
     if not self.game_text_gfx_label or self.game_text_gfx_label.text != txt:
         self.game_text_gfx_label = arcade.create_text(
             txt, color=arcade.color.BLACK, anchor_y="center")
     arcade.render_text(self.game_text_gfx_label,
                        start_x=p1[0] + 5,
                        start_y=app.window.height - center[1])
     if self.info_text_gfx_label:
         arcade.render_text(self.info_text_gfx_label,
                            start_x=p1[0] +
                            self.game_text_gfx_label.content_width + 20,
                            start_y=app.window.height - center[1])
Пример #6
0
def answer_1():
    arcade.open_window(800, 600, "Magic 8 Ball")
    arcade.set_background_color(arcade.color.WHITE)
    arcade.start_render()

    draw_eight_ball(400, 300)
    arcade.render_text(text=arcade.create_text('NO', arcade.color.BLACK),
                       start_x=350,
                       start_y=300,
                       rotation=0)
    arcade.finish_render()
    arcade.run()
Пример #7
0
    def on_draw(self):
        arcade.start_render()
        self.cloud1_sprite.draw()
        self.cloud2_sprite.draw()
        self.cloud3_sprite.draw()
        self.cloud4_sprite.draw()
        self.cloud5_sprite.draw()
        self.house_sprite.draw()
        draw_background()

        if self.world.endd == "GAME OVER":
            f = open('highscore.log', 'r')
            highscore = f.readline()

            arcade.draw_text("score = {}".format(str(self.world.lastscore)),
                             self.width / 3, self.height / 2,
                             arcade.color.BLACK, 25)
            arcade.render_text(self.endd, self.width / 4 + 10,
                               self.height / 3 * 2)

            arcade.draw_text("Highscore = {}".format(str(highscore)),
                             self.width / 3, self.height / 3,
                             arcade.color.BLACK, 20)
            print('{} > {}'.format(self.world.lastscore, highscore))

            if (int(self.world.lastscore) > int(highscore)):
                f = open('highscore.log', 'w')
                f.write(str(self.world.lastscore))

        else:
            if self.world.shield == 0:
                ModelSprite('images/stupidchar.png',
                            model=self.world.stupid).draw()
            elif self.world.shield == 1:
                ModelSprite('images/readbookchar.png',
                            model=self.world.stupid).draw()
            elif self.world.shield == 2:
                ModelSprite('images/smartchar.png',
                            model=self.world.stupid).draw()
            elif self.world.shield == 3:
                ModelSprite('images/jt.png', model=self.world.stupid).draw()

            self.coin_sprite.draw()
            self.obstacleL_sprite.draw()
            self.obstacleR_sprite.draw()
            for bs in self.world.bonus_list:
                ModelSprite('images/peptein.png', model=bs).draw()
            for ss in self.world.shield_list:
                ModelSprite('images/redbook.png', model=ss).draw()

            arcade.draw_text(str(self.world.score), self.width / 2,
                             self.height - 30, arcade.color.BLACK, 20)
Пример #8
0
def on_draw(delta_time):
    arcade.start_render()

    for c in circles:
        c.move()
        c.draw()
        if player.is_hit(c) == True:
            arcade.render_text(
                arcade.create_text('LOSE', arcade.color.RED, 100), 300, 300)
            time.sleep(1)

    player.control(keys)
    player.draw()
Пример #9
0
 def draw_title(self):
     from .app import app
     width, height = self.get_size()
     center_x = app.window.width // 2
     y = (app.window.height - height) // 2
     y += self.border_size
     if self.title_label:
         arcade.render_text(self.title_label,
                            start_x=center_x -
                            self.title_label.content_width // 2,
                            start_y=app.window.height - y -
                            self.title_label.content_height // 2)
         y += self.title_label.content_height + self.title_step_size
     return y
Пример #10
0
 def draw_time(self):
     text = arcade.create_text('Time:{:.1f}'.format(self.world.time),
                               color=arcade.color.WHITE,
                               font_size=14,
                               anchor_x='center',
                               align='center')
     text_offset = arcade.create_text('Time:{:.1f}'.format(self.world.time),
                                      color=arcade.color.BLACK,
                                      font_size=14,
                                      anchor_x='center',
                                      align='center')
     arcade.render_text(text_offset, SCREEN_WIDTH - EDGE_WIDTH + 2,
                        SCREEN_HEIGHT - EDGE_HEIGHT - 2)
     arcade.render_text(text, SCREEN_WIDTH - EDGE_WIDTH,
                        SCREEN_HEIGHT - EDGE_HEIGHT)
Пример #11
0
    def draw_score(self):
        text = arcade.create_text('Score:{}'.format(self.world.SCORE),
                                  color=arcade.color.WHITE,
                                  font_size=14,
                                  anchor_x='center',
                                  align='center')
        text_offset = arcade.create_text('Score:{}'.format(self.world.SCORE),
                                         color=arcade.color.BLACK,
                                         font_size=14,
                                         anchor_x='center',
                                         align='center')

        arcade.render_text(text_offset, EDGE_WIDTH + 2,
                           SCREEN_HEIGHT - EDGE_HEIGHT - 2)
        arcade.render_text(text, EDGE_WIDTH, SCREEN_HEIGHT - EDGE_HEIGHT)
Пример #12
0
    def first(self):
        arcade.render_text(arcade.create_text(
'''
                            HOW TO PLAY
Reach a final score higher than the dealer without exceeding 21
                                or
 Let the dealer draw addition card until their hand exceeds 21 
    (The dealer must have a final score higher than 17)

                             CONTROL
        Press <SPACE> To Hit
        Press <ENTER> To Stand
        Press <F1> To start new game (when game end)

        CONTINUE TO GAME BY PRESS <ENTER>
''',arcade.color.BLACK,12),50,400)
Пример #13
0
    def on_draw(self):

        arcade.start_render()

        self.all_sprites_list.draw()

        output = f"Score: {self.score}"
        if not self.score_text or output != self.score_text.text:
            self.score_text = arcade.create_text(output, arcade.color.WHITE,
                                                 14)
        arcade.render_text(self.score_text, 10, 70)

        output = "Level: {}".format(self.score // 30)
        if not self.zombie_text or output != self.zombie_text.text:
            self.zombie_text = arcade.create_text(output, arcade.color.WHITE,
                                                  14)
        arcade.render_text(self.zombie_text, 10, 50)
Пример #14
0
    def on_draw(self):
        """ Render the screen. """

        arcade.start_render()

        # Draw the y labels
        i = 0
        for y in range(START, END, STEP):
            arcade.draw_point(0, y, arcade.color.BLUE, 5)
            arcade.render_text(self.label_list[i], 5, y)
            i += 1

        # Draw the x labels.
        i = 1
        for x in range(START + STEP, END, STEP):
            arcade.draw_point(x, 0, arcade.color.BLUE, 5)
            arcade.render_text(self.label_list[i], x, 5)
            i += 1
    def on_draw(self):
        arcade.start_render()

        # Draw background
        self.background_list.draw()
        # Draw all the sprites
        self.player.draw()
        self.enemy_list.draw()
        self.bullet_list.draw()
        self.effect_list.draw()
        self.item_list.draw()
        self.life.draw()
        # Draw text
        output = f"Score: {self.score}"
        self.score_text = arcade.create_text(output, arcade.color.WHITE, 14)
        arcade.render_text(self.score_text, 10, 50)
        output = f"x{self.player.health}"
        self.health_text = arcade.create_text(output, arcade.color.WHITE, 14)
        arcade.render_text(self.health_text, 40, 73)
Пример #16
0
    def on_draw_game(self):
        arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2,
                                      SCREEN_WIDTH, SCREEN_HEIGHT,
                                      self.background)

        #### DRAW CHOICE ####
        self.rock.draw()
        arcade.render_text(self.text_A, 100, 50)

        self.paper.draw()
        arcade.render_text(self.text_S, 200, 50)

        self.scissor.draw()
        arcade.render_text(self.text_D, 300, 50)

        #### DRAW RED ####
        if self.x == 1:
            self.rock_red.draw()
        elif self.x == 2:
            self.paper_red.draw()
        elif self.x == 3:
            self.scissor_red.draw()
        #### DRAW BLUE ####
        elif self.x == 4:
            self.rock_blue.draw()
        elif self.x == 5:
            self.paper_blue.draw()
        elif self.x == 6:
            self.scissor_blue.draw()

        #### DRAW SCORE ####
        output_score = f"Score : {self.score}"
        if not self.score_text or self.score_text.text != output_score:
            self.score_text = arcade.create_text(output_score,
                                                 arcade.color.BLACK, 15)
        arcade.render_text(self.score_text, 300, 475)
        #### DRAW TIME ####
        output_time = f"Time : {round(self.time)}"
        if not self.time_text or self.time_text.text != output_time:
            self.time_text = arcade.create_text(output_time,
                                                arcade.color.BLACK, 15)
        arcade.render_text(self.time_text, 10, 475)
Пример #17
0
    def on_draw(self):
        arcade.start_render()
        arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2,
                                      SCREEN_WIDTH, SCREEN_HEIGHT,
                                      self.background)
        self.player1_p.draw()
        self.player2_p.draw()
        self.town1.draw()
        self.town2.draw()
        self.flag_p1_p.draw()
        self.flag_p2_p.draw()

        minutes = int(self.total_time) // 60
        seconds = int(self.total_time) % 60
        output = f"Time {minutes:02d}:{seconds:02d}"
        output_p1 = "Score: {}".format(FlagPlayer1.score)
        output_p2 = "Score: {}".format(FlagPlayer2.score)

        if not self.timer_text or self.timer_text.text != output:
            self.timer_text = arcade.create_text(output, arcade.color.WHITE,
                                                 20)

        if (FlagPlayer1.score == 5):
            arcade.draw_texture_rectangle(SCREEN_WIDTH // 2,
                                          SCREEN_HEIGHT // 2, SCREEN_WIDTH,
                                          SCREEN_HEIGHT, self.background)
            arcade.draw_text("PLAYER 1 WINS !", 250, 250, arcade.color.WHITE,
                             30)
        if (FlagPlayer2.score == 5):
            arcade.draw_texture_rectangle(SCREEN_WIDTH // 2,
                                          SCREEN_HEIGHT // 2, SCREEN_WIDTH,
                                          SCREEN_HEIGHT, self.background)
            arcade.draw_text("PLAYER 2 WINS !", 250, 250, arcade.color.WHITE,
                             30)

        arcade.render_text(self.timer_text, 650, 450)
        arcade.draw_text(output_p1, 700, 20, arcade.color.WHITE, 15)
        arcade.draw_text(output_p2, 50, 20, arcade.color.WHITE, 15)
Пример #18
0
    def on_draw(self):
        arcade.start_render()
        arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2,
                                      SCREEN_WIDTH, SCREEN_HEIGHT,
                                      self.background)

        if self.is_game_over:
            self.draw_game_over()
            return None
        self.sprites_list.draw()

        output = "{}".format(self.score)
        if not self.score_text or output != self.score_text.text:
            self.score_text = arcade.create_text(output, arcade.color.GOLD, 16)
        arcade.render_text(self.score_text, 450, 662)

        self.coin.draw()
        self.girl[0].draw()
        self.girl[1].draw()
        self.knife[0].draw()
        self.knife[1].draw()
        self.basket[0].draw()
        self.boss[0].draw()
Пример #19
0
    def on_draw(self):
        """
        Render the screen.
        """

        # This command has to happen before we start drawing
        arcade.start_render()

        # Draw all the sprites.
        self.all_sprites_list.draw()

        # Put the text on the screen.
        output = "Score: " + format(self.score)
        if not self.score_text or output != self.score_text.text:
            self.score_text = arcade.create_text(output, arcade.color.WHITE,
                                                 14)
        arcade.render_text(self.score_text, 10, 70)

        output = "Asteroid Count: {}".format(len(self.asteroid_list))
        if not self.asteroid_text or output != self.asteroid_text.text:
            self.asteroid_text = arcade.create_text(output, arcade.color.WHITE,
                                                    14)
        arcade.render_text(self.asteroid_text, 10, 50)
Пример #20
0
 def draw(self):
     arcade.draw_rectangle_filled(self.x, self.y, self.width, self.height,
                                  Blackground_Title.Filled_Color)
     arcade.draw_rectangle_outline(self.x, self.y, self.width, self.height,
                                   Blackground_Title.Outline_Color)
     arcade.draw_line
     arcade.render_text(self.text_title, self.x, self.y)
     arcade.render_text(self.text_title2, self.x, self.y - 80)
     arcade.render_text(self.text_score, self.x, self.y + 50)
Пример #21
0
    def on_draw(self):
        """
        Render the screen.
        """

        # This command has to happen before we start drawing
        arcade.start_render()

        # Draw all the sprites.
        self.player_sprite.draw()
        self.wall_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 = "Distance: "+ format(distance)   # Replaced f (f-string only works in Python 3.6 and will not be backported to previous versions) with u (unicode string)
        if not self.distance_text or output != self.distance_text.text:
            self.distance_text = arcade.create_text(output, arcade.color.WHITE, 14)

        arcade.render_text(self.distance_text, self.view_left + 10, self.view_bottom + 20,)

        if self.game_over:
            arcade.render_text(self.game_over_text, self.view_left + 200, self.view_bottom + 200)
Пример #22
0
    def draw(self):

        if self.cur_gui == "triaging":
            patient = self.patients[self.patient_index]

            patient_text = arcade.create_text(
                f"Name: {patient.name}\n"
                "Symptoms:\n"
                f"{list(patient.symptoms)[0][0]}\n"
                f"{list(patient.symptoms)[1][0]}\n"
                f"{list(patient.symptoms)[2][0]}\n"
                f"Survival chance: {patient.survival_chance}",
                arcade.color.BLACK,
                20,
                align="center",
                anchor_x="center",
                anchor_y="center")

            arcade.draw_text(
                "Press the number you want to have this patient treated (0 INDEXED)",
                10, 10, arcade.color.BLACK)

            arcade.render_text(patient_text, self.width / 2 + 100,
                               self.height / 2)
            arcade.draw_texture_rectangle(self.width / 2 - 50, self.height / 2,
                                          100, 100, patient.texture)
            arcade.render_text(self.patients_text, 10, self.height - 10)

        elif self.cur_gui == "death":
            arcade.render_text(self.patients_deaths, self.width / 2,
                               self.height / 2)

        elif self.cur_gui == "day":
            self.day_text = arcade.create_text(f"Day {self.day}",
                                               arcade.color.BLACK,
                                               20,
                                               align="center",
                                               anchor_x="center",
                                               anchor_y="center")
            arcade.render_text(self.day_text, self.width / 2, self.height / 2)
Пример #23
0
    def on_draw(self):
        """
        Render the screen.
        """

        # This command has to happen before we start drawing
        arcade.start_render()

        # Start timing how long this takes
        draw_start_time = timeit.default_timer()

        # Draw all the sprites
        self.sprite_list.draw()

        # Draw the lines that aren't sprites
        for line in self.static_lines:
            body = line.body

            pv1 = body.position + line.a.rotated(body.angle)
            pv2 = body.position + line.b.rotated(body.angle)
            arcade.draw_line(pv1.x, pv1.y, pv2.x, pv2.y, arcade.color.WHITE, 2)

        for joint in self.joints:
            color = arcade.color.WHITE
            if isinstance(joint, pymunk.DampedSpring):
                color = arcade.color.DARK_GREEN
            arcade.draw_line(joint.a.position.x, joint.a.position.y,
                             joint.b.position.x, joint.b.position.y, color, 3)

        # Display timings
        output = f"Processing time: {self.processing_time:.3f}"
        if not self.processing_time_text or output != self.processing_time_text.text:
            self.processing_time_text = arcade.create_text(
                output, arcade.color.WHITE, 12)
        arcade.render_text(self.processing_time_text, 20, SCREEN_HEIGHT - 20)

        output = f"Drawing time: {self.draw_time:.3f}"
        if not self.draw_time_text or output != self.draw_time_text.text:
            self.draw_time_text = arcade.create_text(output,
                                                     arcade.color.WHITE, 12)
        arcade.render_text(self.draw_time_text, 20, SCREEN_HEIGHT - 40)

        self.draw_time = timeit.default_timer() - draw_start_time

        output = f"Mode: {self.mode}"
        if not self.draw_mode_text or output != self.draw_mode_text.text:
            self.draw_mode_text = arcade.create_text(output,
                                                     arcade.color.WHITE, 12)
        arcade.render_text(self.draw_mode_text, 20, SCREEN_HEIGHT - 60)
Пример #24
0
    def on_draw(self):
        arcade.start_render()

        arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2,
                                      SCREEN_WIDTH, SCREEN_HEIGHT,
                                      self.background)
        self.wall_1.draw()
        self.wall_7.draw()
        self.wall_2.draw()
        self.wall_9.draw()
        self.wall_3.draw()
        self.wall_4.draw()
        self.wall_5.draw()
        self.wall_6.draw()
        self.wall_8.draw()
        self.wall_10.draw()

        self.world.ghost_list.draw()
        self.world.player_list.draw()
        self.world.item_list.draw()
        self.world.food_list.draw()
        self.world.bullet_list.draw()

        #######################################################
        output = f"Score: {self.world.score}"
        if not self.score_text or output != self.score_text.text:
            self.score_text = arcade.create_text(output, arcade.color.WHITE,
                                                 14)
        arcade.render_text(self.score_text, 10, 20)
        #######################################################
        output = f"Energy: {self.world.energy} %"
        if not self.energy_text or output != self.energy_text.text:
            self.energy_text = arcade.create_text(output, arcade.color.WHITE,
                                                  14)
        arcade.render_text(self.energy_text, 140, 20)

        if self.world.game_over:
            arcade.draw_texture_rectangle(SCREEN_WIDTH // 2,
                                          SCREEN_HEIGHT // 2, SCREEN_WIDTH,
                                          SCREEN_HEIGHT, self.background)
            output = f"Your Score: {self.world.score}"
            if not self.score_text or output != self.score_text.text:
                self.score_text = arcade.create_text(output,
                                                     arcade.color.WHITE, 30)
            arcade.render_text(self.score_text, 300, 300)
        if not self.world.start_game:
            arcade.draw_texture_rectangle(SCREEN_WIDTH // 2,
                                          SCREEN_HEIGHT // 2, SCREEN_WIDTH,
                                          SCREEN_HEIGHT, self.intro)
Пример #25
0
    def on_draw(self):
        arcade.start_render()
        self.board.draw()
        self.puck.draw()
        self.player1.draw()
        self.player2.draw()

        arcade.render_text(self.world.scoreboard, SCREEN_WIDTH // 2, 83.5 // 2)

        if self.world.end == True:
            if self.world.player1_score > self.world.player2_score:
                arcade.render_text(
                    arcade.create_text("PLAYER 1 WIN!!!!!",
                                       arcade.color.RED,
                                       50,
                                       align="center",
                                       anchor_x="center",
                                       anchor_y="center"), SCREEN_WIDTH // 2,
                    SCREEN_HEIGHT // 2)
            else:
                arcade.render_text(
                    arcade.create_text("PLAYER 2 WIN!!!!!",
                                       arcade.color.BLUE,
                                       50,
                                       align="center",
                                       anchor_x="center",
                                       anchor_y="center"), SCREEN_WIDTH // 2,
                    SCREEN_HEIGHT // 2)

            arcade.render_text(
                arcade.create_text("Press \"Enter\" to restart.",
                                   arcade.color.CAMOUFLAGE_GREEN,
                                   15,
                                   align="center",
                                   anchor_x="center",
                                   anchor_y="center"), SCREEN_WIDTH // 2,
                SCREEN_HEIGHT // 2 - 50)
Пример #26
0
    def on_draw(self):
        # Render the Screen
        arcade.start_render()
        if not self.game_over:
            arcade.draw_texture_rectangle(SCREEN_WIDTH // 2,
                                          SCREEN_HEIGHT // 2, SCREEN_WIDTH,
                                          SCREEN_HEIGHT, self.background)

            self.all_sprites_list.draw()

            if not self.started:
                show_tutorial = False
                output = f"Press Spacebar to start"
                self.score_text = arcade.create_text(output,
                                                     arcade.color.BLACK, 14)
                arcade.render_text(self.score_text, self.width // 2 - 100, 100)
            else:
                output = f"Player1: {self.world.player1.score}  Player2: {self.world.player2.score}"
                self.score_text = arcade.create_text(output,
                                                     arcade.color.BLACK, 14)
                arcade.render_text(self.score_text, self.width // 2 - 100, 100)

            arcade.draw_rectangle_filled(self.player1.x, self.player1.y, 20,
                                         self.player1.height, arcade.color.RED,
                                         0)
            arcade.draw_rectangle_filled(self.player2.x, self.player2.y, 20,
                                         self.player2.height,
                                         arcade.color.BLUE, 0)

        else:
            if self.world.player1.score == self.end_score:
                output = f"Player 1 WIN {self.world.player1.score}:{self.world.player2.score}"
            elif self.world.player2.score == self.end_score:
                output = f"Player 2 WIN {self.world.player1.score}:{self.world.player2.score}"
            self.score_text = arcade.create_text(output, arcade.color.WHITE,
                                                 60)
            arcade.render_text(self.score_text, self.width // 2 - 100, 100)
Пример #27
0
    def on_draw(self):
        arcade.start_render()

        # Draw all the sprites.
        self.effect_list.draw()
        self.chest_list.draw()
        self.arrow_list.draw()
        self.fireball_list.draw()
        self.wall_list.draw()
        self.player_sprite.draw()
        self.enemy_list.draw()
        self.potion_list.draw()
        self.coin_list.draw()
        self.ammo_list.draw()

        # If you get a high score change the text
        if self.highscore_sound:
            # Render the high-score text
            output = "High Score: " + str(self.highscore)
            if not self.highscore_text or self.highscore_text != output:
                self.highscore_text = arcade.create_text(
                    output, arcade.color.YELLOW, 14)

            arcade.render_text(self.highscore_text, self.view_left + 8,
                               self.view_bottom + 365)
        else:
            # Render the score text
            output = "Score: " + str(self.score) + " (" + str(
                self.highscore) + ")"
            if not self.score_text or self.score_text != output:
                self.score_text = arcade.create_text(output,
                                                     arcade.color.GREEN, 10)

            arcade.render_text(self.score_text, self.view_left + 8,
                               self.view_bottom + 365)

        if self.player_sprite.alive:
            # Render the arrow count text
            output = "Arrows: " + str(self.ammo)
            if not self.ammo_text or self.ammo_text != output:
                self.ammo_text = arcade.create_text(output, arcade.color.WHITE,
                                                    12)

            arcade.render_text(self.ammo_text, self.view_left + 8,
                               self.view_bottom + 8)

            # Draw Health bar
            x = self.player_sprite.center_x
            y = self.player_sprite.center_y
            arcade.draw_rectangle_filled(x, y - 16, 24, 4, (255, 0, 0))
            arcade.draw_rectangle_filled(
                x - math.ceil((24 - (self.health / 4.16)) / 2), y - 16,
                math.ceil(self.health / 4.16), 4, (0, 255, 0))

        # Death screen
        if not self.player_sprite.alive:
            arcade.draw_text("You died!", self.player_sprite.center_x - 125,
                             self.player_sprite.center_y, (200, 20, 20), 48)
            arcade.draw_text("Press R To Restart",
                             self.player_sprite.center_x - 125,
                             self.player_sprite.center_y - 125, (200, 20, 20),
                             24)

        # Instructions
        if not self.game_started:
            arcade.draw_texture_rectangle(self.player_sprite.center_x,
                                          self.player_sprite.center_y, 150,
                                          200, self.controls)
Пример #28
0
 def winner(self):
     self.busted = arcade.create_text("Busted!!!",arcade.color.BLACK,12)
     self.human_win = arcade.create_text("You win!!!",arcade.color.BLACK,12)
     self.bot_win = arcade.create_text("Dealer win!!!",arcade.color.BLACK,12)
     if self.world.human.busted:
         arcade.render_text(self.busted, 255, 290)
         arcade.render_text(self.bot_win, 240, 260)
     elif self.world.bot.busted:
         arcade.render_text(self.busted, 255, 290)
         arcade.render_text(self.human_win, 250, 260)
     elif self.world.human.end and self.world.bot.end:
         if self.world.human.score > self.world.bot.score:
             arcade.render_text(self.human_win, 250, 280)
         elif self.world.human.score < self.world.bot.score:
             arcade.render_text(self.bot_win, 240, 280)
         else:
             arcade.render_text(arcade.create_text("Tie!!!",arcade.color.BLACK,12),250,250)
     if self.world.human.busted or self.world.bot.busted or self.world.bot.end:
         arcade.render_text(arcade.create_text("Press <F1> to start new game :3",arcade.color.BLACK,12),170,230)
Пример #29
0
 def update_score(self):
     self.human_score_board = arcade.create_text("Score: " + str(self.world.human.score), arcade.color.BLACK, 12)
     self.bot_score_board = arcade.create_text("Score: " + str(self.world.bot.score), arcade.color.BLACK, 12)
     arcade.render_text(self.human_score_board, 50, 225)
     if self.world.human.end:
         arcade.render_text(self.bot_score_board, 50, 550)
Пример #30
0
    def on_draw(self):
        arcade.start_render()
        current_x = 20

        # First line
        current_y = SCREEN_HEIGHT - LINE_HEIGHT
        arcade.draw_text("Test Text", current_x, current_y, arcade.color.BLACK,
                         12)

        # Again to test caching
        current_y -= LINE_HEIGHT
        arcade.draw_text("Test Text", current_x, current_y, arcade.color.BLACK,
                         12)

        current_y -= LINE_HEIGHT
        arcade.draw_text("Test Text Anchor Left",
                         SCREEN_WIDTH // 2,
                         current_y,
                         arcade.color.BLACK,
                         12,
                         anchor_x="left")
        arcade.draw_point(SCREEN_WIDTH // 2, current_y, arcade.color.RED, 5)

        current_y -= LINE_HEIGHT
        arcade.draw_text("Test Text Anchor Center",
                         SCREEN_WIDTH // 2,
                         current_y,
                         arcade.color.BLACK,
                         12,
                         anchor_x="center")
        arcade.draw_point(SCREEN_WIDTH // 2, current_y, arcade.color.RED, 5)

        current_y -= LINE_HEIGHT
        arcade.draw_text("Test Text Anchor Right",
                         SCREEN_WIDTH // 2,
                         current_y,
                         arcade.color.BLACK,
                         12,
                         anchor_x="right")
        arcade.draw_point(SCREEN_WIDTH // 2, current_y, arcade.color.RED, 5)

        current_y -= LINE_HEIGHT
        arcade.draw_text("Test Text Anchor Top",
                         SCREEN_WIDTH // 2,
                         current_y,
                         arcade.color.BLACK,
                         12,
                         anchor_y="top")
        arcade.draw_point(SCREEN_WIDTH // 2, current_y, arcade.color.RED, 5)

        current_y -= LINE_HEIGHT
        arcade.draw_text("Test Text Anchor Center",
                         SCREEN_WIDTH // 2,
                         current_y,
                         arcade.color.BLACK,
                         12,
                         anchor_y="center")
        arcade.draw_point(SCREEN_WIDTH // 2, current_y, arcade.color.RED, 5)

        current_y -= LINE_HEIGHT
        arcade.draw_text("Test Text Anchor Bottom",
                         SCREEN_WIDTH // 2,
                         current_y,
                         arcade.color.BLACK,
                         12,
                         anchor_y="bottom")
        arcade.draw_point(SCREEN_WIDTH // 2, current_y, arcade.color.RED, 5)

        field_width = SCREEN_WIDTH
        current_y -= LINE_HEIGHT
        arcade.draw_text(f"Test Text Field Width {field_width}",
                         current_x,
                         current_y,
                         arcade.color.BLACK,
                         12,
                         font_name="arial",
                         width=field_width)

        current_y -= LINE_HEIGHT
        arcade.draw_text(f"Centered Test Text Field Width {field_width}",
                         current_x,
                         current_y,
                         arcade.color.BLACK,
                         12,
                         font_name="arial",
                         width=field_width,
                         align="center")

        current_y -= LINE_HEIGHT
        font_name = "comic"
        arcade.draw_text("Different font",
                         current_x,
                         current_y,
                         arcade.color.BLACK,
                         12,
                         font_name=font_name)

        current_y -= LINE_HEIGHT
        # noinspection PyDeprecation
        text = arcade.create_text("Create text", arcade.color.BLACK)
        # noinspection PyDeprecation
        arcade.render_text(text, current_x, current_y)