# before the text
Yes, I am so ignorant and incompetent. I really have a pain in learning C++, so I simply make some entertainment measures. Yesterday I caught up with the jingdong book promotion event, so I stocked up a lot of books, and haven’t touched python for a long time. So play the whole thing! Today is the day to get started! Write your own little games to play!
Also, a book on cloud computing from China Machine Press. (Reason: Yesterday, JINGdong Books held an activity and stored up a lot of books. Go to your teacher today and confess that you want to do cloud computing. As a result, the teacher said that there was nothing to do with cloud computing and asked me to do data in the future. Too bad I didn’t toughen up. So the book you bought yesterday should be put out today, it’s not opened yet. Foreign place postage one person half (had better be my alumnus to buy. Wuhan area is also good. Provinces are really, ten yuan!! . The price is guaranteed to be no more than 40 (after all, I still save a lot on activities). Want message or private stamp, whether to see comments!
The body of the
Cut the crap! ~ Get down to business. I read the introduction to Python game programming book, written by foreigners, or pretty good. Jonathan Jonathan, oh, 666
Pygame 1.9 supports most versions of Py, so you can find it yourself. I was looking for 1.9.2 that was too far ahead of its time, and I’m too lazy to update the Python version of my Mac. Let’s keep 3.5.2. I’m too lazy to think about 2.x. I think the official focus will be on 3.x in the future. In the future, it may be abandoned. So it’s ok to keep the 3.x version stable. For PyGame, 1.9 seems to be standard for this book, so I won’t change it to avoid embarrassing myself with the new features! ~ The following experience:
On a MAC, the experience of installing Pip3 after installing Python is forgotten. I mean, a bunch of them. Jane’s books. The newer the better, but that doesn’t mean I can’t wait for something a little bit behind. People write books on 3.2, so 3.5 is fine. Advanced version compatible with original version not. Here’s where I found pyGame to download. The author also used 1.9, but assumed it would be 1.9.1 at the time, so it was just 1.9. Let’s go ahead and make 1.9.2, which can be downloaded here:
Pypi.python.org/pypi/Pygame…
Then there’s installation. Pip3 Install PyGame pip3 Install PyGame But what the hell happened was this:
src/scrap.c:27:10: fatal error: 'SDL.h' file not found #include "SDL.h"Copy the code
Annoyed!! I can’t stand it. Be decisive ~ ~ change the way. Then discover the method of this article. Download PyGame and then install it. Well, some places are:
PIP install pygame 1.9.2 - cp35 - cp35m - macosx_10_9_intel. WHLCopy the code
But pips also come in twos and threes, so let’s go with the following:
Pip3 install pygame 1.9.2 - cp35 - cp35m - macosx_10_9_intel. WHLCopy the code
Then run found that the installation is good, simple and quick, beautiful ah!! You can also view your own version of PY.
If you’re new to your MAC and Python3 is still the default old version, go to the official website and install the new version. It seems to automatically replace the old version. (It doesn’t matter if you can’t. There are so many ways to do that. A few orders of business!
Some people say that the MAC version is 64-bit and not compatible with PyGame’s 32-bit version, but I don’t think it’s that silly. Knowing that the MAC version is 64-bit by default, I’m still developing 32-bit software and asking you to reinstall it. Mine is 64-bit Python, but installing PyGame feels pretty good.
As for how to determine how many bits your Python is.
Eight would be fine. This is I stole a CSDN blog ~~ hey you are welcome to borrow the next ~
~ ~ ~ ~ ~ ~ ~ fill it, too lazy to open a new article ~ ~ ~ ~ ~
import pygame,sys # import the moudle of pygame
from pygame.locals import *
white=255.255.255 #set the white' RGB
blue = 1.1.200
pygame.init() # start the pygame
screen = pygame.display.set_mode((600.500)) #set the background of the game
myfont = pygame.font.Font(None.60) # define the font of a word
textImage = myfont.render("Hello Pygame".True,white) # define the word with the font and content,the "True" means something but I forgot it, if you are interesting you can ask me .
while True: #the loop for the screen estable instead of a picture
for event in pygame.event.get(): # this loop is waiting for the keyboard event
if event.type in (QUIT,KEYDOWN):
sys.exit()
screen.fill(blue) // fill thee screen with blue color
screen.blit(textImage,(100.100)) // clear the screen
pygame.display.update() //always update the screenCopy the code
Wow by Pygame, so cute!!
After the body
Ok finished, continue to play PY game ~ want to play can communicate ah. Of course, it would be great if someone took my books.