Skip to content

Commit 79339b2

Browse files
committed
PyGame
1 parent 9fb92d2 commit 79339b2

File tree

2 files changed

+18
-32
lines changed

2 files changed

+18
-32
lines changed

README.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2932,27 +2932,21 @@ while all(event.type != pg.QUIT for event in pg.event.get()):
29322932
### Rect
29332933
**Object for storing rectangular coordinates.**
29342934
```python
2935-
<Rect> = pg.Rect(topleft_x, topleft_y, width, height) # x, y, w/width, h/height
2936-
<int> = <Rect>.x/y/centerx/centery/bottom/left/right/top
2937-
<tuple> = <Rect>.topleft/center/topright/bottomright/bottomleft
2938-
<tuple> = <Rect>.midtop/midright/midbottom/midleft
2935+
<Rect> = pg.Rect(topleft_x, topleft_y, width, height)
2936+
<tuple> = <Rect>.topleft/topright/bottomright/bottomleft/center
2937+
<int> = <Rect>.x/y/centerx/centery
29392938
```
29402939

29412940
```python
2942-
<Rect> = <Rect>.move(<tuple>/<int>, <int>)
2943-
<Rect>.move_ip(<tuple>/<int>, <int>)
2944-
<Rect> = <Rect>.inflate(<tuple>/<int>, <int>)
2945-
<Rect>.inflate_ip(<tuple>/<int>, <int>)
2941+
<Rect> = <Rect>.move(<tuple>) # Or: <Rect>.move(<int>, <int>)
2942+
<Rect>.move_ip(<tuple>) # Or: <Rect>.move_ip(<int>, <int>)
29462943
```
29472944

29482945
```python
2949-
<bool> = <Rect>.contains(<Rect>)
2950-
<bool> = <Rect>.collidepoint(<tuple>/<int>, <int>)
2946+
<bool> = <Rect>.collidepoint(<tuple>) # Or: <Rect>.collidepoint(<int>, <int>)
29512947
<bool> = <Rect>.colliderect(<Rect>)
29522948
index = <Rect>.collidelist(<list_of_Rect>) # Returns index of first coliding Rect or -1.
29532949
indices = <Rect>.collidelistall(<list_of_Rect>) # Returns indices of all colinding Rects.
2954-
(key, value) = <Rect>.collidedict(<dict_of_Rect>)
2955-
[(key, value), ...] = <Rect>.collidedictall(<dict_of_Rect>)
29562950
```
29572951

29582952
### Surface
@@ -2966,7 +2960,7 @@ indices = <Rect>.collidelistall(<list_of_Rect>) # Returns indices of all colind
29662960
```python
29672961
<Surface>.set_at((x, y), <color>) # Updates pixel.
29682962
<Surface>.fill(<color>) # Fills the whole surface.
2969-
<Surface>.blit(<Surface>, (x, y)/<Rect>) # Draws passed surface to the surface.
2963+
<Surface>.blit(<Surface>, (x, y)) # Draws passed surface to the surface.
29702964
<Surface> = <Surface>.subsurface(<Rect>) # Returns subsurface.
29712965
```
29722966

@@ -2976,7 +2970,6 @@ indices = <Rect>.collidelistall(<list_of_Rect>) # Returns indices of all colind
29762970
<Surface> = pg.transform.scale(<Surface>, (width, height))
29772971
```
29782972

2979-
#### Drawing:
29802973
```python
29812974
pg.draw.rect(<Surface>, color, <Rect>)
29822975
pg.draw.polygon(<Surface>, color, points)
@@ -2987,7 +2980,7 @@ pg.draw.line(<Surface>, color, start_pos, end_pos, width)
29872980
pg.draw.lines(<Surface>, color, points)
29882981
```
29892982

2990-
#### Fonts:
2983+
### Font
29912984
```python
29922985
<Font> = pg.font.SysFont(name, size, bold=False, italic=False)
29932986
<Font> = pg.font.Font('<path>', size)

index.html

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,25 +2493,19 @@
24932493
</code></pre></div></div>
24942494

24952495

2496-
<div><h3 id="rect">Rect</h3><p><strong>Object for storing rectangular coordinates.</strong></p><pre><code class="python language-python hljs">&lt;Rect&gt; = pg.Rect(topleft_x, topleft_y, width, height) <span class="hljs-comment"># x, y, w/width, h/height</span>
2497-
&lt;int&gt; = &lt;Rect&gt;.x/y/centerx/centery/bottom/left/right/top
2498-
&lt;tuple&gt; = &lt;Rect&gt;.topleft/center/topright/bottomright/bottomleft
2499-
&lt;tuple&gt; = &lt;Rect&gt;.midtop/midright/midbottom/midleft
2496+
<div><h3 id="rect">Rect</h3><p><strong>Object for storing rectangular coordinates.</strong></p><pre><code class="python language-python hljs">&lt;Rect&gt; = pg.Rect(topleft_x, topleft_y, width, height)
2497+
&lt;tuple&gt; = &lt;Rect&gt;.topleft/topright/bottomright/bottomleft/center
2498+
&lt;int&gt; = &lt;Rect&gt;.x/y/centerx/centery
25002499
</code></pre></div>
25012500

25022501

2503-
<pre><code class="python language-python hljs">&lt;Rect&gt; = &lt;Rect&gt;.move(&lt;tuple&gt;/&lt;int&gt;, &lt;int&gt;)
2504-
&lt;Rect&gt;.move_ip(&lt;tuple&gt;/&lt;int&gt;, &lt;int&gt;)
2505-
&lt;Rect&gt; = &lt;Rect&gt;.inflate(&lt;tuple&gt;/&lt;int&gt;, &lt;int&gt;)
2506-
&lt;Rect&gt;.inflate_ip(&lt;tuple&gt;/&lt;int&gt;, &lt;int&gt;)
2502+
<pre><code class="python language-python hljs">&lt;Rect&gt; = &lt;Rect&gt;.move(&lt;tuple&gt;) <span class="hljs-comment"># Or: &lt;Rect&gt;.move(&lt;int&gt;, &lt;int&gt;)</span>
2503+
&lt;Rect&gt;.move_ip(&lt;tuple&gt;) <span class="hljs-comment"># Or: &lt;Rect&gt;.move_ip(&lt;int&gt;, &lt;int&gt;)</span>
25072504
</code></pre>
2508-
<pre><code class="python language-python hljs">&lt;bool&gt; = &lt;Rect&gt;.contains(&lt;Rect&gt;)
2509-
&lt;bool&gt; = &lt;Rect&gt;.collidepoint(&lt;tuple&gt;/&lt;int&gt;, &lt;int&gt;)
2505+
<pre><code class="python language-python hljs">&lt;bool&gt; = &lt;Rect&gt;.collidepoint(&lt;tuple&gt;) <span class="hljs-comment"># Or: &lt;Rect&gt;.collidepoint(&lt;int&gt;, &lt;int&gt;)</span>
25102506
&lt;bool&gt; = &lt;Rect&gt;.colliderect(&lt;Rect&gt;)
25112507
index = &lt;Rect&gt;.collidelist(&lt;list_of_Rect&gt;) <span class="hljs-comment"># Returns index of first coliding Rect or -1.</span>
25122508
indices = &lt;Rect&gt;.collidelistall(&lt;list_of_Rect&gt;) <span class="hljs-comment"># Returns indices of all colinding Rects.</span>
2513-
(key, value) = &lt;Rect&gt;.collidedict(&lt;dict_of_Rect&gt;)
2514-
[(key, value), ...] = &lt;Rect&gt;.collidedictall(&lt;dict_of_Rect&gt;)
25152509
</code></pre>
25162510
<div><h3 id="surface">Surface</h3><p><strong>Object for representing images.</strong></p><pre><code class="python language-python hljs">&lt;Surface&gt; = pg.display.set_mode((width, height)) <span class="hljs-comment"># Retruns the display surface.</span>
25172511
&lt;Surface&gt; = pg.Surface((width, height)) <span class="hljs-comment"># Creates a new surface.</span>
@@ -2521,23 +2515,22 @@
25212515

25222516
<pre><code class="python language-python hljs">&lt;Surface&gt;.set_at((x, y), &lt;color&gt;) <span class="hljs-comment"># Updates pixel.</span>
25232517
&lt;Surface&gt;.fill(&lt;color&gt;) <span class="hljs-comment"># Fills the whole surface.</span>
2524-
&lt;Surface&gt;.blit(&lt;Surface&gt;, (x, y)/&lt;Rect&gt;) <span class="hljs-comment"># Draws passed surface to the surface.</span>
2518+
&lt;Surface&gt;.blit(&lt;Surface&gt;, (x, y)) <span class="hljs-comment"># Draws passed surface to the surface.</span>
25252519
&lt;Surface&gt; = &lt;Surface&gt;.subsurface(&lt;Rect&gt;) <span class="hljs-comment"># Returns subsurface.</span>
25262520
</code></pre>
25272521
<pre><code class="python language-python hljs">&lt;Surface&gt; = pg.transform.flip(&lt;Surface&gt;, xbool, ybool)
25282522
&lt;Surface&gt; = pg.transform.rotate(&lt;Surface&gt;, angle)
25292523
&lt;Surface&gt; = pg.transform.scale(&lt;Surface&gt;, (width, height))
25302524
</code></pre>
2531-
<div><h4 id="drawing-1">Drawing:</h4><pre><code class="python language-python hljs">pg.draw.rect(&lt;Surface&gt;, color, &lt;Rect&gt;)
2525+
<pre><code class="python language-python hljs">pg.draw.rect(&lt;Surface&gt;, color, &lt;Rect&gt;)
25322526
pg.draw.polygon(&lt;Surface&gt;, color, points)
25332527
pg.draw.circle(&lt;Surface&gt;, color, center, radius)
25342528
pg.draw.ellipse(&lt;Surface&gt;, color, &lt;Rect&gt;)
25352529
pg.draw.arc(&lt;Surface&gt;, color, &lt;Rect&gt;, start_angle, stop_angle)
25362530
pg.draw.line(&lt;Surface&gt;, color, start_pos, end_pos, width)
25372531
pg.draw.lines(&lt;Surface&gt;, color, points)
2538-
</code></pre></div>
2539-
2540-
<div><h4 id="fonts">Fonts:</h4><pre><code class="python language-python hljs">&lt;Font&gt; = pg.font.SysFont(name, size, bold=<span class="hljs-keyword">False</span>, italic=<span class="hljs-keyword">False</span>)
2532+
</code></pre>
2533+
<div><h3 id="font">Font</h3><pre><code class="python language-python hljs">&lt;Font&gt; = pg.font.SysFont(name, size, bold=<span class="hljs-keyword">False</span>, italic=<span class="hljs-keyword">False</span>)
25412534
&lt;Font&gt; = pg.font.Font(<span class="hljs-string">'&lt;path&gt;'</span>, size)
25422535
&lt;Surface&gt; = &lt;Font&gt;.render(text, antialias, color, background=<span class="hljs-keyword">None</span>)
25432536
</code></pre></div>

0 commit comments

Comments
 (0)