<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>sashzのブログ</title>
<link>https://ameblo.jp/sashz/</link>
<atom:link href="https://rssblog.ameba.jp/sashz/rss20.xml" rel="self" type="application/rss+xml" />
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
<description>ブログの説明を入力します。</description>
<language>ja</language>
<item>
<title>Como é criar jogos com a game engine Pyxel</title>
<description>
<![CDATA[ <p>Já faz um bom tempo que ando mexendo com uma ferramenta incrível para se fazer jogos, chamada <b style="font-weight:bold;">Pyxel</b>.</p><p>&nbsp;</p><div class="ogpCard_root"><article class="ogpCard_wrap" contenteditable="false" style="display:inline-block;max-width:100%"><a class="ogpCard_link" data-ogp-card-log="" href="https://github.com/kitao/pyxel" rel="noopener noreferrer" style="display:flex;justify-content:space-between;overflow:hidden;box-sizing:border-box;width:620px;max-width:100%;height:120px;border:1px solid #e2e2e2;border-radius:4px;background-color:#fff;text-decoration:none" target="_blank"><span class="ogpCard_content" style="display:flex;flex-direction:column;overflow:hidden;width:100%;padding:16px"><span class="ogpCard_title" style="-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;max-height:48px;line-height:1.4;font-size:16px;color:#333;text-align:left;font-weight:bold;overflow:hidden">GitHub - kitao/pyxel: A retro game engine for Python</span><span class="ogpCard_description" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.6;margin-top:4px;color:#757575;text-align:left;font-size:12px">A retro game engine for Python. Contribute to kitao/pyxel development by creating an account on GitHub.</span><span class="ogpCard_url" style="display:flex;align-items:center;margin-top:auto"><span class="ogpCard_iconWrap" style="position:relative;width:20px;height:20px;flex-shrink:0"><img alt="リンク" class="ogpCard_icon" height="20" loading="lazy" src="https://c.stat100.ameba.jp/ameblo/symbols/v3.20.0/svg/gray/editor_link.svg" style="position:absolute;top:0;bottom:0;right:0;left:0;height:100%;max-height:100%" width="20"></span><span class="ogpCard_urlText" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#757575;font-size:12px;text-align:left">github.com</span></span></span><span class="ogpCard_imageWrap" style="position:relative;width:120px;height:120px;flex-shrink:0"><img alt="" class="ogpCard_image" data-ogp-card-image="" height="120" loading="lazy" src="https://opengraph.githubassets.com/31e8b5411b424bcdf32ada6c02cea776de2326f368322f1f48f30dd2103010c2/kitao/pyxel" style="position:absolute;top:50%;left:50%;object-fit:cover;min-height:100%;min-width:100%;transform:translate(-50%,-50%)" width="120"></span></a></article></div><p>&nbsp;</p><p><b style="font-weight:bold;">Pyxel</b> é uma game engine retrô, que utiliza a linguagem Python. Ela é bem minimanlista, e lembra as bastante conhecidas Pico-8 e TIC-80.</p><p>&nbsp;</p><p>A estrutura básica, para quem começa a desenvolver um jogo, é a seguinte:</p><p>&nbsp;</p><blockquote><p>import pyxel</p><p>&nbsp;</p><p>class Game:</p><p>&nbsp; &nbsp; def __init__(self):</p><p>&nbsp; &nbsp; &nbsp; &nbsp; pyxel.init(128, 128, title="My New Game")</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; pyxel.run(self.update, self.draw)</p><p>&nbsp;</p><p>&nbsp; &nbsp; def update(self):</p><p>&nbsp; &nbsp; &nbsp; &nbsp; pass</p><p>&nbsp;</p><p>&nbsp; &nbsp; def draw(self):</p><p>&nbsp; &nbsp; &nbsp; &nbsp; pass</p><p>&nbsp;</p><p>Game()</p></blockquote><p>&nbsp;</p><p>Aqui, você já tem o desenho da janela do jogo na tela do computador, com o título "My New Game" na barra. Digitando <i style="font-style:italic;">pyxel run main.py</i> (nome padrão do arquivo principal), você já pode rodar seu jogo.</p><p>&nbsp;</p><p>Vamos criar um objeto controlável pelas setas do teclado. Desta vez, será apenas um retângulo.</p><p>&nbsp;</p><p>Abaixo&nbsp;está o código. Repare que você pode comentar o código adicionando dois hífens antes do texto.</p><p>&nbsp;</p><blockquote><p>import pyxel</p><p>&nbsp;</p><p>class Game:</p><p>&nbsp; &nbsp; def __init__(self):</p><p>&nbsp; &nbsp; &nbsp; &nbsp; pyxel.init(128, 128, title="My New Game")</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; self.x = 20</p><p>&nbsp; &nbsp; &nbsp; &nbsp; self.y = 20</p><p>&nbsp; &nbsp; &nbsp; &nbsp; self.speed = 50</p><p>&nbsp; &nbsp; &nbsp; &nbsp; sef.width = 40</p><p>&nbsp; &nbsp; &nbsp; &nbsp; self.height = 40</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; pyxel.run(self.update, self.draw)</p><p>&nbsp;</p><p>&nbsp; &nbsp; def update(self):</p><p>&nbsp; &nbsp; &nbsp; &nbsp; if pyxel.btn(pyxel.RIGHT):</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.x += self.speed</p><p>&nbsp; &nbsp; &nbsp; &nbsp; elif pyxel.btn(pyxel.LEFT):</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.x -= self.speed</p><p>&nbsp;</p><p>&nbsp; &nbsp; def draw(self):</p><p>&nbsp; &nbsp; &nbsp; &nbsp; pyxel.cls(0) -- Limpa a tela com a cor 0 (preto)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; pyxel.rect(self.x, self.y, self.width, self.height, 4)</p><p>&nbsp;</p><p>Game()</p></blockquote><p>&nbsp;</p><p>O resultado é este que você vê na imagem:</p><p>&nbsp;</p><p><a href="https://stat.ameba.jp/user_images/20260616/09/sashz/8c/7e/p/o0772080215793424291.png"><img alt="" height="436" src="https://stat.ameba.jp/user_images/20260616/09/sashz/8c/7e/p/o0772080215793424291.png" width="420"></a></p><p>&nbsp;</p><p>Utilizando as setas para direita/esquerda, você controla o retângulo.</p><p>&nbsp;</p><p>Na game engine <b style="font-weight:bold;">Pyxel</b>, o ponto inicial se localiza no canto superior esquerdo da tela. Então, quando definimos as posições X e Y como 20, quer dizer que o quadrado será desenhado a partir de 20 <i style="font-style:italic;">pixels</i> da esquerda para a direita, de cima para baixo. Outro ponto importante de se salientar, é que o tamanho da janela, definido como 128 x 128 <i style="font-style:italic;">ṕixels</i>, é desenhado em uma escala maior no&nbsp;monitor.</p><p>&nbsp;</p><p>No próximo artigo, estudaremos como criar <i style="font-style:italic;">sprites</i> no jogo.</p><div class="simple-translate-system-theme" id="simple-translate"><div><div class="simple-translate-button isShow" style="background-image: url(&quot;chrome-extension://ibplnjkanclpjokhdolnendpplpjiace/icons/512.png&quot;); height: 30px; width: 30px; top: 617px; left: 720px;">&nbsp;</div><div class="simple-translate-panel " style="width: 600px; height: 400px; top: 0px; left: 0px; font-size: 20px; background-color: rgb(83, 0, 184);"><div class="simple-translate-result-wrapper" style="overflow: hidden;"><div class="simple-translate-move" draggable="true">&nbsp;</div><div class="simple-translate-result-contents"><p class="simple-translate-result" dir="auto" style="color: rgb(255, 255, 255);">&nbsp;</p><p class="simple-translate-candidate" dir="auto" style="color: rgb(115, 115, 115);">&nbsp;</p></div></div></div></div></div>
]]>
</description>
<link>https://ameblo.jp/sashz/entry-12969807284.html</link>
<pubDate>Mon, 15 Jun 2026 21:30:00 +0900</pubDate>
</item>
</channel>
</rss>
