|
|
@ -54,7 +54,7 @@ |
|
|
|
|
|
|
|
<body> |
|
|
|
<header> |
|
|
|
<aside>December 27, 2022</aside> |
|
|
|
<aside>December 30, 2022</aside> |
|
|
|
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> |
|
|
|
</header> |
|
|
|
|
|
|
@ -2502,7 +2502,8 @@ W, H, MAX_S = <span class="hljs-number">50</span>, <span class="hljs-number">50< |
|
|
|
run(get_screen(), get_images(), get_mario(), get_tiles()) |
|
|
|
|
|
|
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">run</span><span class="hljs-params">(screen, images, mario, tiles)</span>:</span> |
|
|
|
clock, pressed = pg.time.Clock(), set() |
|
|
|
clock = pg.time.Clock() |
|
|
|
pressed = set() |
|
|
|
<span class="hljs-keyword">while</span> <span class="hljs-keyword">not</span> pg.event.get(pg.QUIT) <span class="hljs-keyword">and</span> clock.tick(<span class="hljs-number">28</span>): |
|
|
|
keys = {pg.K_UP: D.n, pg.K_RIGHT: D.e, pg.K_DOWN: D.s, pg.K_LEFT: D.w} |
|
|
|
pressed |= {keys.get(e.key) <span class="hljs-keyword">for</span> e <span class="hljs-keyword">in</span> pg.event.get(pg.KEYDOWN)} |
|
|
@ -2523,8 +2524,7 @@ W, H, MAX_S = <span class="hljs-number">50</span>, <span class="hljs-number">50< |
|
|
|
n_steps = max(abs(s) <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> mario.spd) |
|
|
|
<span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> range(n_steps): |
|
|
|
mario.spd = stop_on_collision(mario.spd, get_boundaries(mario.rect, tiles)) |
|
|
|
x, y = x + (mario.spd.x / n_steps), y + (mario.spd.y / n_steps) |
|
|
|
mario.rect.topleft = x, y |
|
|
|
mario.rect.topleft = x, y = x + (mario.spd.x / n_steps), y + (mario.spd.y / n_steps) |
|
|
|
|
|
|
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_boundaries</span><span class="hljs-params">(rect, tiles)</span>:</span> |
|
|
|
deltas = {D.n: P(<span class="hljs-number">0</span>, <span class="hljs-number">-1</span>), D.e: P(<span class="hljs-number">1</span>, <span class="hljs-number">0</span>), D.s: P(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>), D.w: P(<span class="hljs-number">-1</span>, <span class="hljs-number">0</span>)} |
|
|
@ -2919,7 +2919,7 @@ $ pyinstaller script.py --add-data '<path>:.' <span class="hljs-comment"> |
|
|
|
|
|
|
|
|
|
|
|
<footer> |
|
|
|
<aside>December 27, 2022</aside> |
|
|
|
<aside>December 30, 2022</aside> |
|
|
|
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> |
|
|
|
</footer> |
|
|
|
|
|
|
|