First Function

Put our action in a function and actually draw something on the screen.

Code

import arcade


def main():
    arcade.open_window(600, 600, 'Coin Game')
    arcade.set_background_color(arcade.color.WHEAT)
    arcade.start_render()
    arcade.draw_text('Drawing Example', 200, 300, arcade.color.BLACK, 12)
    arcade.finish_render()
    arcade.run()


if __name__ == '__main__':
    main()

Analysis

  • In Python, it is common to put the work to get your application running, inside a function named ‘main’
  • We move our arcade game into a function ‘main’
  • Then, we call our function ‘main’
  • We used Arcade’s draw_text function to get something on the screen

Exercises

  1. Use a different function name than main.
  2. Draw more text on the screen, in different places.
  3. Find the other arguments you can pass to draw_text.
  4. Use autocomplete to find other Arcade functions starting with draw_.

Quiz

  1. How can we find out which arguments draw_text takes?