From 79339b22d921bb9e2832c9b3ba19d95ae38a8712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 12 Mar 2020 06:45:48 +0100 Subject: [PATCH] PyGame --- README.md | 23 ++++++++--------------- index.html | 27 ++++++++++----------------- 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 6687a4c..97c45b6 100644 --- a/README.md +++ b/README.md @@ -2932,27 +2932,21 @@ while all(event.type != pg.QUIT for event in pg.event.get()): ### Rect **Object for storing rectangular coordinates.** ```python - = pg.Rect(topleft_x, topleft_y, width, height) # x, y, w/width, h/height - = .x/y/centerx/centery/bottom/left/right/top - = .topleft/center/topright/bottomright/bottomleft - = .midtop/midright/midbottom/midleft + = pg.Rect(topleft_x, topleft_y, width, height) + = .topleft/topright/bottomright/bottomleft/center + = .x/y/centerx/centery ``` ```python - = .move(/, ) -.move_ip(/, ) - = .inflate(/, ) -.inflate_ip(/, ) + = .move() # Or: .move(, ) +.move_ip() # Or: .move_ip(, ) ``` ```python - = .contains() - = .collidepoint(/, ) + = .collidepoint() # Or: .collidepoint(, ) = .colliderect() index = .collidelist() # Returns index of first coliding Rect or -1. indices = .collidelistall() # Returns indices of all colinding Rects. -(key, value) = .collidedict() -[(key, value), ...] = .collidedictall() ``` ### Surface @@ -2966,7 +2960,7 @@ indices = .collidelistall() # Returns indices of all colind ```python .set_at((x, y), ) # Updates pixel. .fill() # Fills the whole surface. -.blit(, (x, y)/) # Draws passed surface to the surface. +.blit(, (x, y)) # Draws passed surface to the surface. = .subsurface() # Returns subsurface. ``` @@ -2976,7 +2970,6 @@ indices = .collidelistall() # Returns indices of all colind = pg.transform.scale(, (width, height)) ``` -#### Drawing: ```python pg.draw.rect(, color, ) pg.draw.polygon(, color, points) @@ -2987,7 +2980,7 @@ pg.draw.line(, color, start_pos, end_pos, width) pg.draw.lines(, color, points) ``` -#### Fonts: +### Font ```python = pg.font.SysFont(name, size, bold=False, italic=False) = pg.font.Font('', size) diff --git a/index.html b/index.html index 43e70ce..eea27dd 100644 --- a/index.html +++ b/index.html @@ -2493,25 +2493,19 @@ rect = pg.Rect(235, 2 -

Rect

Object for storing rectangular coordinates.

<Rect>  = pg.Rect(topleft_x, topleft_y, width, height)  # x, y, w/width, h/height
-<int>   = <Rect>.x/y/centerx/centery/bottom/left/right/top
-<tuple> = <Rect>.topleft/center/topright/bottomright/bottomleft
-<tuple> = <Rect>.midtop/midright/midbottom/midleft
+

Rect

Object for storing rectangular coordinates.

<Rect>  = pg.Rect(topleft_x, topleft_y, width, height)
+<tuple> = <Rect>.topleft/topright/bottomright/bottomleft/center
+<int>   = <Rect>.x/y/centerx/centery
 
-
<Rect>  = <Rect>.move(<tuple>/<int>, <int>)
-<Rect>.move_ip(<tuple>/<int>, <int>)
-<Rect>  = <Rect>.inflate(<tuple>/<int>, <int>)
-<Rect>.inflate_ip(<tuple>/<int>, <int>)
+
<Rect>  = <Rect>.move(<tuple>)                   # Or: <Rect>.move(<int>, <int>)
+<Rect>.move_ip(<tuple>)                          # Or: <Rect>.move_ip(<int>, <int>)
 
-
<bool>  = <Rect>.contains(<Rect>)
-<bool>  = <Rect>.collidepoint(<tuple>/<int>, <int>)
+
<bool>  = <Rect>.collidepoint(<tuple>)           # Or: <Rect>.collidepoint(<int>, <int>)
 <bool>  = <Rect>.colliderect(<Rect>)
 index   = <Rect>.collidelist(<list_of_Rect>)     # Returns index of first coliding Rect or -1.
 indices = <Rect>.collidelistall(<list_of_Rect>)  # Returns indices of all colinding Rects.
-(key, value) = <Rect>.collidedict(<dict_of_Rect>)
-[(key, value), ...] = <Rect>.collidedictall(<dict_of_Rect>)
 

Surface

Object for representing images.

<Surface> = pg.display.set_mode((width, height))  # Retruns the display surface.
 <Surface> = pg.Surface((width, height))           # Creates a new surface.
@@ -2521,23 +2515,22 @@ indices = <Rect>.collidelistall(<list_of_Rect>)  <Surface>.set_at((x, y), <color>)                 # Updates pixel.
 <Surface>.fill(<color>)                           # Fills the whole surface.
-<Surface>.blit(<Surface>, (x, y)/<Rect>)          # Draws passed surface to the surface.
+<Surface>.blit(<Surface>, (x, y))                 # Draws passed surface to the surface.
 <Surface> = <Surface>.subsurface(<Rect>)          # Returns subsurface.
 
<Surface> = pg.transform.flip(<Surface>, xbool, ybool)
 <Surface> = pg.transform.rotate(<Surface>, angle)
 <Surface> = pg.transform.scale(<Surface>, (width, height))
 
-

Drawing:

pg.draw.rect(<Surface>, color, <Rect>)
+
pg.draw.rect(<Surface>, color, <Rect>)
 pg.draw.polygon(<Surface>, color, points)
 pg.draw.circle(<Surface>, color, center, radius)
 pg.draw.ellipse(<Surface>, color, <Rect>)
 pg.draw.arc(<Surface>, color, <Rect>, start_angle, stop_angle)
 pg.draw.line(<Surface>, color, start_pos, end_pos, width)
 pg.draw.lines(<Surface>, color, points)
-
- -

Fonts:

<Font>    = pg.font.SysFont(name, size, bold=False, italic=False)
+
+

Font

<Font>    = pg.font.SysFont(name, size, bold=False, italic=False)
 <Font>    = pg.font.Font('<path>', size)
 <Surface> = <Font>.render(text, antialias, color, background=None)