示例#1
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)
示例#2
0
 def load_figure_names(self):
     self.figure_names.append(
         arcade.create_text("1: Rumba Box", arcade.color.BLACK, 14))
     self.figure_names.append(
         arcade.create_text("2: Alternative Basic", arcade.color.BLACK, 14))
     self.figure_names.append(
         arcade.create_text("3: Cuban Walk", arcade.color.BLACK, 14))
示例#3
0
 def load_figure_names(self):
     self.figure_names.append(
         arcade.create_text("1: Left Box Turn", arcade.color.BLACK, 14))
     self.figure_names.append(
         arcade.create_text("2. Right Box Turn", arcade.color.BLACK, 14))
     self.figure_names.append(
         arcade.create_text("3: Change Step", arcade.color.BLACK, 14))
     self.figure_names.append(
         arcade.create_text("4: Six-count Underarm Turn",
                            arcade.color.BLACK, 14))
示例#4
0
 def update(self):
     self.score_num = arcade.create_text(str(self.map.score),
                                         arcade.color.BLACK, 50)
     self.bonus_num = arcade.create_text(str(self.map.bonus),
                                         arcade.color.BLACK, 50)
     self.total_num = arcade.create_text(
         str(self.map.score + self.map.bonus), arcade.color.BLACK, 50)
     if self.map.score + self.map.bonus < 1:
         self.show = Lose_sprite()
     else:
         self.show = Win_sprite()
     if 822 < self.mouse.x and self.mouse.x < 1090 and 150 < self.mouse.y and self.mouse.y < 227 and self.mouse.click:
         self.status = "change"
示例#5
0
    def __init__(self):
        """
        The constructor builds the first menu to select the dance type.
        Various strings to support the menu system are also created
        """

        # the current_state variable holds which menu is being displayed
        self.current_state = MenuState.SELECT_DANCE
        self.dance_menu = []
        self.dance_menu.append(Waltz.Waltz())
        self.dance_menu.append(Tango.Tango())
        self.dance_menu.append(Foxtrot.Foxtrot())
        self.dance_menu.append(ChaCha.ChaCha())
        self.dance_menu.append(Rumba.Rumba())
        self.dance_menu.append(EastCoastSwing.East_Coast_Swing())
        # more dances go here

        # the current_dance variable holds which dance was selected
        self.current_dance = None

        self.dance_prompt = arcade.create_text("SELECT A DANCE",
                                               arcade.color.BLACK,
                                               24,
                                               bold=True)
        self.song_prompt = arcade.create_text("Select a song",
                                              arcade.color.BLACK,
                                              14,
                                              bold=True,
                                              italic=True)
        self.routine_prompt = arcade.create_text("Create a routine",
                                                 arcade.color.BLACK,
                                                 14,
                                                 bold=True,
                                                 italic=True)
        self.avail_prompt = arcade.create_text("Available Figures",
                                               arcade.color.BLACK,
                                               14,
                                               bold=True,
                                               italic=True)
        self.current_prompt = arcade.create_text("Currently Dancing",
                                                 arcade.color.BLACK,
                                                 14,
                                                 bold=True,
                                                 italic=True)
        self.done_prompt = arcade.create_text("0: Stop adding figures",
                                              arcade.color.BLACK, 14)
        self.silent_prompt = arcade.create_text("0: No music",
                                                arcade.color.BLACK, 14)
        self.start_prompt = arcade.create_text("Press space bar to start",
                                               arcade.color.BLACK, 14)
        self.customize_prompt = arcade.create_text("Customize Figure",
                                                   arcade.color.BLACK,
                                                   14,
                                                   bold=True,
                                                   italic=True)
示例#6
0
 def update(self):
     self.shoothill_S.update()
     for hill in self.mapRandom_S:
         hill.update()
     for box in self.mapFixBox_S:
         box.update()
     for animal in self.animal_S:
         animal.update()
         if animal.model.isHit(self.fruit):
             if animal.model.tag == "dragon":
                 self.score += 90
             else:
                 self.score += 50
             if animal.model.tag == "dragon" and self.fruit.tag == "meat":
                 self.bonus += 10
             elif animal.model.tag == "monkey" and self.fruit.tag == "banana":
                 self.bonus += 10
             elif animal.model.tag == "worm" and self.fruit.tag == "grape":
                 self.bonus += 10
             self.animal_C.remove(animal.model)
             self.animal_S.remove(animal)
             self.world.fruit_C = self.world.random_fruit()
             self.world.fruit_S = self.world.Get_sprite(self.world.fruit_C)
             self.fruit = self.world.fruit_C
             self.world.mouse.reset_mouse()
     if self.shoothill_C.isHit(self.fruit):
         self.world.fruit_C = self.world.random_fruit()
         self.world.fruit_S = self.world.Get_sprite(self.world.fruit_C)
         self.fruit = self.world.fruit_C
         self.world.mouse.reset_mouse()
         self.score -= 10
     for box in self.mapRandom_C:
         if box.isHit(self.fruit):
             self.world.fruit_C = self.world.random_fruit()
             self.world.fruit_S = self.world.Get_sprite(self.world.fruit_C)
             self.fruit = self.world.fruit_C
             self.world.mouse.reset_mouse()
             self.score -= 10
     for box in self.mapFixBox_C:
         if box.isHit(self.fruit):
             self.world.fruit_C = self.world.random_fruit()
             self.world.fruit_S = self.world.Get_sprite(self.world.fruit_C)
             self.fruit = self.world.fruit_C
             self.world.mouse.reset_mouse()
             self.score -= 10
     self.score_text = arcade.create_text("Score : " + str(self.score),
                                          arcade.color.BLACK, 50)
     self.bonus_text = arcade.create_text("Bonus : " + str(self.bonus),
                                          arcade.color.BLACK, 50)
示例#7
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)
示例#8
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)
示例#9
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)
示例#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 __init__(self, width, height):
        super().__init__(width, height)
        self.time = 0

        arcade.set_background_color(arcade.color.AERO_BLUE)

        self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)
        #self.stupid_sprite = ModelSprite('images/stupidchar.png',model=self.world.stupid)

        self.coin_sprite = ModelSprite('images/brand.png',
                                       model=self.world.coin)
        self.obstacleL_sprite = ModelSprite('images/weed.png',
                                            model=self.world.obstacleLeft)
        self.obstacleR_sprite = ModelSprite('images/weed.png',
                                            model=self.world.obstacleRight)
        self.endd = arcade.create_text("GAME OVER", arcade.color.BLACK, 30)
        self.cloud1_sprite = ModelSprite('images/cloud3.png',
                                         model=self.world.cloud1)
        self.cloud2_sprite = ModelSprite('images/cloud3.png',
                                         model=self.world.cloud2)
        self.cloud3_sprite = ModelSprite('images/cloud3.png',
                                         model=self.world.cloud3)
        self.cloud4_sprite = ModelSprite('images/cloud3.png',
                                         model=self.world.cloud4)
        self.cloud5_sprite = ModelSprite('images/cloud3.png',
                                         model=self.world.cloud5)
        self.house_sprite = ModelSprite('images/building.png',
                                        model=self.world.house)
示例#12
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])
示例#13
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)
示例#14
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)
示例#15
0
    def __init__(self, main, width: int, height: int):
        self.width = width
        self.height = height

        self.main = main

        self.texts = [
            "Welcome to TTD! TTD is a game about\n"
            "treating as many patients as possible in your local clinic\n"
            f"Every day, you have enough resources to treat "
            f"{int(constants.BUDGET / constants.TREATMENT_COST)} patients\n"
            f"However, you have {constants.PATIENTS_PER_DAY} patients per day",
            f"You start with a budget of R{constants.BUDGET} per day",
            "There are 2 possible actions:\n"
            "Treat    --   Diagnose",
            f"Treating takes the biggest amount of money, R{constants.TREATMENT_COST}\n"
            f"Since you have R{constants.BUDGET}, you can treat "
            f"{int(constants.BUDGET / constants.TREATMENT_COST)} patients.\n"
            "Treating a patient will cure them of their ailments.\n"
            "Triaging is the act of choosing which order you will treat your patients.\n"
            "However, if you do not treat a patient soon enough, then they may die!",
            "You have been assigned by the Department of Health\n"
            "to a local clinic in the North-West Province. The situation is bad here,\n"
            f"so you can expect to get roughly {constants.PATIENTS_PER_DAY} patients per day. You can only treat\n"
            f"{int(constants.BUDGET / constants.TREATMENT_COST)} patients per day. Choose wisely!"
        ]

        self.text_index = 0
        self.text = arcade.create_text(self.texts[self.text_index],
                                       arcade.color.BLACK,
                                       15,
                                       align="center",
                                       anchor_x="center",
                                       anchor_y="center")
        self.text_shown = 0
示例#16
0
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.all_sprites_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()

        # Set up the player
        self.player_sprite = arcade.Sprite("images/female_idle.png",
                                           SPRITE_SCALING)

        # Starting position of the player
        self.player_sprite.center_x = 64
        self.player_sprite.center_y = 270
        self.all_sprites_list.append(self.player_sprite)

        # Get a 2D array made of numbers based on the map
        map_array = get_map("MyTiledMap.csv")

        for row_index, row in enumerate(map_array):
            for column_index, item in enumerate(row):

                # For this map, the numbers represent:
                # -1 = empty
                # 0  = box
                # 1  = grass left edge
                # 2  = grass middle
                # 3  = grass right edge
                if item == -1:
                    continue
                elif item == 0:
                    wall = arcade.Sprite("images/boxCrate_double.png", SPRITE_SCALING)
                elif item == 1:
                    wall = arcade.Sprite("images/grassLeft.png", SPRITE_SCALING)
                elif item == 2:
                    wall = arcade.Sprite("images/grassMid.png", SPRITE_SCALING)
                elif item == 3:
                    wall = arcade.Sprite("images/grassRight.png", SPRITE_SCALING)

                wall.right = column_index * 64
                wall.top = (7 - row_index) * 64
                self.all_sprites_list.append(wall)
                self.wall_list.append(wall)

        self.physics_engine = \
            arcade.PhysicsEnginePlatformer(self.player_sprite,
                                           self.wall_list,
                                           gravity_constant=GRAVITY)

        # Set the background color
        arcade.set_background_color(arcade.color.AMAZON)

        # Set the view port boundaries
        # These numbers set where we have 'scrolled' to.
        self.view_left = 0
        self.view_bottom = 0

        self.game_over = False
        self.game_over_text = arcade.create_text("Game Over", arcade.color.WHITE, 30)
        self.distance_text = None
示例#17
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)
示例#18
0
 def __init__(self, name):
     """ Initialize the base class with the name of the figure."""
     self.leader_steps = []     # start with empty list of steps
     self.follower_steps = []
     # the figure name can be rendered and displayed on the screen
     self.name = arcade.create_text(name, arcade.color.BLACK, 14)
     # Figures can be customized from a menu of options
     self.menu_items = []      # start with an empty list of options
     self.customization_needed = False  # indicate if more customization is needed
示例#19
0
 def update(self, delta):
     if self.alive:
         self.sink()
         self.unsink()
         self.sprite.center_x = self.x
         self.sprite.center_y = self.y
         self.sprite.update()
         self.text_obj = arcade.create_text(self.text,
             arcade.color.BLACK, 14, width=50, align="center", anchor_x="center", anchor_y="bottom")
示例#20
0
 def __init__(self, index, filename, bpm, seek=0):
     """ Constructor. The index is a number used in creating the menu entry."""
     self.filename = filename
     self.bpm = bpm
     self.seek = seek
     self.menu_entry = self.build_menu_entry(index, self.filename)
     self.menu_text = arcade.create_text(self.menu_entry,
                                         arcade.color.BLACK, 14)
     self.audio_stream = None
     self.player = None
示例#21
0
    def __init__(self, width, height):
        super().__init__(width, height, title="RPS_Puzzles")
        self.background = arcade.load_texture("images/bg1.jpg")
        self.check = check_win_lost(self)
        self.x = self.check.x
        self.score = 0
        self.score_text = None
        self.time = 20.0
        self.time_text = None
        self.game_state = 1

        #### CHOICE ####
        self.rock = arcade.Sprite('images/rock.png')
        self.rock.set_position(100, 100)
        self.text_A = arcade.create_text("A", arcade.color.BLACK, 15)

        self.paper = arcade.Sprite('images/paper.png')
        self.paper.set_position(210, 100)
        self.text_S = arcade.create_text("S", arcade.color.BLACK, 15)

        self.scissor = arcade.Sprite('images/scissor.png')
        self.scissor.set_position(300, 100)
        self.text_D = arcade.create_text("D", arcade.color.BLACK, 15)

        #### RED ####
        self.rock_red = arcade.Sprite('images/rock red.png')
        self.rock_red.set_position(200, 300)

        self.paper_red = arcade.Sprite('images/paper red.png')
        self.paper_red.set_position(200, 300)

        self.scissor_red = arcade.Sprite('images/scissor red.png')
        self.scissor_red.set_position(200, 300)

        #### BLUE ####
        self.rock_blue = arcade.Sprite('images/rock blue.png')
        self.rock_blue.set_position(200, 300)

        self.paper_blue = arcade.Sprite('images/paper blue.png')
        self.paper_blue.set_position(200, 300)

        self.scissor_blue = arcade.Sprite('images/scissor blue.png')
        self.scissor_blue.set_position(200, 300)
示例#22
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)
    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)
示例#24
0
 def update(self, delta):
     print("Text updating.")
     if self.shown:
         self.duration -= delta
         if self.duration < 0:
             self.shown = False
     if not self.shown:
         self.text = ''
         self.duration = 0
     self.text_obj = arcade.create_text(self.text, arcade.color.BLACK, 20, width=600, align="center")
示例#25
0
    def on_draw(self):
        """
        Render the screen.
        """

        # This command should happen before we start drawing. It will clear
        # the screen to the background color, and erase what we drew last frame.
        arcade.start_render()

        # start_x and start_y make the start point for the text. We draw a dot to make it easy too see
        # the text in relation to its start x and y.
        start_x = 50
        start_y = 450
        arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5)
        cache = False

        arcade.render_text(self.t1, start_x, start_y)

        arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5)
        start_x = 50
        start_y = 400
        arcade.render_text(self.t2, start_x, start_y)

        start_y = 350
        arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5)
        arcade.render_text(self.t3, start_x, start_y)

        start_y = 450
        start_x = 300
        arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5)
        arcade.render_text(self.t4, start_x, start_y)


        start_y = 250
        start_x = 300
        arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5)
        arcade.render_text(self.t5, start_x, start_y)

        start_y = 150
        start_x = 300
        arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5)
        arcade.render_text(self.t6, start_x, start_y, rotation=self.text_angle)

        start_y = 150
        start_x = 20
        arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5)
        arcade.render_text(self.t7, start_x, start_y, rotation=90.0)

        start_y = 20
        start_x = 50
        arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5)
        text = "Time elapsed: {:5.1f}".format(self.time_elapsed)
        if text != self.t8.text:
            self.t8 = arcade.create_text(text, arcade.color.BLACK, 14)
        arcade.render_text(self.t8, start_x, start_y)
示例#26
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)
示例#27
0
文件: patients.py 项目: Restioson/TTD
    def patients_text(self):

        string = "Patients:\n"
        num = 0

        for patient in self.patients_order:

            num += 1
            string += f"{num}. {patient.name}: {patient.survival_chance}% survival\n"

        return arcade.create_text(string, arcade.color.BLACK)
示例#28
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()
示例#29
0
    def __init__(self, width, height):
        super().__init__(width, height, title="Drawing Text Example")

        arcade.set_background_color(arcade.color.WHITE)
        self.text_angle = 0
        self.time_elapsed = 0
        self.t1 = arcade.create_text("Simple line of text in 12 point", arcade.color.BLACK, 12)
        self.t2 = arcade.create_text("Text anchored 'top' and 'left'.", arcade.color.BLACK, 12, anchor_x="left", anchor_y="top")
        self.t3 = arcade.create_text("14 point multi\nline\ntext", arcade.color.BLACK, 14, anchor_y="top")
        self.t4 = arcade.create_text("Set of text\nthat\nis centered.", arcade.color.BLACK, 14, width=200, align="center", anchor_y="top")
        self.t5 = arcade.create_text("Text centered on\na point", arcade.color.BLACK, 14, width=200, align="center", anchor_x="center", anchor_y="center")
        self.t6 = arcade.create_text("Text rotated on\na point", arcade.color.BLACK, 14, width=200, align="center", anchor_x="center", anchor_y="center")
        self.t7 = arcade.create_text("Sideways text", arcade.color.BLACK, 14, width=200, align="center", anchor_x="center", anchor_y="center")
        self.t8 = arcade.create_text("Time elapsed: {:5.1f}".format(self.time_elapsed), arcade.color.BLACK, 14)
示例#30
0
文件: patients.py 项目: Restioson/TTD
    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)