Reprint Please note: @ small Wuyi http://www.cnblogs.com/xiaowuyi
Pygame. mixer is a module used to process sound and its meaning is "mixer ". In the game, the processing of sound generally includes two parts: making sound and playing sound. Here, only the playing sound is learned.1. Start and initialize pygame. MixerPygame. mixer. INIT (): Initialize mixer.Program, Usually put in the first fewCodeMedium:
This article mainly introduces pygame study notes (1): rectangular and circular drawing examples. This article describes pygame windows, window exits, colors, circles, rectangles in pygame, and a complete example, you can refer to pygame as a python module designed for game development. In fact,
Pygame is a python module designed to develop games. In fact, pygame is the same as time, OS, and SYS. Today, I officially started learning pygame: www.pygame.org. After the download, the installation is complete. In pygame's learning, I used the SPE editor, and it feels good.
1. pygame window
Before creating a gra
The history of Pygame??Pygame is a game library using the SDL Library, SDL, full name Simple DirectMedia Layer, is a "Sam Lantinga" written by Daniel, It is said that he was to let Loki (dedicated to the Linux transplant Windows game of a big good company, unfortunately has been closed, alas, good people do not long-lived ah ... More effective work to create this stuff.SDL is written in C, but it can also b
Pygame method of playing music, pygame playing music
This article describes how to play music in pygame. Share it with you for your reference. The details are as follows:
Method 1:
Import pygamefilename = '/home/A.mp3' pygame. mixer. music. load (filename) pygame. mixer.
This article mainly describes the detailed Python pygame installation process notes. Small series feel very good, now share to everyone, also for everyone to make a reference. Let's take a look at it with a little knitting.
See a tutorial today about Python Installing the Pygame module. Feel good, share it.
Install Python
Well, this little problem seems to be superfluous here. But in order to take care of
Download the Pygame WHL file for installation in the tutorial "Python programming from Getting started to practice" in the cmd window import pygame prompt error-free, in the Idel program can also run normally,but pycharm error import pygamemodulenotfounderror:no module named ' Pygame 'Select items in Project interpreter settings and green plus sign on right, add
() method.
Animation
It is actually very easy to make the image move from one place to another, that is, to clear the image where it was originally located and then load the image in another place, it looks like the image is moving. In computer opinion, it is actually a group of pixels moving. Is an example
The following is a sample code.
import pygame, sysfrom pygame.locals import *pygame.init()FPS = 30
It is said that in the Nintendo FC era, the role of elves is very large, but at that time only know how to play Super Mary, the Soul Dou Luo, but the elves do not know. Pygame.sprite.Sprite is a class that is used to implement the sprite in Pygame, and when used, it is not necessary to instantiate it, just inherit him, and write his own class on demand, so it is very simple and practical.
First, what is the Spirit
Sprites can be thought of as a smal
It is said that in the Nintendo FC era, the role of the elves is quite huge, but at that time only know how to play Super Mary, the soul, but the elves do not know. Pygame.sprite.Sprite is a class used in Pygame to implement the wizard, when used, do not need to instantiate it, just inherit him, and then write their own class on demand, so it is very simple and practical.
First, what is a genie
Sprites can be thought of as small pictures, a graphical
to say, the Genie cannot jump again after the second jump.
2. Press the space to reset the acceleration of the genie
To modify the preceding code:
Jump_vel = 0.0 # Set a variable to record the number of hops space_number = 0 # player_jumping = Falseplayer_start_y = player. ywhile True: for event in pygame. event. get (): if event. type = QUIT: sys. exit () if event. type = KEYDOWN: if event. key = K_SPACE:
Today, when I used pygame to play music, I encountered a strange problem. With pygame. INIT (), I couldn't hear the sound,Remove the record and try again.CodeAs follows:
1. the following code can play normally and you can hear musicImport pygame, time########## Pygame. INI
Next we will introduce some basic things of pygame.
Drawing Images with pygame. image. Load () and bits ()
Many games do not just use simple drawing functions, but also require a variety of images (also known as Genie). pygame can be loaded to the surface object in PNG format, JPG, GIF, and BMP. You can search for different formats on the Internet.
Next, I will i
1. Movement Rate
In the previous section, a car was implemented on the road from bottom to top, and Pygame.time.delay (200) was used to delay the time. Read a lot of reference materials, basic each material will talk about the different configuration of the machine under the speed of the problem, some by setting the frequency to solve, some through the set speed to solve, their own level limited, see a few, think or "Beginning Game development with Python and
1. Motion Rate
In the previous section, a car was implemented on the road from bottom to top, and the Pygame.time.delay (200) was used for time delay. See a lot of reference material, basic each material will talk about the different configuration machine movement rate of the problem, some by setting the frequency to solve, some by setting speed to solve, their own level is limited, read a few, think or "beginning Game Development with Python and Pygame
Pygame is a Python module designed to develop the game, in fact, the white and time, OS, sys are the same stuff. Today began to formally study pygame, download address: www.pygame.org. After downloading the installation is complete, in pygame learning, I used the SPE editor, I feel good.
1. pygame window
This section describes how to process fonts on the game interface. The experiment uses real-time display of the current time and ball position on the interface as an example. For details, see the code.
I. Code
[Python]#-*-Coding: UTF-8 -*-Import OSImport sysImport timeImport pygameFrom pygame. locals import *From pygame
Pygame is a Python module designed to develop the game, in fact, the same as time, OS, sys are the same stuff. Today began to formally learn pygame, download address: www.pygame.org. After downloading the installation is complete, in pygame learning, I used the SPE editor, feel good.
1. pygame window
Reprint Please note: @ small Wuyi http://www.cnblogs.com/xiaowuyi
1. single pixel (painting point)There are three main methods to use pygame to draw points:Method 1: draw a square with a length and width of 1 pixel
# @ Xiaowuyi http://www.cnblogs.com/xiaowuyi Import Pygame, syspygame. INIT () Screen = Pygame. display. set_caption ( ' Hello world! ' ) Sc
An error or pygameerror occurs when pygame loads an mp3 file with a Chinese name.
I haven't written anything for a while. I 've been working on a Python pygame-based music player in the last few days. I wanted to finish it and try again to write an article, but the deeper it gets, the framework is coming out, it may be due to my personal problems and slow time. let's talk about
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.