失效链接处理 |
Invent Your Own Computer Games with Python 2nd PDF 下载
本站整理下载:
提取码:fbxk
相关截图:
主要内容:
Hello! This is a book that will teach you how to program by showing you how to create
computer games. Once you learn how the games in this book work, you'll be able to create
your own games. All you'll need is a computer, some software called the Python
Interpreter, and this book. The software you'll need is free and you can download it from
the Internet.
When I was a kid, I found a book like this that taught me how to write my first programs
and games. It was fun and easy. Now as an adult, I still have fun programming computers,
and I get paid for it. But even if you don't become a computer programmer when you grow
up, programming is a useful and fun skill to have.
Computers are very useful machines. The good news is that learning to program a
computer is easy. If you can read this book, you can program a computer. A computer
program is just a bunch of instructions run by a computer, just like a storybook is just a
whole bunch of sentences read by the reader.
These instructions are like the turn-by-turn instructions you might get for walking to a
friend's house. (Turn left at the light, walk two blocks, keep walking until you find the first
blue house on the right.) The computer follows each instruction that you give it in the order
that you give it. Video games are themselves nothing but computer programs. (And very
2
fun computer programs!)
In this book, any words you need to know will look like this. For example, the word
"program" is defined in the previous paragraph.
In order to tell a computer what you want it to do, you write a program in a language that
the computer understands. The programming language this book teaches is named Python.
There are many different programming languages including BASIC, Java, Python, Pascal,
Haskell, and C++ (pronounced, "c plus plus").
When I was a kid most people learned to program in BASIC as their first language. But
new programming languages have been invented since then, including Python. Python is
even easier to learn than BASIC and it's a serious programming language used by
professional computer programmers. Many adults use Python in their work (and when
programming just for fun).
The first few games we'll create together in this book will probably seem simple
compared to the games you've played on the Xbox, Playstation, or Wii. They don't have
fancy graphics or music but that's because they're meant to teach you the basics. They're
purposely simple so that we can focus on learning to program. Games don't have to be
complicated to be fun. Hangman, Tic Tac Toe, and making secret codes are simple to
program but are also fun.
We'll also learn how to make the computer solve some math problems in the Python
shell. (Don't worry if you don't know a lot of mathematics. If you know how to add and
multiply, you know enough math to do programming. Programming is more about problem
solving in general than it is about solving math problems.)
Downloading and Installing Python
Before we can begin programming you'll need to install the Python software; specifically
the Python interpreter. (You may need to ask an adult for help here.) The interpreter is a
program that understands the instructions that you'll write in the Python language. Without
the interpreter, your computer won't understand these instructions and your programs won't
work. (We'll just refer to "the Python interpreter" as "Python" from now on.)
Because we'll be writing our games in the Python language, we need to download Python
first, from the official website of the Python programming language,
http://www.python.org
I'm going to give you instructions for installing Python on Microsoft Windows, not
because that's my favorite operating system but because chances are that's the operating
system that your computer is running. You might want the help of someone else to
download and install the Python software.
When you get to python.org, you should see a list of links on the left (About, News,
Documentation, Download, and so on.) Click on the Download link to go to the download
3
1 - Installing Python
page, then look for the file called Python 3.1 Windows Installer (Windows binary --
does not include source) and click on its link to download Python for Windows.
Figure 1-1: Click the Windows installer link to download Python for Windows from http://www.python.org
Double-click on the python-3.1.msi file that you've just downloaded to start the Python
installer. (If it doesn't start, try right-clicking the file and choosing Install.) Once the
installer starts up, click the Next button and just accept the choices in the installer as you go
(no need to make any changes). When the install is finished, click Finish.
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.
The installation for Mac OS is similar. Instead of downloading the .msi file from the
Python website, download the .dmg Mac Installer Disk Image file instead. The link to this
file will look something like "Mac Installer disk image (3.1.1)" on the "Download Python
Software" web page.
If your operating system is Ubuntu, you can install Python by opening a terminal
window (click on Applications > Accessories > Terminal) and entering sudo apt-get
install python3 then pressing Enter. You will need to enter the root password to
install Python, so ask the person who owns the computer to type in this password.
There may be a newer version of Python available than 3.1. If so, then just download the
latest version. The game programs in this book will work just the same. If you have any
problems, you can always Google for "installing Python on <your operating system's
name>". Python is a very popular language, so you should have no difficulty finding help.
A video tutorial of how to install Python is available from this book's website at
http://inventwithpython.com/videos/.
|