""" Example showing how to draw text to the screen. If Python and Arcade are installed, this example can be run from the command line with: python -m arcade.examples.text_loc_example_start """ import arcade import os # Set the working directory (where we expect to find files) to the same # directory this .py file is in. You can leave this out of your own # code, but it is needed to easily run the examples using "python -m" # as mentioned at the top of this program. file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) SCREEN_WIDTH = 500 SCREEN_HEIGHT = 500 SCREEN_TITLE = "Localizing Text Example" class MyGame(arcade.Window): """ Main application class. """ def __init__(self, width, height, title): super().__init__(width, height, title) arcade.set_background_color(arcade.color.WHITE) self.text_angle = 0 self.time_elapsed = 0.0 def update(self, delta_time): self.text_angle += 1 self.time_elapsed += delta_time 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) arcade.draw_text( "Simple line of text in 12 point", start_x, start_y, arcade.color.BLACK, 12 ) def main(): MyGame(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) arcade.run() if __name__ == "__main__": main()