After you have identified your Python version, you can proceed to the following steps:
1. Enter the official website http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame Download the corresponding version of the Pygame, pay attention to distinguish between 32 bits and 64 bits.
Here wheel is a compression format that is easy to install in Python.
2. Install pip into cmd mode
Win+r (or enter CMD in th
This section implements a small ball program that moves freely in the window. It provides detailed comments and does not need to be explained.
Code:
[Python]#-*-Coding: UTF-8 -*-Import sysImport pygameFrom pygame. locals import *Def play_ball ():Pygame. init ()# Window sizeWindows size = (width, height) = (700,500)# Offset of the ball running [horizontal, vertical]. The larger the value, the faster the move
Then the last time to continue. A simple drawing function Pygame provides us with a few simple drawing functions, such as drawing rectangles, circles, ellipses, lines, and independent pixel points. The following program implements some simple drawing operations. Import Pygame, Sysfrom pygame.locals import *pygame.init () Displaysurf = Pygame.display.set_mode ((500,400), 0,32) BLACK = (0, 0, 0) White = (25
This series of blogs introduces the development of mini-games in the Python+pygame library. There is the wrong point of writing and hope you haihan.Until now we have learned a lot of pygame basic knowledge, starting from this blog we will learn the Pygame in the advanced part, more and the wizard module, conflict detection related knowledge.One, Sprite module, Sp
How to play music in pygame
This article describes how to play music in pygame. Share it with you for your reference. The details are as follows:
Method 1:
?
1 2 3 4
Import pygame Filename = '/home/A.mp3' Pygame. mixer. music. load (filename) Pygame.
Keys=pygame.key.get_pressed (), accept all keystrokes currently pressed in the game, and save them as a list, placed in the keys variablePygame. K_w tells Pygame you are checking the W key, by modifying the last letter, you can change it to any button you want to check.Import Pygamepygame.init () size=[400,300]screen=pygame.display.set_mode (size) clock=pygame.time.clock () done= Falsewhile not done:keys=pygame.key.get_pressed () if Keys[
Pygame.mixer is a module for handling sounds, meaning "mixer". In the game, the sound processing generally includes making the sound and playing the sound two parts, here only learns to play the sound part.
1, Pygame.mixer Startup and initialization
Pygame.mixer.init (): Initialization of the mixer. In a program, when used, it is generally placed in the first few lines of code:
Copy Code code as follows:
Import Pygame
Pygame.init ()
Pygame in common Python modules (Manual: home page), pythonpygame
Pygame manual Official Website:Http://www.pygame.org/docs/
Pygame Homepage
Instructions:
Self-Report
The basic information about Pygame, what is it, who participates in it, and where to find it.
Install
The steps required to comp
I used Python to write games. Getting started with pygame (5): Object-oriented game design, pythonpygame
There was a Moving bullet in yesterday's content. Although we only added one bullet, you can see that we need to record the x and y coordinates of the bullet and update its coordinates each time. If we want to have multiple bullets, We need to store multiple coordinates. At that time, the processing was not so simple. Maybe we can use two lists, on
The Pygame.mixer is a module for handling sound, meaning "mixer". The processing of sound in the game typically involves making sounds and playing sounds, where only the sound portion of the play is learned.
1. Pygame.mixer Startup and initialization
Pygame.mixer.init (): Initialization of the mixer. program, when used, is generally placed in the first few lines of code:
The code is as follows:
Import PygamePygame.init ()Pygame.mixer.init ()
2. Play sound clip wav fileWhen you play a sound cli
Simple pie game, mastering the Pygame of lines and arcs, as well as the response to input.1 ImportMath2 Importpygame, sys3 fromPygame.localsImport*4 Pygame.init ()5Screen = Pygame.display.set_mode ((600, 500))6Pygame.display.set_caption ("The Pie Game--Press 1 2 3 4")7MyFont = Pygame.font.Font (None, 60)8 9color = 200, 80, 60Tenwidth = 5 Onex = 300 Ay = 250 -RADIUS = 200 -Position = X-radius, Y-radius, radius*2, radius*2 the -Piece1 =False -Piece2 =
1. This machine is python3.6 environment2. To the Pygame website to download the corresponding system, corresponding to the Python version of the Pygame file,:https://pypi.python.org/pypi/pygame/1.9.3, Must download "PYGAME-1.9.3-CP36-CP36M-WIN_AMD64.WHL (4.2 MB) Copy SHA256 hashSHA256"Note: since my python3.6 is 32
Python Based on pygame to achieve the ball effect (with the source code), pythonpygame
This article describes how to use pygame to create a ball. We will share this with you for your reference. The details are as follows:
Running effect:
The Code is as follows:
# A bouncing ballimport sys, pygame _ author _ = {'name': 'hongten ', 'mail': 'hongtenzone @ fo
After learning so long pygame, always want to write a game of combat. It looks like a very simple game, how hard it is to write it. Originally wanted to write a Tetris, think for a long time how to achieve, think about it, also did not write out, so simply download someone else's code to read. Later, to write a help to remember the treasure box of the game, the result is not completed. The only completed is the following this little villain to pick up
First download the good file:Pygame Download URL: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygameFind PYGAME-1.9.2B8-CP36-CP36M-WIN_AMD64.WHLCMD in file path, input: python-m pip install--user PYGAME-1.9.2B8-CP36-CP36M-WIN_AMD64.WHLNormally, the installation will be successful.But when I install this, the total prompt, error: * * is not a supported wheel in this platformWorkaround:Win+r Enter cmd, enter P
Automatic tracking algorithm, in our design of 2D shooting games often used, this sounds very tall things, in fact, is not a military science patent, in mathematics to solve the words need to resolve the differential equation,It's hard to work out a mathematical basis. But we have a computer is not the same, relying on the computer very fast computing speed, we use the idea of differentiation, coupled with a simple triangular knowledge, we can achieve it.Well, don't say much, let's look at its a
Python pygame module usage example, pythonpygame
The example in this article describes the usage of the pygame module in python and shares it with you for your reference. The specific method is as follows:
import pygame, sys from pygame.locals import * #set up pygame pygame.init() windowSurface = pygame.display.set_m
This example describes Python's approach to responding to events in the game based on the Pygame implementation. Share to everyone for your reference, as follows:
Let's look at the demo effect I've done:
When the player presses on the keyboard: up, down, left, right button, the background will print out the number of keys that the player presses, and the graphic will move with it
This is the phenomenon that exists objectively above.
So what is an ev
Python pygame Installation notes, pythonpygame
Today I saw a tutorial about installing the pygame module in Python. I think it's good. Let's share it with you.
Install Python
Well, this question seems redundant here. But in order to take care of the children's shoes I just learned Python, I should say a few more words.
The details are as follows:
Go to the Python official website. Download the required ver
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.