Set the Background Color

Games have colors, including a background color. Arcade makes it really easy to set the background color, so let’s do so.

Code

import arcade

if __name__ == '__main__':
    arcade.open_window(600, 600, 'Coin Game')
    arcade.set_background_color(arcade.color.WHEAT)
    arcade.run()

Analysis

  • We changed the title of our window
  • We added a call to set_background_color
  • Names such as WHEAT are called constants. In Python, constants are noted with all caps.
  • Arcade’s names for colors are really just RGB tuples
  • Running this does not yet change the background color

Exercises

  1. Use Ctrl-B to navigate to the definition of WHEAT and tell its RGB value.

Quiz

  1. What is a tuple?
  2. Can you change a value in a tuple?
  3. How can you tell that a variable is intended to be used as a constant?
  4. In Python, can you change the value of a constant?
  5. Why doesn’t the background color change?