Setting Up the Project
This project is going to be run off of MacOS X. I will be using the package manager Homebrew.. Homebrew helps make sure everything is the correct version, and all apps are installed. It is likely that if you are following this blog post you are familiar with Homebrew, but if not the simple install is as follows:Open up your terminal of choice (I use the given terminal) and execute the following command
Next, in order to make sure everything is fine with Homebrew it's best to run
$/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Now we can get to work on downloading everything necessary!
First up, Python (3)!
A quick way to verify that everything is looking good is to use
$brew install python3
which should spit out something like:
Next, we have a handful of dependencies we have to make sure are installed in order to use Pygame.
Lastly, on top of our package manager for Mac, we will be using a package manager for Python, Pip(3)! luckily, Homebrew installs the correct
version of pip when you install python. All you have to do to install pygame is the following command:
$brew install mercurial
$brew install sdl sdl_image sdl_mixer sdl_ttf portmidi
$brew tap homebrew/headonly
$brew install smpeg
Note: the latest version of PyGame did not work for me. I had to use the command
$pip3 install pygame
$pip3 install pygame=2.0.0.dev3
The quickest way to check if everything so far has been done correctly is to execute the following command:
If your output looks similar to the following, PyGame and Python were sucessfully installed.
$python -c "import pygame"
Finally, to play a game using PyGame, we will use one of the prebuilt modules.
pygame 2.0.0.dev3 (SDL 2.0.9, python 3.7.6)
Hello from the pygame community. https://www.pygame.ord/contribute.html
$python3 -m pygame.examples.aliens