It might help if you know a bit about Python programming (or how to program in another
language besides Python) before you read through this book; however even if you haven’t you
can still read this book anyway. Programming isn’t nearly as hard as people think it is. If you ever
run into some
You don’t need to know how to use the Pygame library before reading this book. The next
Before we can begin programming you'll need to install software called the Python
The Python
Important Note!Be sure to install Python 3, and not Python 2. The programs in this book use Python 3, and you'll get errors if you try to run them with Python 2. It is so important, I am adding a cartoon penguin telling you to install Python 3 so that you do not miss this message:
(рис 1.1) "Be sure to install Python 3, not Python 2!", says the enguin. Otherwise the programs in this book won’t work
Double-click on the python-3.2.
Mac OS X 10.5 comes with Python 2.5.1
The installation for Mac OS X is similar to the Windows installation. Instead of downloading the
.
The Python website also has some additional information about using Python on a Mac at http://docs.python.org/dev/using/mac.html.
When you get to http://python.org, you should see a list of links on the left (such as "About", "News", "Documentation", "Download", and so on). Click on the Download link to go to the download page, then look for the file called "Python 3.2 Windows Installer (Windows binary -- does not include source)" and click on its link to download Python for Windows.
Double-click on the python-3.2.
Mac OS X 10.5 comes with Python 2.5.1
The installation for Mac OS X is similar to the Windows installation. Instead of downloading the
.
The Python website also has some additional information about using Python on a Mac at http://docs.python.org/dev/using/mac.html.
If your operating system is Ubuntu, you can install Python by opening a terminal window (from
the desktop click on Applications > Accessories > Terminal) and entering "sudo
You also need to install the IDLE software. From the terminal, type in "sudo
We will be using the IDLE software to type in our programs and run them. IDLE
If your operating system is Windows XP, you should be able to run Python by clicking the Start
button, then selecting Programs, Python 3.1, IDLE (Python GUI). For Windows Vista or
Windows 7, just click the Windows button in the lower left
If your operating system is Max OS X, start IDLE by opening the Finder window and click on Applications, then click Python 3.2, then click the IDLE icon.
If your operating system is Ubuntu or Linux, start IDLE by opening a terminal window and then type " idle3" and press Enter. You may also be able to click on Applications at the top of the screen, and then select Programming, then IDLE 3.
(рис 1.2) Python shell
The window that appears when you first run IDLE is called the interactive shell. A shell is a
program that lets you type instructions into the computer. The Python shell lets you type Python
instructions, and the shell sends these instructions to the Python
"Making Games with Python Pygame" is different from other programming books because it
focuses on the complete
In general, you should read these
Each
However, you can also download the
While you can just type in the code you read out of this book, you will need to download the graphics and sound files used by the games in this book from http://invpy.com/downloads. Make sure that these image and sound files are located in the same folder as the .py Python file otherwise your Python program will not be able to find these files.
When entering the
1. number = random.randint(1, 20)
2. spam = 42
3. print('Hello world!')
You do not need to type the "1." on the left side, or the space that immediately follows it. Just type it like this:
number = random.randint(1, 20)
spam = 42
print('Hello world!')
Those numbers are only used so that this book can refer to specific lines in the code. They are not a part of the actual program.
Aside from the line numbers, be sure to enter the code
For example in the code below, you can see that the second line is indented by four spaces because the four characters ("whil") on the line above are over the indented space. The third line is indented by another four spaces (the four characters, "if n" are above the third line's indented space):
while spam < 10:
if number == 42:
print('Hello')
Some lines of code are too long to fit on one line on the pages in this book, and the text of the code will wrap around to the next line. When you type these lines into the file editor, enter the code all on one line without pressing Enter.
You can tell when a new line starts by looking at the line numbers on the left side of the code. For example, the code below has only two lines of code, even though the first line wraps around:
1. print('This is the first line! xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxx’)
2. print('This is the second line, not the third line.')
Some of the programs in this book are a little long. Although it is very helpful to learn Python by
typing out the
You can copy and paste the text of your
Copying and pasting text is a very useful computer skill, especially for computer programming.
There is a video
The online diff tool is at this web page: http://invpy.com/diff/pygame. There is also a video
There is a lot that you can learn about programming. But you don’t need to learn all of it now. There are several times in this book where you might like to learn these additional details and explanations, but if I included them in this book then it would add many more pages. If this larger, heavier book accidentally fell on you the weight of these many additional pages would crush you, resulting in death. Instead, I have included "more info" links in this book that you can follow on this book’s website. You do not have to read this additional information to understand anything in this book, but it is there if you are curious. These (and other) links have been shortened and begin with http://invpy.com .
All of the information from these "more info" links can also be downloaded from http://invpy.com/pygamemoreinfo .
Even though this book is not dangerously heavy, please do not let it fall on you anyway.
Для получения официальных документов о завершении программы дополнительного профессионального образования (удостоверения о повышении квалификации, дипломов о профессиональной переподготовке и MBA) необходимо предоставить:
Внимание! Вы можете не заказывать доставку бумажной версии официального документы, а скачать его в электронном виде и распечатать самостоятельно. Информация о выданном документе в течение 1 месяца загружается в Федеральную информационную систему «Федеральный реестр сведений о документах об образовании и (или) о квалификации, документах об обучении» - ФИС ФРДО.
Доступ на новый сайт осуществляется с использованием адреса электронной почты, который был указан вами при регистрации на "старом". Мы постарались перенести все ваши данные с прежнего ресурса, однако не исключена вероятность потери части информации.
При возникновении проблемы со входом, воспользуйтесь функцией сброса пароля
Если вы обнаружите несоответствия, пожалуйста, сообщите нам.