1、Keyboard events:
KEYDOWN
KEYUP
2、key names:
K_a,K_b(for letter keys)
K_SPACE
K_ESCAPE
3、Mouse events:
MOUSEMOTION
MOUSEBUTTONUP
MOUSEBUTTONDOWN
4、event.pos:the
position(x and y coordinates)
5、Timer events:
pygame.time.set_timer(EVENT_NUMBER,interval)
获取pygame的已用事件:
>> import pygame
>>pygame.USEREVENT
输出结果:24
说明已用事件从0到23,可用的userevent从24开始。
获取pygame的最大事件类型:
>>pygame.NUMEVENTS
输出结果:32
说明可用的事件从0到31,那么可用的userevent从24到31。
通常使用方法:
Pygame.time.set_timer(pygame.USEREVENT,1000)
备注:1000是指毫秒为单位。
6、\:是line-contination
character.使用这个符号可以用两行显示,但是还是表示在同一行的意思。一般这个符号在
一行结尾使用,但是这个符号后不能有空格。
7、display text的对象:
font = pygame.font.Font(None,50)
score_text =
font.render(str(points),1,(0,0,0))
textpos = [10,10]
screen.blit(score_text,textpos)
8、创建一个surface
image_surface =
pygame.surface.Surface([100,20])
image_surface.fill([0,0,0])
self.image = image_surface.convert()
self.rect = self.image.get_rect()
self.rect.left,self.rect.top = location
9、paddle:一段代码只处理一个事件。比如创建8的surface。