{"id":37752,"date":"2016-05-05T01:57:28","date_gmt":"2016-05-05T06:57:28","guid":{"rendered":"http:\/\/edithsantoscom.wordpress.com\/?p=373"},"modified":"2016-05-05T02:36:35","modified_gmt":"2016-05-05T07:36:35","slug":"final-proyect","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101winter2016\/2016\/05\/final-proyect\/","title":{"rendered":"Final Proyect"},"content":{"rendered":"<p>Hello,<\/p>\n<p>Here you will find my final proyect which took me all semester to decide what to do, at the end i worked side by side with a really good friend Martha, the blog that i shared with you some posts ago,<\/p>\n<p>The game is based on Snake from years ago and it took us a while to finish it but at the end it worth it, we share with you the code and its really important to mention that to make it work we download CodeBlocks which helps us to write the code and compile in the same program:<\/p>\n<p>#include &lt;windows.h&gt;<br \/>\n#include &lt;iostream&gt;<br \/>\n#include &lt;conio.h&gt;<br \/>\n#include &lt;cstdlib&gt;<br \/>\n#include &lt;stdio.h&gt;<\/p>\n<p>#define Arriba 72 \/\/Define numeros asociados a las flechas<br \/>\n#define Izquierda 75<br \/>\n#define Derecha 77<br \/>\n#define Abajo 80<br \/>\n#define Esc 27<br \/>\nint cuerpo[200][2];<br \/>\nint n=1, tam=4, x=10, y=12, dir=3, xc=30, yc=15, velocidad=100, score=0, h=1;<br \/>\nchar tecla;<\/p>\n<p>void gotoxy(int x, int y) \/\/funcion posicion de &#8220;x&#8221; y &#8220;y&#8221;<br \/>\n{<br \/>\nHANDLE hCon;<br \/>\nCOORD dwPos;<\/p>\n<p>dwPos.X =x;<br \/>\ndwPos.Y =y;<br \/>\nhCon=GetStdHandle(STD_OUTPUT_HANDLE);<br \/>\nSetConsoleCursorPosition(hCon,dwPos);<\/p>\n<p>}<br \/>\nvoid pintar(){<br \/>\n\/\/lineas<br \/>\nfor(int i = 2 ; i &lt; 78 ; i++){<br \/>\ngotoxy(i,3);<br \/>\nprintf(&#8220;%c&#8221;,205);<br \/>\ngotoxy(i,23);<br \/>\nprintf(&#8220;%c&#8221;, 205);<\/p>\n<p>}<br \/>\n\/\/lineas verticales<br \/>\nfor(int i = 4 ; i &lt; 23 ; i++){<br \/>\ngotoxy(2,i);<br \/>\nprintf(&#8220;%c&#8221;,186);<br \/>\ngotoxy(77,i);<br \/>\nprintf(&#8220;%c&#8221;, 186);<\/p>\n<p>}<br \/>\n\/\/esquinas<br \/>\ngotoxy(2,3);<br \/>\nprintf(&#8220;%c&#8221;,201);<br \/>\ngotoxy(2,23);<br \/>\nprintf(&#8220;%c&#8221;, 200);<br \/>\ngotoxy(77,3);<br \/>\nprintf(&#8220;%c&#8221;, 187);<br \/>\ngotoxy(77,23);<br \/>\nprintf(&#8220;%c&#8221;, 188);<\/p>\n<p>}<br \/>\nvoid guardar_posicion(){<\/p>\n<p>cuerpo[n][0]=x;<br \/>\ncuerpo[n][1]=y;<br \/>\nn++; \/\/sigue incrementando<br \/>\nif(n==tam) n=1;<\/p>\n<p>}<\/p>\n<p>void pintar_cuerpo(){<\/p>\n<p>for(int i = 1 ; i &lt; tam ; i++){<br \/>\ngotoxy(cuerpo[i][0], cuerpo[i][1]) ; printf(&#8220;*&#8221;);<\/p>\n<p>}<\/p>\n<p>}<br \/>\nvoid borrar_cuerpo(){<br \/>\ngotoxy(cuerpo[n][0], cuerpo[n][1]) ; printf(&#8221; &#8220;);<\/p>\n<p>}<br \/>\nvoid teclear(){<br \/>\nif(kbhit()){<br \/>\ntecla=getch();<br \/>\nswitch(tecla){<br \/>\ncase Arriba:<br \/>\nif(dir!=2)<br \/>\ndir=1;<br \/>\nbreak;<br \/>\ncase Abajo:<br \/>\nif(dir!=1)<br \/>\ndir=2;<br \/>\nbreak;<br \/>\ncase Derecha:<br \/>\nif(dir!=4)<br \/>\ndir=3;<br \/>\nbreak;<br \/>\ncase Izquierda:<br \/>\nif(dir!=3)<br \/>\ndir=4;<br \/>\nbreak;<br \/>\n}<br \/>\n}<\/p>\n<p>}<br \/>\nvoid cambiar_velocidad(){<br \/>\nif(score==h*20){<br \/>\nvelocidad-=10;<br \/>\nh++;<br \/>\n}<br \/>\n}<br \/>\nvoid <\/p>\n<div class=\"post-limited-image\"><img decoding=\"async\" class=\"alignnone size-full wp-image-383\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/90515718fecb1744d8c6fb231fa135b7.jpg\" alt=\"2016-05-05_0028\"   \/><\/div>\n<div class=\"post-limited-image\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/68647625f47e71da832f67d12ff7bb66.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\/b005432ecc7dfd3e0295490da2dfa4a2.jpg#038;blog=105302360&#038;%23038;post=373&#038;%23038;subd=edithsantoscom&#038;%23038;ref=&#038;%23038;feed=1\" width=\"1\" height=\"1\" \/><\/div>\n<p><!--more--><br \/>\nif(x==xc &amp;&amp; y==yc){<br \/>\nxc=(rand()%73)+4;<br \/>\nyc=(rand()%19)+4;<br \/>\ntam++;<br \/>\nscore +=10;<br \/>\ngotoxy(xc,yc);printf(&#8220;%c&#8221;, 4);<\/p>\n<p>cambiar_velocidad();<br \/>\n}<\/p>\n<p>}<br \/>\nbool game_over(){<br \/>\nif(y==3 || y==23 || x==2 || x==77) return false;\/\/falta signo de O<br \/>\nfor( int j = tam &#8211; 1 ; j &gt; 0 ; j&#8211;){<br \/>\nif(cuerpo[j][0]== x &amp;&amp; cuerpo[j][1]== y)<br \/>\nreturn false;<br \/>\n}<br \/>\nreturn true;<br \/>\n}<br \/>\nvoid puntos(){<br \/>\ngotoxy(3,1); printf(&#8220;Score %d&#8221;, score);<br \/>\n}<br \/>\nint main(){<\/p>\n<p>pintar();<br \/>\ngotoxy(xc,yc);printf(&#8220;%c&#8221;, 4);<\/p>\n<p>while(tecla != Esc &amp;&amp; game_over())<br \/>\n{<br \/>\nborrar_cuerpo();<br \/>\nguardar_posicion();<br \/>\npintar_cuerpo();<\/p>\n<p>comida();<\/p>\n<p>puntos();<br \/>\nteclear();<br \/>\nteclear();<br \/>\nteclear();<br \/>\nif(dir==1) y&#8211;;<br \/>\nif(dir==2) y++;<br \/>\nif(dir==3) x++;<br \/>\nif(dir==4) x&#8211;;<\/p>\n<p>Sleep(velocidad);<\/p>\n<p>}<br \/>\npintar();<br \/>\nsystem(&#8220;pause&gt;null&#8221;);<br \/>\nreturn 0;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>The program works!!!<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-383\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/90515718fecb1744d8c6fb231fa135b7.jpg\" alt=\"2016-05-05_0028\"   \/><\/p>\n<p>It was a hard proyect but at the end we both agreed the results where satisfactory, Martha will share with you the outcome of the other idea we had&#8230;<\/p>\n<p>&nbsp;<\/p>\n<p>Thanks for reading,<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>-Free Money-<\/p>\n<p>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/edithsantoscom.wordpress.com\/373\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/68647625f47e71da832f67d12ff7bb66.jpg\" \/><\/a> <img loading=\"lazy\" decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/b005432ecc7dfd3e0295490da2dfa4a2.jpg#038;blog=105302360&#038;%23038;post=373&#038;%23038;subd=edithsantoscom&#038;%23038;ref=&#038;%23038;feed=1\" width=\"1\" height=\"1\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello, Here you will find my final proyect which took me all semester to decide what to do, at the end i worked side by side with a really good friend Martha, the blog that i shared with you some posts ago, The game is based on Snake from years ago and it took us &hellip; <a href=\"https:\/\/kenscourses.com\/tc101winter2016\/2016\/05\/final-proyect\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Final Proyect<\/span><\/a><\/p>\n","protected":false},"author":26,"featured_media":37754,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[45],"class_list":["post-37752","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\/37752","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\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/comments?post=37752"}],"version-history":[{"count":2,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/37752\/revisions"}],"predecessor-version":[{"id":37758,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/37752\/revisions\/37758"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media\/37754"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media?parent=37752"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/categories?post=37752"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/tags?post=37752"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}