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

PYGAME的方法和官方文档查询

官方文档

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

 

模块简介
pygame.BufferProxyAn array protocol view of surface pixels
pygame.cdromHow to access and control the CD audio devices.
pygame.ColorColor representation.
pygame.cursorsLoading and compiling cursor images.
pygame.displayConfigure the display surface.
pygame.drawDrawing simple shapes like lines and ellipses to surfaces.
pygame.eventManage the incoming events from various input devices and the windowing platform.
pygame.examplesVarious programs demonstrating the use of individual pyame modules.
pygame.fontLoading and rendering Truetype fonts.
pygame.freetypeEnhanced Pygame module for loading and rendering font faces.
pygame.gfxdrawAnti-aliasing draw functions.
pygame.imageLoading, saving, and transferring of surfaces.
pygame.joystickManage the joystick devices.
pygame.keyManage the keyboard device.
pygame.localsPygame constants.
pygame.mixerLoad and play sounds
pygame.mouseManage the mouse device and display.
pygame.movieVideo playback from MPEG movies.
pygame.mixer.musicPlay streaming music tracks.
pygame.OverlayAccess advanced video overlays.
pygameTop level functions to manage Pygame.
pygame.PixelArrayManipulate image pixel data.
pygame.RectFlexible container for a rectangle.
pygame.scrapNative clipboard access.
pygame.sndarrayManipulate sound sample data.
pygame.spriteHigher level objects to represent game images.
pygame.SurfaceObjects for images and the screen.
pygame.surfarrayManipulate image pixel data.
pygame.testsTest Pygame.
pygame.timeManage timing and framerate.
pygame.transformResize 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.copycopy the rectangle
pygame.Rect.movemoves the rectangle
pygame.Rect.move_ipmoves the rectangle, in place
pygame.Rect.inflategrow or shrink the rectangle size
pygame.Rect.inflate_ipgrow or shrink the rectangle size, in place
pygame.Rect.clampmoves the rectangle inside another
pygame.Rect.clamp_ipmoves the rectangle inside another, in place
pygame.Rect.clipcrops a rectangle inside another
pygame.Rect.unionjoins two rectangles into one
pygame.Rect.union_ipjoins two rectangles into one, in place
pygame.Rect.unionallthe union of many rectangles
pygame.Rect.unionall_ipthe union of many rectangles, in place
pygame.Rect.fitresize and move a rectangle with aspect ratio
pygame.Rect.normalizecorrect negative sizes
pygame.Rect.containstest if one rectangle is inside another
pygame.Rect.collidepointtest if a point is inside a rectangle
pygame.Rect.colliderecttest if two rectangles overlap
pygame.Rect.collidelisttest if one rectangle in a list intersects
pygame.Rect.collidelistalltest if all rectangles in a list intersect
pygame.Rect.collidedicttest if one rectangle in a dictionary intersects
pygame.Rect.collidedictalltest 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

 

  • 8
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值