<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CubaGames &#187; Desenvolvimento</title>
	<atom:link href="http://www.cubagames.com.br/category/desenvolvimento/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cubagames.com.br</link>
	<description>Notícias sobre o mundo dos games, artigos sobre gamedev, reflexões, tutoriais, games e jogos online</description>
	<lastBuildDate>Wed, 01 Feb 2012 16:40:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>David Crane Mostra Como Fazia Jogos de Atari</title>
		<link>http://www.cubagames.com.br/david-crane-mostra-como-fazia-jogos-de-atari/</link>
		<comments>http://www.cubagames.com.br/david-crane-mostra-como-fazia-jogos-de-atari/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 00:18:00 +0000</pubDate>
		<dc:creator>Fernando Lorenzon</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[Atari 2600]]></category>
		<category><![CDATA[David Crane]]></category>
		<category><![CDATA[Pitfall]]></category>

		<guid isPermaLink="false">http://www.cubagames.com.br/?p=2986</guid>
		<description><![CDATA[<p>Vi recentemente um vídeo da GDC 2011 onde David Crane, o criador de Pitfall, fala de suas experiências de desenvolvimento com o Atari 2600. O vídeo é de março e só fui descobrir agora, simplesmente porque não sou um rato de internet, hehehe. Para quem se interessa por desenvolvimento, vale a pena dar uma olhada. David explica de maneira bem didática as limitações do console e técnicas ninja empregadas para expremer os jogos nos cartuchinhos.</p>
<p><a href="http://www.youtube.com/watch?v=MBT1OK6VAIU">http://www.youtube.com/watch?v=MBT1OK6VAIU</a></p>
<p><iframe width="450" height="250" src="http://www.youtube.com/embed/MBT1OK6VAIU" frameborder="0" allowfullscreen></iframe></p>
]]></description>
		<wfw:commentRss>http://www.cubagames.com.br/david-crane-mostra-como-fazia-jogos-de-atari/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Códigos dos Lander no SourceForge</title>
		<link>http://www.cubagames.com.br/codigos-dos-lander-no-sourceforge/</link>
		<comments>http://www.cubagames.com.br/codigos-dos-lander-no-sourceforge/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 15:18:44 +0000</pubDate>
		<dc:creator>Fernando Lorenzon</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[WinForms Lander]]></category>
		<category><![CDATA[XNA Lander]]></category>

		<guid isPermaLink="false">http://www.cubagames.com.br/?p=2743</guid>
		<description><![CDATA[<p>Galera, depois de muito tempo fiz algo muito bacana que facilitará minha vida. Fiz upload dos fontes do <strong>WinForms Lander </strong>e do <strong>XNA Lander</strong> no <a href="http://sourceforge.net">sourceforge.net</a>.</p>
<p>Os fontes podem ser baixados por SVN ou através de um tarball.</p>
<p>Lembrando que para poder abrir e executar o projeto é necessário o <strong>Visual Studio 2008</strong> ou o <strong>C# Express 2008</strong>. Para o projeto do XNA, é necessário instalar também o XNA 3.1.</p>
<p><strong>WinForms Lander:</strong></p>
<p><a href="https://sourceforge.net/projects/winformslander/">Link do Projeto</a><br />
<a href="http://winformslander.svn.sourceforge.net/viewvc/winformslander/">Link dos Fontes</a><br />
<a href="http://sourceforge.net/projects/winformslander/files/WinFormsLander_1.0.zip/download">Link do Release 1.0</a></p>
<p><strong>XNA Lander:</strong></p>
<p><a href="https://sourceforge.net/projects/xnalander/">Link do Projeto</a><br />
<a href="http://xnalander.svn.sourceforge.net/viewvc/xnalander/">Link dos Fontes</a><br />
<a href="http://sourceforge.net/projects/xnalander/files/XNALander_1.0.zip/download">Link do Release 1.0</a></p>
<p>Para que um jogo em XNA funcione em sua máquina, primeiro deve ser instalado o XNA Redistributable.<br />
<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=53867a2a-e249-4560-8011-98eb3e799ef2&amp;displaylang=en"><br />
Download do XNA Redistributable 3.1.</a></p>
]]></description>
		<wfw:commentRss>http://www.cubagames.com.br/codigos-dos-lander-no-sourceforge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Criando Um Jogo em XNA – Parte 7 – Conclusão</title>
		<link>http://www.cubagames.com.br/criando-um-jogo-em-xna-%e2%80%93-parte-7-%e2%80%93-conclusao/</link>
		<comments>http://www.cubagames.com.br/criando-um-jogo-em-xna-%e2%80%93-parte-7-%e2%80%93-conclusao/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 22:53:24 +0000</pubDate>
		<dc:creator>Fernando Lorenzon</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>

		<guid isPermaLink="false">http://www.cubagames.com.br/?p=1915</guid>
		<description><![CDATA[<p>Finalmente chegamos ao final desta série. Obviamente eu não cobri tudo sobre XNA, mas também não era o foco inicial dos posts. A idéia era dar uma pincelada sobre o básico deste framework. No futuro, conforme eu for descobrindo coisas mais legais, eu vou escrevendo mais. Estou atualmente estudando conceitos de games de corrida e criação de tile-maps (bloquinhos para criar fases).</p>
<p>Como prometido, disponibilizo o game bem como o código fonte.</p>
<p>Então, para que um jogo em XNA funcione em sua máquina, primeiro deve ser instalado o XNA Redistributable.<br />
<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=53867a2a-e249-4560-8011-98eb3e799ef2&#038;displaylang=en"><br />
Download do XNA Redistributable 3.1.</a></p>
<p><a href="http://www.4shared.com/file/I5jSt43_/XNALander_Game.html">Download do jogo XNA Lander</a></p>
<p><a href="http://www.4shared.com/file/pRQtvWra/XNALander_Source.html">Download do código fonte do XNA Lander</a></p>
<p>Qualquer problema ou dúvida, estou a disposição para ajudar. Basta deixar um comentário.</p>
<p><a href="http://www.cubagames.com.br/criando-um-jogo-em-xna-%E2%80%93-parte-6-%E2%80%93-audio/">Parte 6 &#8211; Audio</a></p>
]]></description>
		<wfw:commentRss>http://www.cubagames.com.br/criando-um-jogo-em-xna-%e2%80%93-parte-7-%e2%80%93-conclusao/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Criando Um Jogo em XNA – Parte 6 – Audio</title>
		<link>http://www.cubagames.com.br/criando-um-jogo-em-xna-%e2%80%93-parte-6-%e2%80%93-audio/</link>
		<comments>http://www.cubagames.com.br/criando-um-jogo-em-xna-%e2%80%93-parte-6-%e2%80%93-audio/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 13:34:37 +0000</pubDate>
		<dc:creator>Fernando Lorenzon</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>

		<guid isPermaLink="false">http://www.cubagames.com.br/?p=1905</guid>
		<description><![CDATA[<p>Continuando a série sobre XNA, vamos abordar o áudio do XNA.</p>
<p>Em primeiro lugar, temos uma classe usada somente para tocar música, chamada de Song.</p>
<p>Para carregar o som, deve-se usar o Content.Load da mesma forma que uma textura, passando por parâmetro o caminho relativo do arquivo (sem extensão) a partir do diretório Content.</p>
<p>Segue o código:</p>
<div class="igBar"><span id="lc-1"><a href="#" onclick="javascript:showPlainTxt('c-1'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-1">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Song song = Content.<span style="color: #202020;">Load</span>&lt;Song&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Songs<span style="color: #000099; font-weight: bold;">\\</span>Intro"</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Para tocar a música, deve-se usar a classe estática MediaPlayer, que é própria do XNA. Vejam todos os comandos possíveis:</p>
<div class="igBar"><span id="lc-2"><a href="#" onclick="javascript:showPlainTxt('c-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-2">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">MediaPlayer.<span style="color: #202020;">IsRepeating</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">MediaPlayer.<span style="color: #202020;">Play</span><span style="color: #66cc66;">&#40;</span>song<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">MediaPlayer.<span style="color: #202020;">Stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Já os efeitos sonoros são utilizados de várias maneiras. Eu estou utilizando uma implementação própria do XNA 3.0, onde podemos instanciar uma classe SoundEffect de maneira similar ao Song. A diferença é que os arquivos devem ser do tipo wave.</p>
<div class="igBar"><span id="lc-3"><a href="#" onclick="javascript:showPlainTxt('c-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-3">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">SoundEffect SFXExplosion = Content.<span style="color: #202020;">Load</span>&lt;SoundEffect&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Sounds<span style="color: #000099; font-weight: bold;">\\</span>explosion"</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Com isso, podemos tocar o som a qualquer momento usando a função Play().</p>
<div class="igBar"><span id="lc-4"><a href="#" onclick="javascript:showPlainTxt('c-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-4">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">SFXExplosion.<span style="color: #202020;">Play</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>O que ocorre neste Play() é criar uma nova instância daquele som e tocá-lo. Se o Play() for chamado várias vezes, vários sons são tocados ao mesmo tempo, em sobreposição. Isso não é muito útil, a não ser em situação em que o som deve ser tocado de maneira independente. Um exemplo disso é quando coletamos moedas no Super Mario.</p>
<p>Mas caso seja preciso tocar somente uma instância do som, usando repetição, aí a figura muda:</p>
<div class="igBar"><span id="lc-5"><a href="#" onclick="javascript:showPlainTxt('c-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-5">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">SoundEffect SFXRocket = Content.<span style="color: #202020;">Load</span>&lt;SoundEffect&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Sounds<span style="color: #000099; font-weight: bold;">\\</span>rocket"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">SoundEffectInstance SFXRocketInstance = Globals.<span style="color: #202020;">SFXRocket</span>.<span style="color: #202020;">CreateInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Com esta instância do som rocket, podemos aplicar loop no som e tocá-lo sem sobreposição de áudio. Ou seja, ao dar um novo Play(), o som corta e começa novamente. Tocando o som a partir da instância ele automaticamente se repete quando chega ao fim. Eu uso isso para ficar repetindo o som do foguete das naves enquanto ele está acionado.</p>
<p>Para tocar o som, basta fazer o seguinte:</p>
<div class="igBar"><span id="lc-6"><a href="#" onclick="javascript:showPlainTxt('c-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-6">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">SFXRocketInstance.<span style="color: #202020;">Play</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><a href="http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-5-mais-scenes/">Parte 5 - Mais Scenes</a><br />
<a href="http://www.cubagames.com.br/criando-um-jogo-em-xna-%E2%80%93-parte-7-%E2%80%93-conclusao/">Parte 7 - Conclusão</a></p>
]]></description>
		<wfw:commentRss>http://www.cubagames.com.br/criando-um-jogo-em-xna-%e2%80%93-parte-6-%e2%80%93-audio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Criando Um Jogo em XNA &#8211; Parte 5 &#8211; Mais Scenes</title>
		<link>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-5-mais-scenes/</link>
		<comments>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-5-mais-scenes/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 16:17:18 +0000</pubDate>
		<dc:creator>Fernando Lorenzon</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[XNA Lander]]></category>

		<guid isPermaLink="false">http://www.cubagames.com.br/?p=1862</guid>
		<description><![CDATA[<p>Continuando a explicar o conceito de Scenes, vimos como o <strong>Game1 </strong>trabalha com as scenes. Vamos agora ver como é a implementação dentro da Scene.</p>
<p>A classe base <strong>Scene</strong> é bastante simples. Ela é uma classe abstrata, o que significa que você não pode utilizá-la diretamente. A única maneira de utilizar é extendendo a classe com o uso de herança. Por quê? Porque nela temos somente a estrutura básica, mas a implementação de cada scene depende do contexto do jogo. Aí sim criamos uma nova classe herdada dela, como por exemplo <strong>SceneTitle</strong> ou <strong>SceneAction</strong>.</p>
<p>Veja o código de <strong>Scene</strong>:<br />
<!--more--></p>
<div class="igBar"><span id="lc-7"><a href="#" onclick="javascript:showPlainTxt('c-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-7">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public abstract class Scene</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public List SpriteList;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public List FontList;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public Color BackgroundColor;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public Scene<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Classes.<span style="color: #202020;">Globals</span>.<span style="color: #202020;">MustLoadContent</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">BackgroundColor</span> = Color.<span style="color: #202020;">Black</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">SpriteList</span> = new List<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">FontList</span> = new List<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public virtual <span style="color: #993333;">void</span> LoadScene<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">LoadSpriteList</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">LoadFontList</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public virtual <span style="color: #993333;">void</span> UnloadScene<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">SpriteList</span> = <span style="color: #000000; font-weight: bold;">null</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">FontList</span> = <span style="color: #000000; font-weight: bold;">null</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public virtual <span style="color: #993333;">void</span> LoadSpriteList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public virtual <span style="color: #993333;">void</span> LoadFontList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public virtual <span style="color: #993333;">void</span> Update<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Como já falei, temos uma lista de fontes e uma lista de sprites. A classe Font assim como Sprite é também uma criação minha, que encapsula coisas mais chatas do framework.</p>
<p>Outra coisa que temos é uma cor de fundo em <strong>BackgroundColor</strong>, que a scene vai armazenar e o <strong>Game1.</strong>Draw() vai utilizar para pintar todo o buffer. Para quem não sabe, antes de pintar sprites na tela, o buffer é todo zerado com uma cor única, para limpar a sujeira toda dos Draws anteriores e começar do zero. Geralmente a cor padrão é preto, mas dependendo da tela você pode usar outra cor. Na tela de partida do jogo eu uso cinza, porque cada pedaço do HUD do jogo fica um pouco afastado do outro e o cinza acaba se destacando entre esses pedaços, simulando uma pequena borda:</p>
<p><a href="http://www.cubagames.com.br/wp-content/uploads/2010/06/borda_de_background.png"><img class="aligncenter size-full wp-image-1865" title="borda_de_background" src="http://www.cubagames.com.br/wp-content/uploads/2010/06/borda_de_background.png" alt="borda_de_background" width="259" height="234" /></a></p>
<p>A bordinha cinza na verdade faz parte do fundo cinza, e sobrou porque todo o resto foi pintado por cima, sobrando somente esses filetes entre os painéis do HUD.</p>
<p>Por padrão eu carrego a cor preta. Mas em qualquer lugar, a qualquer momento é possível trocar a cor.</p>
<p>Uma coisa necessária paar que a scene recém-criada possa ter seus sptires e fontes carregados pelo Game1, eu uso a linha de código no construtor:</p>
<p><strong>Globals.</strong>MustLoadContent = <span style="color: #0000ff;">true</span>;</p>
<p>O <strong>Game1.</strong>Update() verifica o valor e se estiver true, volta para o <strong>Game1.</strong>LoadContent(). Senão, continua fazendo o update:</p>
<div class="igBar"><span id="lc-8"><a href="#" onclick="javascript:showPlainTxt('c-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-8">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">protected override <span style="color: #993333;">void</span> Update<span style="color: #66cc66;">&#40;</span>GameTime gameTime<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Globals.<span style="color: #202020;">CurrentScene</span>.<span style="color: #202020;">Update</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; base.<span style="color: #202020;">Update</span><span style="color: #66cc66;">&#40;</span>gameTime<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>Globals.<span style="color: #202020;">MustLoadContent</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">LoadContent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">Draw</span><span style="color: #66cc66;">&#40;</span>gameTime<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>O que isso significa é que todas as vezes que crio uma nova scene (e imaginando que a utilizarei imediatamente) o jogo vai parar de rodar a scene anterior e carregar novamente os sprites desta nova scene. Assim que tudo carrega, faço isso:</p>
<p><strong>Globals.</strong>MustLoadContent = <span style="color: #0000ff;">false</span>;</p>
<p>Algo tosco e básico, mas altamente inteligível ("entendível"). Não gosto de implementações que usam conceitos avançados de orientação a objeto  porque fica muito difícil de entender o que está acontecendo. Na verdade a orientação a objetos serve justamente para esconder código e facilitar/segmentar o desenvolvimento de sistemas. Aqui a idéia é ser didático, então tudo tem que ser simples.</p>
<p>Veja a implementação completa de SceneTitle, referente à primeira tela do jogo, com o menu principal e o título:</p>
<div class="igBar"><span id="lc-9"><a href="#" onclick="javascript:showPlainTxt('c-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-9">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public class SceneTitle : Scene</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; private Sprite titleScreen;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; private Sprite cursor;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; private Font title;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; private Font arcade;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; private Font freeGame;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; private Font oreCollecting;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; private Font chooseShip;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; private Font currentShip;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; private Font exit;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public SceneTitle<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : base<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public override <span style="color: #993333;">void</span> LoadScene<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; base.<span style="color: #202020;">LoadScene</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Globals.<span style="color: #202020;">SelectedShip</span>.<span style="color: #202020;">X</span> = this.<span style="color: #202020;">currentShip</span>.<span style="color: #202020;">Position</span>.<span style="color: #202020;">X</span> + <span style="color: #cc66cc;color:#800000;">70</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Globals.<span style="color: #202020;">SelectedShip</span>.<span style="color: #202020;">Y</span> = this.<span style="color: #202020;">currentShip</span>.<span style="color: #202020;">Position</span>.<span style="color: #202020;">Y</span> - <span style="color: #cc66cc;color:#800000;">5</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Globals.<span style="color: #202020;">FontInfo1</span>.<span style="color: #202020;">Text</span> = <span style="color: #ff0000;">"Pressione Enter para selecionar"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">gameOptions</span> = <span style="color: #000000; font-weight: bold;">Enum</span>.<span style="color: #202020;">Options</span>.<span style="color: #202020;">Arcade</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public override <span style="color: #993333;">void</span> LoadSpriteList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">titleScreen</span> = new Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">800</span>, <span style="color: #cc66cc;color:#800000;">450</span>, <span style="color: #ff0000;">"Images<span style="color: #000099; font-weight: bold;">\\</span>Menu<span style="color: #000099; font-weight: bold;">\\</span>LunarLander"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">cursor</span> = new Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">16</span>, <span style="color: #cc66cc;color:#800000;">16</span>, <span style="color: #ff0000;">"Images<span style="color: #000099; font-weight: bold;">\\</span>Misc<span style="color: #000099; font-weight: bold;">\\</span>VMenuCursor"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">cursor</span>.<span style="color: #202020;">Y</span> = <span style="color: #cc66cc;color:#800000;">550</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">SpriteList</span> = new System.<span style="color: #202020;">Collections</span>.<span style="color: #202020;">Generic</span>.<span style="color: #202020;">List</span>&lt;Sprite&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">SpriteList</span>.<span style="color: #202020;">Add</span><span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">titleScreen</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">SpriteList</span>.<span style="color: #202020;">Add</span><span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">cursor</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">SpriteList</span>.<span style="color: #202020;">Add</span><span style="color: #66cc66;">&#40;</span>Globals.<span style="color: #202020;">SelectedShip</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public override <span style="color: #993333;">void</span> LoadFontList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">title</span> = new Font<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Fonts<span style="color: #000099; font-weight: bold;">\\</span>Title"</span>, <span style="color: #ff0000;">"XNA Lander"</span>, new Vector2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">270</span>, <span style="color: #cc66cc;color:#800000;">22</span><span style="color: #66cc66;">&#41;</span>, Color.<span style="color: #202020;">Lime</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">arcade</span> = new Font<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Fonts<span style="color: #000099; font-weight: bold;">\\</span>MenuOptions"</span>, <span style="color: #ff0000;">"Arcade"</span>, new Vector2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">10</span>, <span style="color: #cc66cc;color:#800000;">533</span><span style="color: #66cc66;">&#41;</span>, Color.<span style="color: #202020;">Lime</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">freeGame</span> = new Font<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Fonts<span style="color: #000099; font-weight: bold;">\\</span>MenuOptions"</span>, <span style="color: #ff0000;">"Jogo Livre"</span>, new Vector2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">75</span>, <span style="color: #cc66cc;color:#800000;">533</span><span style="color: #66cc66;">&#41;</span>, Color.<span style="color: #202020;">Lime</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">oreCollecting</span> = new Font<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Fonts<span style="color: #000099; font-weight: bold;">\\</span>MenuOptions"</span>, <span style="color: #ff0000;">"Coletar Minério"</span>, new Vector2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">160</span>, <span style="color: #cc66cc;color:#800000;">533</span><span style="color: #66cc66;">&#41;</span>, Color.<span style="color: #202020;">Lime</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">chooseShip</span> = new Font<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Fonts<span style="color: #000099; font-weight: bold;">\\</span>MenuOptions"</span>, <span style="color: #ff0000;">"Escolher Nave"</span>, new Vector2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">275</span>, <span style="color: #cc66cc;color:#800000;">533</span><span style="color: #66cc66;">&#41;</span>, Color.<span style="color: #202020;">Lime</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">exit</span> = new Font<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Fonts<span style="color: #000099; font-weight: bold;">\\</span>MenuOptions"</span>, <span style="color: #ff0000;">"Sair"</span>, new Vector2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">380</span>, <span style="color: #cc66cc;color:#800000;">533</span><span style="color: #66cc66;">&#41;</span>, Color.<span style="color: #202020;">Lime</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">currentShip</span> = new Font<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Fonts<span style="color: #000099; font-weight: bold;">\\</span>MenuOptions"</span>, <span style="color: #ff0000;">"Nave Atual"</span>, new Vector2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">600</span>, <span style="color: #cc66cc;color:#800000;">533</span><span style="color: #66cc66;">&#41;</span>, Color.<span style="color: #202020;">Lime</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">FontList</span> = new System.<span style="color: #202020;">Collections</span>.<span style="color: #202020;">Generic</span>.<span style="color: #202020;">List</span>&lt;Font&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">FontList</span>.<span style="color: #202020;">Add</span><span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">title</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">FontList</span>.<span style="color: #202020;">Add</span><span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">arcade</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">FontList</span>.<span style="color: #202020;">Add</span><span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">freeGame</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">FontList</span>.<span style="color: #202020;">Add</span><span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">oreCollecting</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">FontList</span>.<span style="color: #202020;">Add</span><span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">chooseShip</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">FontList</span>.<span style="color: #202020;">Add</span><span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">currentShip</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">FontList</span>.<span style="color: #202020;">Add</span><span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">exit</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">FontList</span>.<span style="color: #202020;">Add</span><span style="color: #66cc66;">&#40;</span>Globals.<span style="color: #202020;">FontInfo1</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public override <span style="color: #993333;">void</span> Update<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Functions.<span style="color: #202020;">KeyReading</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>Globals.<span style="color: #202020;">EnterKeyPressed</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//entra na opção selecionada</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>Classes.<span style="color: #202020;">Globals</span>.<span style="color: #202020;">RightKeyPressed</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//move o cursor para a direita</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>Classes.<span style="color: #202020;">Globals</span>.<span style="color: #202020;">LeftKeyPressed</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//move o cursor para a esquerda</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><span>Como o código de Update() ficaria muito extenso, eu cortei parte dele, pois aqui o objetivo é entender como implementar uma scene inteira.</span></p>
<p><span>No LoadSpriteList() eu instancio os sprites que utilizarei e adiciono cada um na lista. Faço o mesmo com as fontes no método LoadFontList().</span></p>
<p><span>No caso dos sprites, os 3 únicos utilizados aqui são a figura que ilustra a tela, o cursor de seleção e a figura da nave atualmente selecionada. Como o sprite da nave selecionada eu utilizo durante todo o jogo, eu não preciso declarar este objeto na scene. Eu declaro em <strong>Globals</strong>. Por isso só existem essas duas declarações de sprite:</span></p>
<p><span style="color: #3366ff;">private Sprite titleScreen;<br />
private Sprite cursor;</span></p>
<p>Porém, ao carregar os sprites que serã0 utilizados na scene, eu carrego junto com os dois anteriores o sprite da nave que está lá no Globals:</p>
<p><span style="color: #3366ff;">this.SpriteList.Add(this.titleScreen);<br />
this.SpriteList.Add(this.cursor);<br />
this.SpriteList.Add(Globals.SelectedShip);</span></p>
<p><span style="color: #3366ff;"><span style="color: #000000;">Veja a tela de título:</span></span></p>
<p><span style="color: #3366ff;"><span style="color: #000000;"><a href="http://www.cubagames.com.br/wp-content/uploads/2010/05/xnalander3.jpg"><img class="aligncenter size-full wp-image-1778" title="xnalander" src="http://www.cubagames.com.br/wp-content/uploads/2010/05/xnalander3.jpg" alt="xnalander" width="400" height="310" /></a><br />
</span></span></p>
<p><span style="color: #3366ff;"><span style="color: #000000;">Com isso encerramos este tópico sobre scenes.</span></p>
<p><a href="http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-4-scenes/">Parte 4 - Scenes</a><br />
<a href="http://www.cubagames.com.br/criando-um-jogo-em-xna-%E2%80%93-parte-6-%E2%80%93-audio/">Parte 6 - Audio</a></p>
]]></description>
		<wfw:commentRss>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-5-mais-scenes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Criando Um Jogo em XNA &#8211; Parte 4 &#8211; Scenes</title>
		<link>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-4-scenes/</link>
		<comments>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-4-scenes/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 16:10:43 +0000</pubDate>
		<dc:creator>Fernando Lorenzon</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[Ferramentas]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[XNA Lander]]></category>

		<guid isPermaLink="false">http://www.cubagames.com.br/?p=1787</guid>
		<description><![CDATA[<p style="text-align: justify;">Nesta parte 4, vamos falar de Scenes.</p>
<p style="text-align: justify;">Na implementação de games complexos, algo que percebi na literatura do gênero é a adoção de scenes. Mas o que é uma scene?</p>
<p style="text-align: justify;">Posso dizer que é um bloco de código independente que armazena dados e realiza um conjunto de funções pertinentes apenas àquela parte do jogo atual.</p>
<p style="text-align: justify;">Mas para quê isso?</p>
<p style="text-align: justify;">Com o uso de scenes, você pode separar cada pedaço do jogo em blocos, sendo que apenas um bloco é carregado e executado por vez.</p>
<p style="text-align: justify;">Imagina ter que escrever toda a lógica de update de um game inteiro dentro do  método Update()? Ou  mesmo carregar todas as texturas do jogo inteiro no  LoadContent()? Para um <strong>Asteroids</strong>, tudo bem. Mas imagina um de tamanho razoável como Braid sendo inteiramente escrito dentro de um único arquivo (Game1)?</p>
<p style="text-align: justify;">Certamente ficaria extenso e confuso demais.</p>
<p style="text-align: justify;">É aí que o conceito de Scene é utilizado, pois assim consegue-se separar o código e agrupar toda a lógica de cada tela/fase/cena do jogo em um único lugar, de modo que fique independente do resto e que sejam intercomunicáveis.</p>
<p style="text-align: justify;">Por exemplo, a tela de menu tem toda uma lógica e grupo de gráficos próprios, que o resto do jogo não aproveitará. Aqui podemos agrupar tudo numa Scene. E quando o fluxo principal do jogo vai rodar pela primeira vez, a Scene é invocada e ela passa a comandar o jogo. Já no menu, ao selecionarmos o modo Arcade, a cena de menu chama a cena de jogo (ou da fase 1, dependendo do nível de agrupamento), e o menu "sai de cena".</p>
<p style="text-align: justify;">É um conceito parecido com o teatro ou filme. Cada cena possui um grupo de falas, atuações, objetos, decoração figurantes e atc, que estão independentes do resto de tal maneira que não importa a ordem em que as cenas sejam filmadas. Depois basta rodar cada uma em ordem.</p>
<p style="text-align: justify;">Dentro do desenvolvimento de games, uma scene geralmente é uma classe. Algumas engines já possuem uma implementação padrão para isso. Como o XNA é cru, temos que implementar nosso próprio conceito de scene.</p>
<p style="text-align: justify;">Uma idéia que vi na literatura é criar uma classe que herda de <strong>GameComponent</strong>, pois esta classe possui todos aqueles métodos da classe <strong>Game</strong>, como <em>Update()</em>, <em>LoadContent()</em> e <em>Draw()</em>.</p>
<p style="text-align: justify;">A idéia com isso é que cada scene teria o poder de carregar sprites e renderizá-los sem a intervenção de <strong>Game1</strong>.</p>
<p style="text-align: justify;">Mas quando eu fui tentar implementar isso, não consegui fazer com que o framework utilizasse os métodos corretamente. Por algum motivo, o comando Content.Load&lt;&gt;() usado para carregar textura e áudio não era acessível nestas classes extendidas. Ou seja, ainda não consigo carregar conteúdo fora da classe <strong>Game1</strong>.</p>
<p style="text-align: justify;">Então eu decidi criar minha própria implementação de Scene, que considero ser menos poderosa, mas muito mais simples e fácil de onganizar, pois não depende de usar métodos obscuros do framework e de certa forma faz com que todo o processamento fique dentro de <strong>Game1</strong>, mas a implementação, fora.</p>
<p style="text-align: justify;">Veja abaixo como funciona atualmente o fluxo das scenes no XNA Lander:</p>
<p style="text-align: justify;"><!--more--></p>
<p style="text-align: center;"><a href="http://www.cubagames.com.br/wp-content/uploads/2010/06/scenes2.png"><img class="aligncenter size-full wp-image-1845" title="scenes" src="http://www.cubagames.com.br/wp-content/uploads/2010/06/scenes2.png" alt="scenes" width="464" height="279" /></a> <em>Clique para ampliar</em></p>
<p style="text-align: justify;">
<p style="text-align: justify;">Bem, a idéia geral é que toda a lógica do  jogo seja de alguma forma executada a partir do <strong>Game1</strong>, e assim tudo vai  funcionar bem.</p>
<p style="text-align: justify;">O que eu fiz foi criar uma classe <strong>Scene</strong> contendo o seguinte:</p>
<p style="text-align: justify;">- lista de Sprites;</p>
<p style="text-align: justify;">- lista de Fontes;</p>
<p style="text-align: justify;">- método LoadContent();</p>
<p style="text-align: justify;">- método Update().</p>
<p style="text-align: justify;">Para cada scene usada no jogo, eu crio uma nova classe e herdo de <strong>Scene</strong>. Aí eu declaro todos os sprites que serão utilizados na classe e adiciono na lista. Faço o mesmo com as fontes. Mas só declaro, e não as carrego, pois fora de Game1 eu não consegui. No método LoadContent() eu carrego ou inicializo qualquer outra coisa necessária para aquela scene funcionar (por exemplo, recarregar o combustível nave para uma nova fase caso seja a Scene de jogo).</p>
<p style="text-align: justify;">No método Update() eu escrevo toda a lógica de fluxo de jogo para a Scene. Caso seja a Scene de menu, o Update() ficará lendo as teclas para mover o cursor pelo menu, além de verificar se o jogador pressionou Enter para selecionar a opção desejada.</p>
<p style="text-align: justify;">Com isso, eu carrego a Scene desejada num objeto de visibilidade global (usando <span style="color: #3366ff;">public static</span>) chamada de <strong>CurrentScene</strong>, de modo que <strong>Game1</strong> possa acessá-la. Aí, no método <strong>Game1.</strong>LoadContent(), eu chamo o <strong>CurrentScene</strong>.LoadContent(), e depois eu percorro a lista de sprites e carrego as texturas. No método <strong>Game1.</strong>Update(), invoco o <strong>CurrentScene</strong>.Update(). E no método <strong>Game1.</strong>Draw(), eu percorro a lista de sprites da <strong>CurrentScene </strong>e renderizo em ordem uma a uma. Isso tudo sem o jogo saber qual scene está sendo usada no momento, pois independente de qual seja, ela estará no objeto <strong>CurrentScene</strong>. O <strong>Game1</strong> executa os mesmos passos para qualquer scene carregada. E isso é possível porque todas elas herdam de <strong>Scene</strong> e se comportam de maneira similar. Só seus conteúdos mudam.</p>
<p style="text-align: justify;">Com isso, toda a lógica e sprites/fontes ficam contidos em cada scene, mas seu carregamento e execução ainda ficam  atrelados a <strong>Game1</strong>.</p>
<p style="text-align: justify;">Após colocar isso em prática, basta codificar uma vez o <strong>Game1</strong> e todo o resto do game passa a ser codificado através das <strong>Scenes</strong>.</p>
<p>Veja o void Initialize() do <strong>Game1</strong>:</p>
<div class="igBar"><span id="lc-10"><a href="#" onclick="javascript:showPlainTxt('c-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-10">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">protected override <span style="color: #993333;">void</span> Initialize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; this.<span style="color: #202020;">IsFixedTimeStep</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; this.<span style="color: #202020;">graphics</span>.<span style="color: #202020;">PreferredBackBufferWidth</span> = <span style="color: #cc66cc;color:#800000;">800</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; this.<span style="color: #202020;">graphics</span>.<span style="color: #202020;">PreferredBackBufferHeight</span> = <span style="color: #cc66cc;color:#800000;">600</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; this.<span style="color: #202020;">spriteBatch</span> = new SpriteBatch<span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">GraphicsDevice</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; FunctionsGame.<span style="color: #202020;">LoadGame</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Globals.<span style="color: #202020;">CurrentScene</span> = new SceneTitle<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; base.<span style="color: #202020;">Initialize</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Este código acima só rodará uma vez durante a execução de todo o game. Nada impede que você chame depois o método, entretanto. Então eu aproveito para carregar a primeira scene do jogo, que é a SceneTitle(), da tela de título e menu principal.</p>
<p>Vamos para o LoadContent():</p>
<div class="igBar"><span id="lc-11"><a href="#" onclick="javascript:showPlainTxt('c-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-11">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">protected override <span style="color: #993333;">void</span> LoadContent<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Globals.<span style="color: #202020;">CurrentScene</span>.<span style="color: #202020;">LoadScene</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; foreach <span style="color: #66cc66;">&#40;</span>Classes.<span style="color: #202020;">Sprite</span> sprite in Globals.<span style="color: #202020;">CurrentScene</span>.<span style="color: #202020;">SpriteList</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; sprite.<span style="color: #202020;">Texture</span> = Content.<span style="color: #202020;">Load</span>&lt;Texture2D&gt;<span style="color: #66cc66;">&#40;</span>sprite.<span style="color: #202020;">TexturesPath</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; foreach <span style="color: #66cc66;">&#40;</span>Classes.<span style="color: #202020;">Font</span> font in Globals.<span style="color: #202020;">CurrentScene</span>.<span style="color: #202020;">FontList</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; font.<span style="color: #202020;">SpriteFont</span> = Content.<span style="color: #202020;">Load</span>&lt;SpriteFont&gt;<span style="color: #66cc66;">&#40;</span>font.<span style="color: #202020;">SpriteFontPath</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Globals.<span style="color: #202020;">MustLoadContent</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Aqui no LoadContent()  eu chamo o CurrentScene.LoadScene(), que pode ter qualquer carregamento que não seja gráfico.</p>
<p>Para carregar os sprites eu percorro a lista de sprites que carrego na Scene. Como não sei quais são os sprites a serem carregados, basta jogar todos eles na lista. Assim eu percorro ela carregando um por um. Faço o mesmo com as fontes também.</p>
<p>Vejamos o void Update():</p>
<div class="igBar"><span id="lc-12"><a href="#" onclick="javascript:showPlainTxt('c-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-12">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">protected override <span style="color: #993333;">void</span> Update<span style="color: #66cc66;">&#40;</span>GameTime gameTime<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Globals.<span style="color: #202020;">CurrentScene</span>.<span style="color: #202020;">Update</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; base.<span style="color: #202020;">Update</span><span style="color: #66cc66;">&#40;</span>gameTime<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>Globals.<span style="color: #202020;">MustLoadContent</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">LoadContent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">Draw</span><span style="color: #66cc66;">&#40;</span>gameTime<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Veja que aqui eu chamo o Update() que está no scene. Outra coisa que faço é verificar se devo chamar novamente o Game1.LoadContent(). Mas quando isso acontece? Simples, devo chamar sempre um LoadContent() quando carrego uma nova Scene. Assim que carrego qualquer scene, mudo um boolean <span style="text-decoration: underline;">Globals.MustLoadContent</span> para true e o update volta novamente para o processo anterior, de carregamento dos sprites, para carregar os novos sprites da scene recém-carregada.</p>
<p>No Draw(), continua tudo tranquilo:</p>
<div class="igBar"><span id="lc-13"><a href="#" onclick="javascript:showPlainTxt('c-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-13">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">protected override <span style="color: #993333;">void</span> Draw<span style="color: #66cc66;">&#40;</span>GameTime gameTime<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; this.<span style="color: #202020;">GraphicsDevice</span>.<span style="color: #202020;">Clear</span><span style="color: #66cc66;">&#40;</span>Globals.<span style="color: #202020;">CurrentScene</span>.<span style="color: #202020;">BackgroundColor</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; spriteBatch.<span style="color: #202020;">Begin</span><span style="color: #66cc66;">&#40;</span>SpriteBlendMode.<span style="color: #202020;">AlphaBlend</span>, SpriteSortMode.<span style="color: #202020;">Immediate</span>, SaveStateMode.<span style="color: #202020;">SaveState</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; foreach <span style="color: #66cc66;">&#40;</span>Sprite sprite in Globals.<span style="color: #202020;">CurrentScene</span>.<span style="color: #202020;">SpriteList</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>sprite.<span style="color: #202020;">Visible</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; spriteBatch.<span style="color: #202020;">Draw</span><span style="color: #66cc66;">&#40;</span>sprite.<span style="color: #202020;">TextureCurrent</span>, sprite.<span style="color: #202020;">Rectangle</span>, sprite.<span style="color: #202020;">Color</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; spriteBatch.<span style="color: #202020;">End</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; spriteBatch.<span style="color: #202020;">Begin</span><span style="color: #66cc66;">&#40;</span>SpriteBlendMode.<span style="color: #202020;">AlphaBlend</span>, SpriteSortMode.<span style="color: #202020;">FrontToBack</span>, SaveStateMode.<span style="color: #202020;">SaveState</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; foreach <span style="color: #66cc66;">&#40;</span>Font font in Globals.<span style="color: #202020;">CurrentScene</span>.<span style="color: #202020;">FontList</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>font.<span style="color: #202020;">Visible</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; spriteBatch.<span style="color: #202020;">DrawString</span><span style="color: #66cc66;">&#40;</span>font.<span style="color: #202020;">SpriteFont</span>, font.<span style="color: #202020;">Text</span>, font.<span style="color: #202020;">Position</span>, font.<span style="color: #202020;">Color</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; spriteBatch.<span style="color: #202020;">End</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; base.<span style="color: #202020;">Draw</span><span style="color: #66cc66;">&#40;</span>gameTime<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Veja que eu não renderizo o sprite ou font quando o <span style="text-decoration: underline;">Visible</span> está como <span style="color: #0000ff;">false</span>. O resto é só renderizar cada sprite na lista da Scene carregada.</p>
<p>Aqui eu mostrei mais como o jogo invoca e usa as scenes, mas não expliquei a implementação de cada Scene internamente. No próximo post eu falo mais sobre isso, inclusive com exemplos de código.</p>
<p style="text-align: justify;"><a href="http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-3-codificacao-basica/">Parte 3 - Codificação Básica</a><br />
<a href="http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-5-mais-scenes/">Parte 5 - Mais Scenes</a></p>
]]></description>
		<wfw:commentRss>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-4-scenes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Criando Um Jogo em XNA &#8211; Parte 3 &#8211; Codificação Básica</title>
		<link>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-3-codificacao-basica/</link>
		<comments>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-3-codificacao-basica/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 01:07:27 +0000</pubDate>
		<dc:creator>Fernando Lorenzon</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[XNA Lander]]></category>

		<guid isPermaLink="false">http://www.cubagames.com.br/?p=1815</guid>
		<description><![CDATA[<p>Partindo da <a href="http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-2-nocoes-basicas">parte 2</a>, na classe <strong>Game1</strong> que herda de <strong>Game</strong> é possível escrever todo o código do jogo.</p>
<p>Aqui já podemos ser mais práticos. Crie um projeto XNA limpo e abra a classe <strong>Game1</strong>.</p>
<p>O que vemos nela é aquilo explicado no post da parte 2.</p>
<p>Para fazer um <span style="text-decoration: underline;">sprite</span> se mover na tela, precisamos criar um <strong>Rectangle</strong>, um <strong>Texture2D </strong>e um <strong>KeyboardState</strong>.</p>
<p>Para começar, vamos criar uma textura. Crie ou pegue uma figura qualquer em png ou jpg e renomeie como "quadrado.png" (ou .jpg).</p>
<p>Se quiser, use esta figura:</p>
<p style="text-align: center;"><a href="http://www.cubagames.com.br/wp-content/uploads/2010/06/quadrado.png"><img class="size-full wp-image-1816  aligncenter" title="quadrado" src="http://www.cubagames.com.br/wp-content/uploads/2010/06/quadrado.png" alt="quadrado" width="50" height="50" /></a></p>
<p>Agora clique com o botão direito na pasta <span style="text-decoration: underline;">Content</span> pelo Solution Explorer do Visual Studio e selecione <em>Add &gt;&gt; Existing Item</em>:</p>
<p style="text-align: center;"><a href="http://www.cubagames.com.br/wp-content/uploads/2010/06/add_content.png"><img class="size-full wp-image-1825  aligncenter" title="add_content" src="http://www.cubagames.com.br/wp-content/uploads/2010/06/add_content.png" alt="add_content" width="420" height="316" /></a></p>
<p style="text-align: left;">Selecione o quadrado que você acabou de salvar.</p>
<p style="text-align: left;">Vamos ao código:</p>
<p style="text-align: left;"><!--more--></p>
<p>Lá no início da declaração da classe encontram-se dois objetos declarados:</p>
<p><strong>GraphicsDeviceManager</strong> graphics;<br />
<strong>SpriteBatch</strong> spriteBatch;</p>
<p>O GraphicsDeviceManager é usado pelo framework e até agora só vi ser utilizado para ajustar a resolução da tela. O SpriteBatch é utilizado para renderizar sprites na tela, dentro do método <em>Draw()</em>.</p>
<p>Vamos criar os objetos. Abaixo da declaração dos objetos que citei acima, digite o seguinte:</p>
<p><strong>Rectangle </strong>rectangle;<br />
<strong>Texture2D </strong>texture;<br />
<strong>KeyboardState</strong> keyboardState;</p>
<p>Agora temos que carregar cada objeto. O <span style="text-decoration: underline;">rectangle</span> pode ser instanciado no método <strong>Initialize()</strong>:</p>
<p><span style="color: #0000ff;">this.rectangle = new Rectangle(300, 300, 50, 50);</span></p>
<p>Os números do parâmetro são respectivamente: Posição X, Posição Y, Largura, Altura. Ou seja, estou criando um quadrado com 50 pixels de lado posicionado mais ou menos no meio da tela.</p>
<p>A textura <span style="text-decoration: underline;">texture</span> pode ser carregada dentro do método <strong>LoadContent()</strong>:</p>
<p><span style="color: #0000ff;">this.texture = Content.Load&lt;Texture2D&gt;("quadrado");</span></p>
<p>Note que o comando <strong>Content.Load</strong> deve receber como tipo (&lt;Type&gt;) a classe correspondente ao conteúdo audiovisual a ser carregado. No caso, se trata de uma textura 2D. Como parâmetro, deve receber o path a partir do <span style="text-decoration: underline;">Content</span> + o nome do arquivo SEM a extensão! No caso, se você tivesse criado uma pasta dentro de <span style="text-decoration: underline;">Content</span> chamada <span style="text-decoration: underline;">Imagens</span> e colocasse a figura dentro, então a maneira correta para carregar seria:</p>
<p><span style="color: #3366ff;">this.texture  = Content.Load&lt;Texture2D&gt;("Imagens/quadrado");</span></p>
<p>Agora temos que fazer o quadrado se mover pela tela conforme o usuário pressiona as setas do teclado. Para isso, vamos escrever o seguinte no método <strong>Update()</strong>:</p>
<p><span style="color: #0000ff;"> this.keyboardState = Keyboard.GetState();</span></p>
<p><span style="color: #0000ff;">if (this.keyboardState.IsKeyDown(Keys.Up))<br />
{<br />
this.rectangle.Y--;<br />
}</span></p>
<p><span style="color: #0000ff;">if (this.keyboardState.IsKeyDown(Keys.Down))<br />
{<br />
this.rectangle.Y++;<br />
}</span></p>
<p><span style="color: #0000ff;">if (this.keyboardState.IsKeyDown(Keys.Left))<br />
{<br />
this.rectangle.X--;<br />
}</span></p>
<p><span style="color: #0000ff;">if (this.keyboardState.IsKeyDown(Keys.Right))<br />
{<br />
this.rectangle.X++;<br />
}</span></p>
<p>O que estou fazendo é a cada Update obter o estado do teclado para verificar quais teclas estavam pressionadas naquele momento. Para isso, devemos carregar o objeto <span style="text-decoration: underline;">keyboardState</span> com o método <strong>Keyboard.GetState()</strong>.</p>
<p>Aí é só verificar se a seta está pressionada e dependendo da direção, incrementar ou decrementar o X ou o Y daquele quadrado.</p>
<p>Por último, falta renderizar o quadrado na tela. Para isso, escreva o seguinte dentro do método <strong>Draw()</strong>:</p>
<p><span style="color: #0000ff;"> this.spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.SaveState);<br />
this.spriteBatch.Draw(this.texture, this.rectangle, Color.White);<br />
this.spriteBatch.End();</span></p>
<p>O que estamos fazendo acima é iniciando a renderização com o <span style="color: #0000ff;">spriteBatch.Begin</span>, renderizando com <span style="color: #0000ff;">spriteBatch.Draw</span> e finalizando com <span style="color: #0000ff;">spriteBatch.End</span>. Só depois do end algo aparecerá na tela.</p>
<p>O que o método <span style="color: #0000ff;">spriteBatch.Draw</span> recebe é a textura a ser renderizada, o quadrado que receberá a textura e a cor da textura. Se você quiser manter a cor original, use a cor<span style="color: #0000ff;"> White</span>. Rode e veja se o quadrado se move. Eis o código completo de <strong>Game1</strong>:</p>
<div class="igBar"><span id="lc-14"><a href="#" onclick="javascript:showPlainTxt('c-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-14">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">using System;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">using System.<span style="color: #202020;">Collections</span>.<span style="color: #202020;">Generic</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">using System.<span style="color: #202020;">Linq</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">using Microsoft.<span style="color: #202020;">Xna</span>.<span style="color: #202020;">Framework</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">using Microsoft.<span style="color: #202020;">Xna</span>.<span style="color: #202020;">Framework</span>.<span style="color: #202020;">Audio</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">using Microsoft.<span style="color: #202020;">Xna</span>.<span style="color: #202020;">Framework</span>.<span style="color: #202020;">Content</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">using Microsoft.<span style="color: #202020;">Xna</span>.<span style="color: #202020;">Framework</span>.<span style="color: #202020;">GamerServices</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">using Microsoft.<span style="color: #202020;">Xna</span>.<span style="color: #202020;">Framework</span>.<span style="color: #202020;">Graphics</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">using Microsoft.<span style="color: #202020;">Xna</span>.<span style="color: #202020;">Framework</span>.<span style="color: #202020;">Input</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">using Microsoft.<span style="color: #202020;">Xna</span>.<span style="color: #202020;">Framework</span>.<span style="color: #202020;">Media</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">using Microsoft.<span style="color: #202020;">Xna</span>.<span style="color: #202020;">Framework</span>.<span style="color: #202020;">Net</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">using Microsoft.<span style="color: #202020;">Xna</span>.<span style="color: #202020;">Framework</span>.<span style="color: #202020;">Storage</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">namespace WindowsGame3</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public class Game1 : Microsoft.<span style="color: #202020;">Xna</span>.<span style="color: #202020;">Framework</span>.<span style="color: #202020;">Game</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; GraphicsDeviceManager graphics;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; SpriteBatch spriteBatch;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Rectangle rectangle;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Texture2D texture;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; KeyboardState keyboardState;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; public Game1<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; graphics = new GraphicsDeviceManager<span style="color: #66cc66;">&#40;</span>this<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Content.<span style="color: #202020;">RootDirectory</span> = <span style="color: #ff0000;">"Content"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; protected override <span style="color: #993333;">void</span> Initialize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">rectangle</span> = new Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">300</span>, <span style="color: #cc66cc;color:#800000;">300</span>, <span style="color: #cc66cc;color:#800000;">50</span>, <span style="color: #cc66cc;color:#800000;">50</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; base.<span style="color: #202020;">Initialize</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; protected override <span style="color: #993333;">void</span> LoadContent<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; spriteBatch = new SpriteBatch<span style="color: #66cc66;">&#40;</span>GraphicsDevice<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">texture</span> = Content.<span style="color: #202020;">Load</span>&lt;Texture2D&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"quadrado"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; protected override <span style="color: #993333;">void</span> UnloadContent<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; protected override <span style="color: #993333;">void</span> Update<span style="color: #66cc66;">&#40;</span>GameTime gameTime<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>GamePad.<span style="color: #202020;">GetState</span><span style="color: #66cc66;">&#40;</span>PlayerIndex.<span style="color: #202020;">One</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #202020;">Buttons</span>.<span style="color: #202020;">Back</span> == ButtonState.<span style="color: #202020;">Pressed</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">Exit</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">keyboardState</span> = Keyboard.<span style="color: #202020;">GetState</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">keyboardState</span>.<span style="color: #202020;">IsKeyDown</span><span style="color: #66cc66;">&#40;</span>Keys.<span style="color: #202020;">Up</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">rectangle</span>.<span style="color: #202020;">Y</span>--;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">keyboardState</span>.<span style="color: #202020;">IsKeyDown</span><span style="color: #66cc66;">&#40;</span>Keys.<span style="color: #202020;">Down</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">rectangle</span>.<span style="color: #202020;">Y</span>++;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">keyboardState</span>.<span style="color: #202020;">IsKeyDown</span><span style="color: #66cc66;">&#40;</span>Keys.<span style="color: #202020;">Left</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">rectangle</span>.<span style="color: #202020;">X</span>--;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">keyboardState</span>.<span style="color: #202020;">IsKeyDown</span><span style="color: #66cc66;">&#40;</span>Keys.<span style="color: #202020;">Right</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">rectangle</span>.<span style="color: #202020;">X</span>++;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; base.<span style="color: #202020;">Update</span><span style="color: #66cc66;">&#40;</span>gameTime<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; protected override <span style="color: #993333;">void</span> Draw<span style="color: #66cc66;">&#40;</span>GameTime gameTime<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GraphicsDevice.<span style="color: #202020;">Clear</span><span style="color: #66cc66;">&#40;</span>Color.<span style="color: #202020;">CornflowerBlue</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">spriteBatch</span>.<span style="color: #202020;">Begin</span><span style="color: #66cc66;">&#40;</span>SpriteBlendMode.<span style="color: #202020;">AlphaBlend</span>, SpriteSortMode.<span style="color: #202020;">BackToFront</span>, SaveStateMode.<span style="color: #202020;">SaveState</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">spriteBatch</span>.<span style="color: #202020;">Draw</span><span style="color: #66cc66;">&#40;</span>this.<span style="color: #202020;">texture</span>, this.<span style="color: #202020;">rectangle</span>, Color.<span style="color: #202020;">Blue</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.<span style="color: #202020;">spriteBatch</span>.<span style="color: #202020;">End</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; base.<span style="color: #202020;">Draw</span><span style="color: #66cc66;">&#40;</span>gameTime<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><a href="http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-2-nocoes-basicas/">Parte  2 - Noções Básicas</a><br />
<a href="http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-4-scenes/">Parte 4 - Scenes</a></p>
]]></description>
		<wfw:commentRss>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-3-codificacao-basica/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Criando Um Jogo em XNA &#8211; Parte 2 &#8211; Noções Básicas</title>
		<link>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-2-nocoes-basicas/</link>
		<comments>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-2-nocoes-basicas/#comments</comments>
		<pubDate>Thu, 27 May 2010 16:00:24 +0000</pubDate>
		<dc:creator>Fernando Lorenzon</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[XNA Lander]]></category>

		<guid isPermaLink="false">http://www.cubagames.com.br/?p=1783</guid>
		<description><![CDATA[<p>Neste post vamos falar um pouco mais sobre desenvolvimento em XNA.</p>
<p>Com Visual Studio e o framework instalados, abra o Visual Studio e clique m File &gt;&gt; New Project.</p>
<p>Então escolha um projeto do tipo XNA Game Studio 3.1:</p>
<p style="text-align: center;"><a href="http://www.cubagames.com.br/wp-content/uploads/2010/05/projeto_xna.jpg"><img class="size-full wp-image-1784  aligncenter" title="projeto_xna" src="http://www.cubagames.com.br/wp-content/uploads/2010/05/projeto_xna.jpg" alt="projeto_xna" width="367" height="371" /></a></p>
<p>Dê um nome para o projeto e clique em OK.</p>
<p>O Visual Studio vai abrir o projeto e já vai ter criado para você um arquivo chamado <strong>Game1</strong>.</p>
<p>Este arquivo é uma classe que herda da classe <strong>Game</strong>.</p>
<p>É neste arquivo que toda mágica acontece. A thread principal do jogo funciona atrelado a ela. Enquanto eu desenvolvia, tentei criar outras classes herdando de <strong>Game</strong>, mas cada uma fica presa na thread principal e não é possível alternar a execução entre elas. Pelo menos eu não consegui.</p>
<p>A classe <strong>Game1</strong> começa com 5 funções criadas:</p>
<p>- void Initialize();<br />
- void LoadContent();<br />
- void UnloadContent();<br />
- void Update(GameTime gameTime);<br />
- void Draw(GameTime gameTime).</p>
<p>Cada uma delas deve ser usada apropriadamente para que o jogo funcione corretamente. Mas nada impede que você as invoque a qualquer momento. Eu mesmo tive alguns problemas em que a função Draw não era invocada quando necessário, e eu simplesmente comecei a invocá-la explicitamente.</p>
<p><strong>void Initialize()</strong></p>
<p>Neste método, você deve escrever todo o código de inicialização do jogo. Esta função roda somente na primeira execução do jogo. Para quem programa <em>web client</em> ou <em>windows forms</em>, isso seria o equivalente ao <em>form_load()</em>.</p>
<p>Aqui poderemos informar a taxa de FPS pretendida no jogo, carregar a tela principal, inicializar as variáveis globais do jogo e etc.</p>
<p><strong>void LoadContent()</strong></p>
<p>Este método é responsável por carregar todo conteúdo audiovisual do jogo. A chamada deste método pode ocorrer várias vezes durante a execução do programa.</p>
<p>No próprio projeto criado, existe um diretório do projeto chamado Content, onde todo o conteúdo externo usado no jogo deve ser guardado para ser carregado apropriadamente.</p>
<p><strong>void UnloadContent()</strong></p>
<p>Aqui você pode escrever código para descarregar variáveis do jogo bem como tirar da memória o conteúdo gráfico. Como o jogo roda em .Net e este possui coletor de lixo automático, dependendo da sua implementação do jogo, este método é inútil.</p>
<p><strong>void Update()</strong></p>
<p>Método principal onde o fluxo de jogo ocorre. É este método que é chamado 60 vezes por segundo. Toda a lógica da partida do jogo ou de qualquer outra tela dinâmica deve chamada por aqui, pois o próprio jogo se encarrega de disparar este método de acordo com as configurações do FPS.</p>
<p><strong>void Draw()</strong></p>
<p>Aqui é onde o conteúdo gráfico é renderizado. Entenda conteúdo gráfico como texturas e fontes de texto.</p>
<p><!--more--></p>
<p>----</p>
<p>Então, não é necessário usar estes métodos exatamente como descrito. É perfeitamente possível carregar conteúdo gráfico no Update(), bem como botar lógica de jogo no Draw(). A idéia é que o framework saberia o momento certo de invocar automaticamente cada um destes métodos e encadear a execução com métodos de outras classes herdadas de <strong>GameComponent</strong> , que possui estes métodos também.</p>
<p>Para começar a desenvolver o jogo, precisamos aprender a usar sprites, que são os gráficos 2D.</p>
<p>Para renderizar alguma coisa 2D na tela, é necessário um <strong>Rectangle</strong> e um <strong>Texture2D</strong>.</p>
<p><strong>Rectangle</strong> é uma classe que representa um retângulo simples e invisível. Você consegue mover o rectangle alterando seus valores X e Y. E também consegue alterar seu tamanho através dos atributos <strong>Width</strong> e <strong>Height</strong>. É a partir dele que teremos o controle de colisão e aplicação de física.</p>
<p>O <strong>Texture2D</strong> é uma figura ou mesmo um array de cores (que não deixa de ser uma figura). O Texture2D é visível, porém, não se move nem muda o tamanho.</p>
<p>Para renderizar a textura (no método Draw), é necessário informar um retângulo em que ela será impressa. Como o retângulo muda de posição e de tamanho, a textura sendo constantmente aplicada em cima dele acada se movendo e mudando o tamanho por consequência. Ou seja, o destino de uma textura será sempre um retângulo. Então, se mudarmos a posição deste ao longo do jogo, o que veremos na prática é a textura se movendo.</p>
<p>Como podem ver, é tudo muito básico, simples e cru.</p>
<p>Para tudo isso ficar mais fácil, seria interessante ter uma classe <strong>Sprite</strong> que tivesse um Rectangle e um Texture2D como atributos. Como eu já tinha esta classe do jogo anterior, eu só tive que mudar o PictureBox para Rectangle e Image para Texture2D.</p>
<p>Para incrementar, podemos criar uma <span style="text-decoration: underline;">Property</span> <strong>X</strong> na classe <strong>Sprite</strong> em que o <span style="color: #0000ff;">get</span> retorne o Rectangle.X e o <span style="color: #0000ff;">set</span> aplica o valor ao Rectangle.X.</p>
<p>Podemos fazer isso para o <strong>Y</strong> também, lógico.</p>
<p>Assim, teremos uma classe Sprite com seu retângulo, sua textura, e sua posição no plano 2D do jogo.</p>
<div class="igBar"><span id="lc-15"><a href="#" onclick="javascript:showPlainTxt('c-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-15">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public class Sprite</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; private <span style="color: #993333;">float</span> x, y;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public Rectangle Rectangle;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public Texture2D Texture;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color: #993333;">float</span> X</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; get <span style="color: #66cc66;">&#123;</span> <span style="color: #b1b100;">return</span> this.<span style="color: #202020;">x</span>; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #66cc66;">&#123;</span> this.<span style="color: #202020;">x</span> = value; this.<span style="color: #202020;">Rectangle</span>.<span style="color: #202020;">X</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>value; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color: #993333;">float</span> Y</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; get <span style="color: #66cc66;">&#123;</span> <span style="color: #b1b100;">return</span> this.<span style="color: #202020;">y</span>; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #66cc66;">&#123;</span> this.<span style="color: #202020;">y</span> = value; this.<span style="color: #202020;">Rectangle</span>.<span style="color: #202020;">Y</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>value; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color: #993333;">int</span> Height</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; get <span style="color: #66cc66;">&#123;</span> <span style="color: #b1b100;">return</span> this.<span style="color: #202020;">Rectangle</span>.<span style="color: #202020;">Height</span>; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #66cc66;">&#123;</span> this.<span style="color: #202020;">Rectangle</span>.<span style="color: #202020;">Height</span> = value; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color: #993333;">int</span> Width</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; get <span style="color: #66cc66;">&#123;</span> <span style="color: #b1b100;">return</span> this.<span style="color: #202020;">Rectangle</span>.<span style="color: #202020;">Width</span>; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #66cc66;">&#123;</span> this.<span style="color: #202020;">Rectangle</span>.<span style="color: #202020;">Width</span> = value; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><a href="http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-1/">Parte 1 - Introdução</a><br />
<a href="http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-3-codificacao-basica//">Parte 3 - Codificação Básica</a></p>
]]></description>
		<wfw:commentRss>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-2-nocoes-basicas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Criando Um Jogo em XNA &#8211; Parte 1</title>
		<link>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-1/</link>
		<comments>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-1/#comments</comments>
		<pubDate>Tue, 25 May 2010 13:54:13 +0000</pubDate>
		<dc:creator>Fernando Lorenzon</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[XNA Lander]]></category>

		<guid isPermaLink="false">http://www.cubagames.com.br/?p=1774</guid>
		<description><![CDATA[<p style="text-align: center;"><a href="http://www.cubagames.com.br/wp-content/uploads/2010/05/xnalander3.jpg"><img class="size-full wp-image-1778 alignnone" title="xnalander" src="http://www.cubagames.com.br/wp-content/uploads/2010/05/xnalander3.jpg" alt="xnalander" width="400" height="310" /></a></p>
<p style="text-align: justify;">Enfim, depois de algum tempinho e de alguns problemas, estamos de volta. E nada melhor que voltarmos aos nossos posts sobre desenvolvimento (pra alguns, talvez não).</p>
<p style="text-align: justify;">Como fazer seu próprio jogo? Nesta série explicarei como criar um jogo usando XNA. No final dos posts da série eu disponibilizarei todo o código fonte bem como o jogo pronto para jogar.</p>
<p style="text-align: justify;">Lembram-se do WinForms Lander, o <a href="http://www.cubagames.com.br/criando-um-jogo-em-windowsforms-parte-1/">jogo feito em Windows Forms</a> que expliquei aqui há alguns meses?</p>
<p style="text-align: justify;">Na época eu havia tentando fazer um jogo usando ferramentas que não eram exatamente para este fim, mas que eu dominava bem. Ao longo dos 7 posts, eu expliquei um pouco sobre o desenvolvimento de um jogo de modo geral, passando pelos comandos, fluxos de update, colisão e etc. Quem não viu, eu recomendo muitíssimo a leitura, disponível ali no link acima.</p>
<p style="text-align: justify;">Em algum momento eu mencionei que no futuro eu faria o game totalmente em XNA.</p>
<p style="text-align: justify;">Há algumas semanas eu estou fazendo isso e o jogo está quase 100% convertido, permitindo assim que eu inicie uma nova série de posts sobre desenvolvimento em XNA.</p>
<p style="text-align: justify;">Como o básico eu já expliquei nos posts anteriores, nesta série vou focar mais na tecnologia do XNA que em desenvolvimento de games de modo geral. Lembrando que este não é um guia de como fazer um jogo do início ao fim, nem sobre XNA avançado. Já existem muitos blogs por aí postando sobre XNA e eu não vou competir com eles. Minha idéia será mostrar alguns problemas de desenvolvimento que eu tive bem como as soluções que adotei para resolvê-los.</p>
<p style="text-align: justify;">Para começar, quem quiser de alguma forma acompanhar terá que baixar o Visual Studio 2008 ou 2010 e o <a href="http://www.microsoft.com/downloads/details.aspx?familyid=80782277-d584-42d2-8024-893fcd9d3e82&amp;displaylang=en">XNA 3.1</a>.</p>
<p style="text-align: justify;">Vamos falar um pouco do XNA. O que é XNA? É um framework de desenvolvimento de games. E o que isso significa? Bem, no contexto de desenvolvimento de sistemas, um framework é um conjunto de bibliotecas e estruturas de dados que juntas direcionam ou mesmo forçam o desenvolvedor a codificar de uma determinada maneira. Se você usar o framework à risca, ganhará muita produtividade, mas como todo framework, há alguma limitações em que você certamente esbarrará.</p>
<p style="text-align: justify;">O XNA não é a melhor ferramenta do mundo para desenvolver grandes games, mas também não é paga, o que é uma grande vantagem. O legal é que o XNA usa o Visual Studio e a linguagem de programação C#, que são consideradas juntas a melhor e mais produtiva ferramenta de desenvolvimento de grandes aplicações hoje em dia por muita gente (eu incluso). Principalmente se considerar o uso de interfaces gráficas. Isso tudo está ao alcance de você ao criar seu game usando XNA. A Microsoft é f*da!!</p>
<p style="text-align: justify;">Porém, mesmo usando o Visual Studio, você definitivamente não usará nenhum tipo de auxílio visual para construir cenários e layouts de tela em geral. Tudo deve ser feito via código.</p>
<p style="text-align: justify;">Aqui foi onde eu mais sofri nesta migração do <strong>WinForms Lander</strong>. Transformá-lo no <strong>XNA Lander</strong> significou deixar de lado toda a facilidade de construir telas do Visual Studio e substituir tudo por sprites posicionados na mão, passando o X,Y de cada um e fazendo ajustes às cegas, para então executar o game e ver como ficou o layout.</p>
<p style="text-align: justify;">Nesta parte não tem muito o que chorar mesmo, pois ajustar o layout é relativamente rápido em comparação com desenvolver o resto do game.</p>
<p style="text-align: justify;">Como eu já tinha os fontes do jogo original, aproveitei todo o código de cálculo de física bem como a maioria das classes. Só precisei reescrever os layouts e as chamadas para cada tela, pois no XNA as coisas mudam muito na maneira como você carrega conteúdo na tela e os renderiza.</p>
<p style="text-align: justify;">Usando o XNA, a coisa que eu notei mais rapidamente foi o ganho em performance com relação à versão antiga do game. Pois Windows Forms é usado primariamente para exibir telas estáticas. Mas pelo que eu vejo por aí, o XNA não é mais rápido que as grandes engines comerciais, como a Unreal Engine ou a Unity. Portanto, se você almeja fazer o novo World of Warcraft killer, esteja avisado <img src='http://www.cubagames.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (toda salsinha quer fazer um WoW). Querem uma dica, comecem tentando fazer um Pong ou mesmo Tetris.</p>
<p style="text-align: justify;">Bem, o intuito deste port para XNA é de apenas conhecer melhor a ferramenta, e assim que o jogo estiver pronto e fiel à versão em Windows Forms, vou começar a criar a versão melhorada, com recursos adicionais, como cenários de fundo, sons melhores, mais missões e tudo o que o XNA permitir e eu conseguir fazer.</p>
<p style="text-align: justify;">Por hoje é só. Aguardem a parte 2 com alguns códigos e uma visão geral das classes do XNA.</p>
<p><a href="http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-2-nocoes-basicas/">Parte 2 - Noções Básicas</a></p>
]]></description>
		<wfw:commentRss>http://www.cubagames.com.br/criando-um-jogo-em-xna-parte-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Criando Um Jogo em Windows Forms &#8211; Parte 7 &#8211; Final</title>
		<link>http://www.cubagames.com.br/criando-um-jogo-em-windows-forms-parte-7-final/</link>
		<comments>http://www.cubagames.com.br/criando-um-jogo-em-windows-forms-parte-7-final/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 03:01:39 +0000</pubDate>
		<dc:creator>Fernando Lorenzon</dc:creator>
				<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Jogos]]></category>
		<category><![CDATA[Windows Forms]]></category>
		<category><![CDATA[WinForms Lander]]></category>

		<guid isPermaLink="false">http://www.cubagames.com.br/?p=1587</guid>
		<description><![CDATA[<p style="text-align: center;"><a href="http://www.cubagames.com.br/wp-content/uploads/2010/02/winformslander.jpg"><img class="size-full wp-image-1590   alignnone" title="winformslander" src="http://www.cubagames.com.br/wp-content/uploads/2010/02/winformslander.jpg" alt="winformslander" width="462" height="336" /></a><br />
<em>Clique para ampliar</em></p>
<p style="text-align: justify;">Depois de algum tempo, termino esta série. A idéia desde o início era simplesmente explicar o básico sobre desenvolvimento de games conforme eu fosse aprendendo. Desde o primeiro post, o jogo <strong>WinForms Lander</strong> já estava praticamente completo. E claro, como nem todos gostam de ler posts técnicos, fui alternando os posts com posts padrão deste blog. Por isso a série demorou para acabar. Mesmo assim, recomendo muitíssimo a todos a leitura dos posts anteriores, pois eu tentei ser bastante didático e teórico, não se prendendo somente em códigos. Acredito que os textos tenham ficados bem agradáveis e com conteúdo interessante. Mesmo se você não quer desenvolver.</p>
<p style="text-align: justify;">Leiam o restante para acessar os downloads:</p>
<p style="text-align: justify;"><!--more-->Ao longo do desenvolvimento, fui tomando algumas decisões de design e alterando coisas. A principal alteração foi o uso de código 100% nativo para leitura de teclas. Agora não é mais necessário usar aquela dll do XNA para isso. O código eu achei na internet e mantive intacto, junto com o comentário que identifica o autor.</p>
<p style="text-align: justify;">Outra coisa foi o uso de código nativo para tocar arquivos de áudio multimídia. Também peguei da internet. A biblioteca original do Windows Forms/.Net só permitia tocar um som por vez, e ainda somente .WAV. Agora o game toca mp3.</p>
<p style="text-align: justify;">Algo que descobri desenvolvendo o game é que a parte audiovisual é um grande limitador para quem desenvolve sozinho. Fazer um game sem uma equipe multi-talentosa requer um criador multi-talentoso. Criar gráficos 2D estáticos é fácil. Mas criar sons, músicas, animações, backgrounds sem copiar tudo de outras fontes é extremamente difícil para um simples programador.</p>
<p style="text-align: justify;">E aí vem o problema. Encontrar bons efeitos sonoros é muito mais difícil que encontrar músicas. Acredite.</p>
<p style="text-align: justify;">Um dos grandes problemas para desenvolver este jogo foi tentar incluir cenários. O Windows Forms aceita inserir imagens de background, mas qualquer animação fica meio quebrada. A detecção de transparência não é muito boa. Por isso, e também por falta de habilidades de minha parte, não foi possível colocar backgrounds, muito menos obstáculos nas fases, como montanhas, relevos e etc.</p>
<p style="text-align: justify;">Isso levou a algumas idéias interessantes para aumentar o desafio de pousar as naves. Eu fiz com que em cada fase a plataforma se movesse de variadas velocidades e direções para dificultar um pouco e diferenciar as áreas mais avançadas. Algumas áreas possuem ventos. Outra coisa que inseri nas últimas fases foram asteróides que ficam caindo em velocidades e direções variadas, para atrapalhar um pouco.</p>
<p style="text-align: justify;">No geral, acho que o game ficou bem completo.</p>
<p style="text-align: justify;">Tentei neste game incluir um pouco das coisas que sinto falta em alguns games, como fases variadas, prêmios e incentivos para continuar a jogar. Tudo isso na escala do jogo, claro.</p>
<p style="text-align: justify;">Bom, depois de tudo isso, vamos aos downloads:</p>
<p style="text-align: justify;"><a href="http://www.4shared.com/file/231239952/3923be76/WinFormsLander_Source.html">Aqui</a> tem os fontes.</p>
<p style="text-align: justify;">Para codificar, adotei por padrão o idioma inglês. Acho mais fácil em inglês porque assim evitamos estrangeirismos, acentuações ou traduções grosseiras geralmente vistas no código em "português". Se for codificar em português e usar "GetValor" para nomear alguma função, então que se adote o inglês de uma vez! Ou usa "PegaValor". Os comentários estão todos em português, no entanto.</p>
<p style="text-align: justify;"><a href="http://www.4shared.com/file/231237363/88412fc6/WinFormsLander_Game.html">Aqui</a> tem o executável.</p>
<p style="text-align: justify;"><a href="http://www.4shared.com/file/232452167/d387c3a3/WinFormsLander_Game_NO_SOUND.html&lt;br &gt;&lt;/a&gt;">Aqui</a> tem o executável sem o áudio, para quem tiver problemas.</p>
<p style="text-align: justify;">Para rodar o game, é necessário ter o .Net 2.0 instalado. Talvez precise de alguma outra biblioteca, mas não consegui testar em uma grande variedade de PCs para me certificar se está tudo ok. Qualquer problema, deixe um comentário.</p>
<p style="text-align: justify;"><em>Edit:</em></p>
<p style="text-align: justify;"><em>PROBLEMA - a biblioteca de audio que usei pode não funcionar corretamente em alguns sistemas (foi o caso do Kazuma). Como a biblioteca não é minha, não sei porque não funciona. Vou investigar. Enquanto isso, estou disponibilizando uma versão sem áudio do game.</em></p>
<p style="text-align: justify;"><em>VISUAL - Como utilizei controles visuais usados em formulários de sistemas, como barras, botões, painéis e etc., as imagens ficarão melhores se o jogo rodar no modo visual clássico, e não com o tema do XP (ou mesmo Aero). Cliquem com o botão direito no WinFormsLander.exe e em Propriedades &gt;&gt; Compatibilidade, marquem "Desabilitar temas visuais".</em></p>
<p><a href="http://www.cubagames.com.br/criando-um-jogo-em-windowsforms-parte-1/">Parte 1 - Início</a></p>
]]></description>
		<wfw:commentRss>http://www.cubagames.com.br/criando-um-jogo-em-windows-forms-parte-7-final/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

