1. 程式人生 > >【整理】python學習筆記(5)-- pygame庫的函式和方法整理

【整理】python學習筆記(5)-- pygame庫的函式和方法整理

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