{"id":38478,"date":"2016-05-12T23:28:01","date_gmt":"2016-05-13T04:28:01","guid":{"rendered":"http:\/\/guillermoserrano97.wordpress.com\/?p=230"},"modified":"2016-05-12T23:52:36","modified_gmt":"2016-05-13T04:52:36","slug":"proyecto-final-4","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101winter2016\/2016\/05\/proyecto-final-4\/","title":{"rendered":"PROYECTO FINAL!!"},"content":{"rendered":"<p>Hey todo llega a su final y este curso no es la excepci\u00f3n, y como proyecto final creamos una copia del famoso juego de Atari Mars Invaders!!<\/p>\n<p>&nbsp;<\/p>\n<p>lo hicimos entre Miguel Brise\u00f1o, Alan Martinez y yo, Guillermo Serrano.<img decoding=\"async\" class=\"alignnone size-full wp-image-231\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/9c5ccc2a68bfbc844ad7e594966b85c9.jpg\" alt=\"unnamed.jpg\"   \/><\/p>\n<p>fue un proyecto complejo pero divertido en el que aprendimos muchas cosas muy importantes.<\/p>\n<p>pero aqu\u00ed tenemos un v\u00eddeo de como funciona:\u00a0https:\/\/youtu.be\/wCx3FjJlTEA<\/p>\n<p>y nuestro hermoso codigo:<\/p>\n<p>#include&lt;stdio.h&gt;<br \/>\n#include &lt;windows.h&gt;<br \/>\n#include &lt;conio.h&gt;<br \/>\n#include&lt;cstdlib&gt;<br \/>\n#define arriba 72<br \/>\n#define abajo 80<br \/>\n#define derecha 77<br \/>\n#define izquierda 75<br \/>\n#include &lt;list&gt;<br \/>\nusing namespace std;<\/p>\n<p>void posicion(int x,int y){<br \/>\nHANDLE hCon; \/\/con esta fncion se definen los<br \/>\nhCon = GetStdHandle(STD_OUTPUT_HANDLE); \/\/valores de las coordenadas para que los<br \/>\nCOORD dwPos; \/\/objetos se desplacen por la pantalla<br \/>\ndwPos.X= x;<br \/>\ndwPos.Y = y;<br \/>\nSetConsoleCursorPosition(hCon,dwPos);<br \/>\n}<\/p>\n<p>void ocultar(){<br \/>\nHANDLE hCon;<br \/>\nhCon = GetStdHandle(STD_OUTPUT_HANDLE);<br \/>\nCONSOLE_CURSOR_INFO cur;<br \/>\ncur.dwSize = 50;<br \/>\ncur.bVisible = FALSE;<br \/>\nSetConsoleCursorInfo(hCon,&amp;cur);<\/p>\n<p>}<\/p>\n<p>void limites (){<br \/>\nfor (int i = 1 ; i&lt;= 78; i++){ \/\/ en esta funcion se declaran los movimientos<br \/>\nposicion(i,3); \/\/ y los limites en los ejes &#8220;x&#8221; y &#8220;y&#8221;<br \/>\nprintf (&#8220;%c&#8221;,240); \/\/ el numero 240 es el codigo ascii para el caracter &#8220;-&#8221;<br \/>\n} \/\/ al igual que el 219 para el caracter &#8220;\u2588&#8221; que es un cuadro<br \/>\nfor (int i = 1 ; i&lt;= 78; i++){ \/\/ para dibujar los limites de donde se va a jugar.<br \/>\nposicion(i,34); \/\/ se llama a la funcion posicion () para dar las posiciones en la pantalla<br \/>\nprintf (&#8220;%c&#8221;,240);<br \/>\n}<br \/>\nfor (int i = 4 ; i&lt;= 33; i++){<br \/>\nposicion(1,i);<br \/>\nprintf (&#8220;%c&#8221;,219);<\/p>\n<p>}<br \/>\nfor (int i = 4 ; i&lt;= 33; i++){<br \/>\nposicion(78,i);<br \/>\nprintf (&#8220;%c&#8221;,219);<\/p>\n<p>}<br \/>\n}<br \/>\nclass NAVE{<br \/>\npublic: int x,y,cor,vidas;<br \/>\npublic :<br \/>\nNAVE(int _x,int _y,int _cor,int _vidas):x(_x), y(_y),cor(_cor),vidas(_vidas){}<br \/>\nint X (){return x;}<br \/>\nint Y (){return y;}<br \/>\nvoid dibujar();<br \/>\nvoid <\/p>\n<div class=\"post-limited-image\"><img decoding=\"async\" class=\"alignnone size-full wp-image-241\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/7d9c51dc17468f800ee36a8bb37f7017.jpg\" alt=\"maxresdefault.jpg\"   \/><\/div>\n<div class=\"post-limited-image\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/5f8da4fa3f018d223ba96f44b20db78b.jpg\" \/><\/div>\n<div class=\"post-limited-image\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/530fe257549c92fc6d99a92a7c701e15.jpg#038;blog=105381084&#038;%23038;post=230&#038;%23038;subd=guillermoserrano97&#038;%23038;ref=&#038;%23038;feed=1\" width=\"1\" height=\"1\" \/><\/div>\n<p><!--more--><br \/>\nvoid mover();<br \/>\nvoid dibujar_cor();<br \/>\nvoid perder();<br \/>\nvoid corazon_red(){cor&#8211;;}<\/p>\n<p>};<br \/>\nvoid NAVE :: dibujar(){<br \/>\nposicion(x,y);<br \/>\nprintf(&#8221; %c&#8221;,30);<br \/>\nposicion(x,y+1);<br \/>\nprintf(&#8221; %c%c%c&#8221;,47,0177,92);<br \/>\nposicion(x,y+2);<br \/>\nprintf(&#8221; %c%c%c%c%c&#8221;,47,177,177,177,92);<\/p>\n<p>}<br \/>\nvoid NAVE :: borrar(){<br \/>\nposicion(x,y);<br \/>\nprintf(&#8221; &#8220;);<br \/>\nposicion(x,y+1);<br \/>\nprintf(&#8221; &#8220;);<br \/>\nposicion(x,y+2);<br \/>\nprintf(&#8221; &#8220;);<\/p>\n<p>}<\/p>\n<p>void NAVE ::mover(){<\/p>\n<p>if (kbhit()){<br \/>\nchar tecla = getch();<br \/>\nborrar();<br \/>\nif (tecla == &#8216;a&#8217; &amp;&amp; x&gt;2)<br \/>\nx&#8211;;<br \/>\nif (tecla == &#8216;d&#8217; &amp;&amp;x&lt;72)<br \/>\nx++;<br \/>\nif (tecla == &#8216;w&#8217; &amp;&amp;y&gt;4)<br \/>\ny&#8211;;<br \/>\nif (tecla == &#8216;s&#8217; &amp;&amp;y&lt;31)<br \/>\ny++;<br \/>\ndibujar();<br \/>\nif (tecla ==&#8217;0&#8242;)<br \/>\ncor&#8211;;<br \/>\ndibujar_cor();<br \/>\n}<br \/>\n}<\/p>\n<p>void NAVE ::dibujar_cor(){<br \/>\nposicion(5,1);<br \/>\nprintf(&#8220;vidas %d&#8221;,vidas );<br \/>\nposicion(64,1);<br \/>\nprintf(&#8220;salud&#8221; );<br \/>\nposicion(70,1);<br \/>\nprintf(&#8221; &#8220;);<br \/>\nfor (int i = 0;i &lt;cor;i++){<\/p>\n<p>posicion(70+i,1);<br \/>\nprintf(&#8220;%c&#8221;,3);<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>void NAVE :: perder(){<br \/>\nif (cor ==0){<\/p>\n<p>borrar();<br \/>\nposicion(x,y);<br \/>\nprintf(&#8220;* * *&#8221;);<br \/>\nposicion(x,y+1);<br \/>\nprintf(&#8220;* * *&#8221;);<br \/>\nposicion(x,y+2);<br \/>\nprintf(&#8220;* * *&#8221;);<br \/>\nSleep(600);<br \/>\nvidas&#8211;;<br \/>\ncor = 3;<br \/>\ndibujar_cor();<br \/>\nborrar();<br \/>\ndibujar();<br \/>\n\/\/ printf(&#8220;* * *&#8221;);<br \/>\n\/\/ posicion(x,y-1);<br \/>\n\/\/ printf(&#8220;* * *&#8221;);<br \/>\n\/\/ posicion(x,y-2);<br \/>\n\/\/ printf(&#8220;* * *&#8221;);<br \/>\n\/\/ borrar();<br \/>\n\/\/ Sleep(200);<br \/>\n\/\/ alto = 1;<br \/>\n\/\/ vidas &#8211;;<br \/>\n}<br \/>\n}<\/p>\n<p>class malos {<br \/>\nint x,y;<\/p>\n<p>public:<br \/>\nmalos(int _x,int _y):x(_x), y(_y){}<br \/>\nvoid pintar();<br \/>\nvoid mover();<br \/>\nvoid colision (class NAVE &amp;N);<\/p>\n<p>};<br \/>\nvoid malos :: pintar(){<br \/>\nposicion(x,y);<br \/>\nprintf(&#8220;%c&#8221; ,127);<br \/>\n}<br \/>\nvoid malos :: mover(){<br \/>\nposicion(x,y);<br \/>\nprintf(&#8221; &#8220;);<br \/>\ny++;<br \/>\nif (y &gt; 30){<br \/>\nx = rand()%71 +4;<br \/>\ny = 4;<\/p>\n<p>}<br \/>\npintar();<br \/>\n}<br \/>\nvoid malos::colision(class NAVE &amp;N){<br \/>\nif (x&gt;= N.X() &amp;&amp; x&lt; N.X() +5&amp;&amp; y&gt;= N.Y() &amp;&amp; y&lt; N.Y()+2){<br \/>\nN.corazon_red();<br \/>\nN.dibujar();<br \/>\nN.dibujar_cor();<br \/>\nprintf(&#8221; &#8220;);<br \/>\ny++;<br \/>\nif (y &gt; 30){<br \/>\nx = rand()%71 +4;<br \/>\ny = 4;<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>class disparo{<br \/>\nint x,y;<br \/>\npublic :<br \/>\ndisparo(int _x,int _y): x(_x),y(_y){}<br \/>\nvoid mover();<br \/>\n};<\/p>\n<p>void disparo :: mover(){<br \/>\nposicion(x,y);<br \/>\nprintf(&#8221; &#8220;);<br \/>\nif (y&gt;4){<br \/>\ny&#8211;;<br \/>\nprintf (&#8220;*&#8221;);<br \/>\n}<br \/>\n}<\/p>\n<p>int main(){<\/p>\n<p>ocultar();<br \/>\nlimites();<br \/>\nNAVE N(6,6,3,3);<br \/>\nN.borrar();<br \/>\nN.dibujar();<br \/>\nN.x++;<br \/>\nN.dibujar_cor();<br \/>\nint vida=N.vidas;<br \/>\nmalos da(3,4);<br \/>\nmalos ma(15,4);<br \/>\nmalos ta(22,4);<br \/>\nmalos fa(8,4);<\/p>\n<p>list&lt;disparo*&gt; d;<br \/>\nbool gameover = false;<br \/>\nwhile (vida&gt;0){<br \/>\nN.perder();<br \/>\nN.mover();<br \/>\nma.mover();<br \/>\nma.colision(N);<br \/>\nda.mover();<br \/>\nda.colision(N);<br \/>\nta.mover();<br \/>\nta.colision(N);<br \/>\nfa.mover();<br \/>\nfa.colision(N);<br \/>\nif (kbhit()){<br \/>\nchar tecla = getch();<\/p>\n<p>if(tecla == &#8216;k&#8217;){<br \/>\nd.push_back(new disparo(N.X()+2,N.Y()+2));<br \/>\n}<\/p>\n<p>}<\/p>\n<p>vida=N.vidas;<\/p>\n<p>Sleep(70);<\/p>\n<p>}<\/p>\n<p>N.borrar();<br \/>\nprintf(&#8221; n&#8221;);<br \/>\nprintf(&#8220;********** ********** *** *** **********n&#8221;);<br \/>\nprintf(&#8220;********** ********** **** **** **********n&#8221;);<br \/>\nprintf(&#8220;** ** ** ***** ***** **n&#8221;);<br \/>\nprintf(&#8220;** **** ********** ** ****** ** *******n&#8221;);<br \/>\nprintf(&#8220;** **** ********** ** **** ** *******n&#8221;);<br \/>\nprintf(&#8220;** ** ** ** ** ** **n&#8221;);<br \/>\nprintf(&#8220;********** ** ** ** ** **********n&#8221;);<br \/>\nprintf(&#8220;********** ** ** ** ** **********n&#8221;);<br \/>\nprintf(&#8221; n&#8221;);<br \/>\nprintf(&#8220;********** *** *** ********** **********n&#8221;);<br \/>\nprintf(&#8220;********** *** *** ********** **********n&#8221;);<br \/>\nprintf(&#8220;** ** *** *** ** *** ***n&#8221;);<br \/>\nprintf(&#8220;** ** *** *** ******* **********n&#8221;);<br \/>\nprintf(&#8220;** ** *** *** ******* **********n&#8221;);<br \/>\nprintf(&#8220;** ** *** *** ** *** ****n&#8221;);<br \/>\nprintf(&#8220;********** ****** ********** *** ****n&#8221;);<br \/>\nprintf(&#8220;********** **** ********** *** ****n&#8221;);<br \/>\nreturn 0;<br \/>\n}<\/p>\n<p>sin mas que mencionar solo puedo decir que este fue un curso maravilloso y que esto es todo amigos!!<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-241\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/7d9c51dc17468f800ee36a8bb37f7017.jpg\" alt=\"maxresdefault.jpg\"   \/><\/p>\n<p>&nbsp;<\/p>\n<p>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/guillermoserrano97.wordpress.com\/230\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/5f8da4fa3f018d223ba96f44b20db78b.jpg\" \/><\/a> <img loading=\"lazy\" decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/530fe257549c92fc6d99a92a7c701e15.jpg#038;blog=105381084&#038;%23038;post=230&#038;%23038;subd=guillermoserrano97&#038;%23038;ref=&#038;%23038;feed=1\" width=\"1\" height=\"1\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey todo llega a su final y este curso no es la excepci\u00f3n, y como proyecto final creamos una copia del famoso juego de Atari Mars Invaders!! &nbsp; lo hicimos entre Miguel Brise\u00f1o, Alan Martinez y yo, Guillermo Serrano. fue un proyecto complejo pero divertido en el que aprendimos muchas cosas muy importantes. pero aqu\u00ed &hellip; <a href=\"https:\/\/kenscourses.com\/tc101winter2016\/2016\/05\/proyecto-final-4\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">PROYECTO FINAL!!<\/span><\/a><\/p>\n","protected":false},"author":59,"featured_media":38480,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[45],"class_list":["post-38478","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogs","category-syndicated","tag-sin-categoria"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/38478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/users\/59"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/comments?post=38478"}],"version-history":[{"count":2,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/38478\/revisions"}],"predecessor-version":[{"id":38486,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/38478\/revisions\/38486"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media\/38480"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media?parent=38478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/categories?post=38478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/tags?post=38478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}