Bought a book, but the book is too pit not the correct method of installation, so I can only my own officer net dead Chew English. The software was downloaded and suddenly realized why I didn't search videos and blogs. Here are some ways to explore yourself.Official portal
Python official website: https://www.python.org/
Pygame Official website: http://pygame.org/news (I do not know why this website always bring a news, I think this is a
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
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
This article gives an example of how Pygame plays music. Share to everyone for your reference. Specifically as follows:
Method One:
?
1 2 3 4
Import pygame filename= '/home/a.mp3 ' pygame.mixer.music.load (filename) pygame.mixer.music.play (loops=0, start=0.0)
Method Two:
?
1 2 3 4 5
Import pygame filename= '/home/pe
This article describes how Python uses Pygame to play MIDI and MP3 files. Share to everyone for your reference. The implementation method is as follows:
"' Pg_midi_sound101.py play MIDI Music files (also mp3 files) using Pygame tested with python273/331 and pygame192 by ve
Gaseat ' Import Pygame as pg Def play_music (music_file): ' Stream music with Mixe
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
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
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.