Skip to content

Commit 35bec32

Browse files
committed
Pygame
1 parent db1bcb9 commit 35bec32

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2991,6 +2991,7 @@ simpleaudio.play_buffer(samples_i, 1, 2, F).wait_done()
29912991

29922992
Pygame
29932993
------
2994+
#### Opes a window and draws a square that can be moved with arrow keys:
29942995
```python
29952996
# $ pip3 install pygame
29962997
import pygame as pg
@@ -3006,6 +3007,7 @@ while not pg.event.get(pg.QUIT):
30063007
screen.fill(pg.Color('black'))
30073008
pg.draw.rect(screen, pg.Color('white'), rect)
30083009
pg.display.flip()
3010+
pg.quit()
30093011
```
30103012

30113013
### Rect
@@ -3054,7 +3056,6 @@ arc(<Surf>, color, <Rect>, from_rad, to_rad) # Also ellipse(<Surf>, color, <R
30543056
rect(<Surf>, color, <Rect>, width=0) # Also polygon(<Surf>, color, points, width=0).
30553057
```
30563058

3057-
### Font
30583059
```python
30593060
<Font> = pg.font.Font(<path/file>, size) # Loads TTF file. Pass None for default font.
30603061
<Surf> = <Font>.render(text, antialias, color) # Background color can be specified at the end.

index.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,7 +2435,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
24352435
</code></pre></div></div>
24362436

24372437

2438-
<div><h2 id="pygame"><a href="#pygame" name="pygame">#</a>Pygame</h2><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install pygame</span>
2438+
<div><h2 id="pygame"><a href="#pygame" name="pygame">#</a>Pygame</h2><div><h4 id="opesawindowanddrawsasquarethatcanbemovedwitharrowkeys">Opes a window and draws a square that can be moved with arrow keys:</h4><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install pygame</span>
24392439
<span class="hljs-keyword">import</span> pygame <span class="hljs-keyword">as</span> pg
24402440

24412441
pg.init()
@@ -2449,7 +2449,9 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
24492449
screen.fill(pg.Color(<span class="hljs-string">'black'</span>))
24502450
pg.draw.rect(screen, pg.Color(<span class="hljs-string">'white'</span>), rect)
24512451
pg.display.flip()
2452-
</code></pre></div>
2452+
pg.quit()
2453+
</code></pre></div></div>
2454+
24532455

24542456
<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(x, y, width, height) <span class="hljs-comment"># Creates Rect object. Truncates passed floats.</span>
24552457
&lt;int&gt; = &lt;Rect&gt;.x/y/centerx/centery/… <span class="hljs-comment"># Top, right, bottom, left. Allows assignments.</span>
@@ -2485,10 +2487,9 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
24852487
arc(&lt;Surf&gt;, color, &lt;Rect&gt;, from_rad, to_rad) <span class="hljs-comment"># Also ellipse(&lt;Surf&gt;, color, &lt;Rect&gt;, width=0).</span>
24862488
rect(&lt;Surf&gt;, color, &lt;Rect&gt;, width=<span class="hljs-number">0</span>) <span class="hljs-comment"># Also polygon(&lt;Surf&gt;, color, points, width=0).</span>
24872489
</code></pre>
2488-
<div><h3 id="font">Font</h3><pre><code class="python language-python hljs">&lt;Font&gt; = pg.font.Font(&lt;path/file&gt;, size) <span class="hljs-comment"># Loads TTF file. Pass None for default font.</span>
2490+
<pre><code class="python language-python hljs">&lt;Font&gt; = pg.font.Font(&lt;path/file&gt;, size) <span class="hljs-comment"># Loads TTF file. Pass None for default font.</span>
24892491
&lt;Surf&gt; = &lt;Font&gt;.render(text, antialias, color) <span class="hljs-comment"># Background color can be specified at the end.</span>
2490-
</code></pre></div>
2491-
2492+
</code></pre>
24922493
<div><h3 id="sound">Sound</h3><pre><code class="python language-python hljs">&lt;Sound&gt; = pg.mixer.Sound(&lt;path/file/bytes&gt;) <span class="hljs-comment"># WAV file or bytes/array of signed shorts.</span>
24932494
&lt;Sound&gt;.play/stop() <span class="hljs-comment"># Also set_volume(&lt;float&gt;), fadeout(msec).</span>
24942495
</code></pre></div>

0 commit comments

Comments
 (0)