【整理】python学习笔记(5)-- pygame库的函数和方法整理

版权声明:一起学习,一起成长,欢迎关注犀牛先生的博客 https://blog.csdn.net/xuemanqianshan/article/details/83409829

PYGAME的方法和官方文档查询

官方文档

http://www.pygame.org/docs/

模块 简介
pygame.BufferProxy An array protocol view of surface pixels
pygame.cdrom How to access and control the CD audio devices.
pygame.Color Color representation.
pygame.cursors Loading and compiling cursor images.
pygame.display Configure the display surface.
pygame.draw Drawing simple shapes like lines and ellipses to surfaces.
pygame.event Manage the incoming events from various input devices and the windowing platform.
pygame.examples Various programs demonstrating the use of individual pyame modules.
pygame.font Loading and rendering Truetype fonts.
pygame.freetype Enhanced Pygame module for loading and rendering font faces.
pygame.gfxdraw Anti-aliasing draw functions.
pygame.image Loading, saving, and transferring of surfaces.
pygame.joystick Manage the joystick devices.
pygame.key Manage the keyboard device.
pygame.locals Pygame constants.
pygame.mixer Load and play sounds
pygame.mouse Manage the mouse device and display.
pygame.movie Video playback from MPEG movies.
pygame.mixer.music Play streaming music tracks.
pygame.Overlay Access advanced video overlays.
pygame Top level functions to manage Pygame.
pygame.PixelArray Manipulate image pixel data.
pygame.Rect Flexible container for a rectangle.
pygame.scrap Native clipboard access.
pygame.sndarray Manipulate sound sample data.
pygame.sprite Higher level objects to represent game images.
pygame.Surface Objects for images and the screen.
pygame.surfarray Manipulate image pixel data.
pygame.tests Test Pygame.
pygame.time Manage timing and framerate.
pygame.transform Resize and move images.

pygame.Rect

pygame object for storing rectangular coordinates

Rect(left, top, width, height) -> Rect

Rect((left, top), (width, height)) -> Rect

Rect(object) -> Rect

pygame.Rect.copy copy the rectangle
pygame.Rect.move moves the rectangle
pygame.Rect.move_ip moves the rectangle, in place
pygame.Rect.inflate grow or shrink the rectangle size
pygame.Rect.inflate_ip grow or shrink the rectangle size, in place
pygame.Rect.clamp moves the rectangle inside another
pygame.Rect.clamp_ip moves the rectangle inside another, in place
pygame.Rect.clip crops a rectangle inside another
pygame.Rect.union joins two rectangles into one
pygame.Rect.union_ip joins two rectangles into one, in place
pygame.Rect.unionall the union of many rectangles
pygame.Rect.unionall_ip the union of many rectangles, in place
pygame.Rect.fit resize and move a rectangle with aspect ratio
pygame.Rect.normalize correct negative sizes
pygame.Rect.contains test if one rectangle is inside another
pygame.Rect.collidepoint test if a point is inside a rectangle
pygame.Rect.colliderect test if two rectangles overlap
pygame.Rect.collidelist test if one rectangle in a list intersects
pygame.Rect.collidelistall test if all rectangles in a list intersect
pygame.Rect.collidedict test if one rectangle in a dictionary intersects
pygame.Rect.collidedictall test if all rectangles in a dictionary intersect

(转)RECT详细图像说明

来源原文:https://blog.csdn.net/qq_39546430/article/details/80407817 

Rect对象的属性:
1.返回一个坐标数字
x,y
top, left, bottom, right
centerx, centerysize
width, height
w,h;
2.返回一个(X,Y)坐标数组
topleft (左上)
bottomleft (左下)
bottomright (右下)


midtop(中上)
midleft(左中)
midbottom(底中)
midright(右中)


center(中心点坐标)
直接上图,灰色矩形大小(900,450),中央蓝色矩形(400,510),大家自己体会一下 

è¿éåå¾çæè¿°

我根据这个,和我的理解,画了一个更详细,好懂的图

但是现在不确定的,还有 x, y,size 这几个是什么?

有个哥们研究了下 x y分别就是left top 其实就是topleft点!

https://blog.csdn.net/weixin_39480632/article/details/81273020

那我估计size就是(width height)

另外小甲鱼还有一些rect的更多的方法说明,以后再学

https://fishc.com.cn/thread-62186-1-1.html

猜你喜欢

转载自blog.csdn.net/xuemanqianshan/article/details/83409829