{"id":10156,"date":"2018-09-24T13:26:24","date_gmt":"2018-09-24T11:26:24","guid":{"rendered":"http:\/\/agora.xtec.cat\/esc-cancoll\/?page_id=10156"},"modified":"2018-12-19T15:27:03","modified_gmt":"2018-12-19T14:27:03","slug":"session-5","status":"publish","type":"page","link":"https:\/\/agora.xtec.cat\/esc-cancoll\/curs-scratch-primaria\/module-2-a-game-or-two\/session-5\/","title":{"rendered":"Session 5: Add lives and punctuation to the pong"},"content":{"rendered":"<h2><span id=\"Pla_de_treball\">Work plan<\/span><\/h2>\n<div>\n<ul>\n<li>Control the variable &#8220;lifes&#8221;<\/li>\n<li>Point counter<\/li>\n<\/ul>\n<h2><span id=\"Controlem_millor_les_vides\">We better control your lives<\/span><\/h2>\n<p>In the previous session we have seen what happened to us when we lost.\u00a0We created a variable called &#8220;lives&#8221; that was decreasing every time we achieved it by adding -1 to this variable every time the ball did not touch the racket.\u00a0But we have a problem, the game does not stop and lives start to dial negative numbers.<\/p>\n<p><img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-icona_tasques.png\" alt=\"Icon tasks\" width=\"32\" \/><strong>Let&#8217;s do it step by step<\/strong><\/p>\n<div>\n<ul>\n<li>We enter our Scratch account and make a copy of our project\u00a0<strong>m2\u00a0<\/strong><strong>challenge41<\/strong>\u00a0\u00a0and we change the name to\u00a0<strong>m2repte51<\/strong><\/li>\n<li>In our project we have done that the game is repeated and that the lives decrease when the ball does not touch the racket.\u00a0This repetition can be controlled in different ways but to prevent the game from continuing despite the end of the lives, we will have to use<br \/>\n<img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-pong25-1.png\" alt=\"Repeat\" \/><\/li>\n<li>Note that this repetition allows us to add control over the &#8220;ends&#8221; to an empty space.\u00a0Within this empty space we will add a new element that belongs to the\u00a0<strong>Operators<\/strong>\u00a0block\u00a0.\u00a0From this blog we have already used in previous sessions the creation of random numbers<br \/>\n<img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-pong26.png\" alt=\"Operators\" \/><\/li>\n<li>Since we want the repetition to occur until the lives end, we will indicate this way:<br \/>\n<img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-pong27.png\" alt=\"Control vines\" \/><\/li>\n<\/ul>\n<\/div>\n<hr \/>\n<p><img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-icona_repte.png\" alt=\"Icon challenge\" width=\"32\" \/>\u00a0<strong>Challenge 1:<\/strong><\/p>\n<p>We still have problems with the control of lives since if we do not control the position of the ball when it has not bounced on the racket, besides subtracting a life, it will continue to do so.\u00a0Modify the\u00a0<strong>m2repte51<\/strong>\u00a0project\u00a0that we have open so that the ball returns to the initial position after subtracting a life and that it stops for a few seconds before moving back.<\/p>\n<p><img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-icona_pista.png\" alt=\"Icon track\" width=\"24\" \/>\u00a0Track: We used the &#8220;waiting&#8221; block in module 1 in session 2 when we established dialogues between characters.<\/p>\n<hr \/>\n<h2><span id=\"I_ara8230guanyem_punts\">And now &#8230; we earn points<\/span><\/h2>\n<p>In addition to controlling how many lives we have left in the game, it is interesting to know how many times we can get the ball bouncing on the racket in the same life.\u00a0To achieve this, we will add a point control.<\/p>\n<p><img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-icona_tasques.png\" alt=\"Icon tasks\" width=\"32\" \/><strong>Let&#8217;s do it step by step<\/strong><\/p>\n<div>\n<ul>\n<li>We continue working on our\u00a0<strong>m2repte51<\/strong>\u00a0project<\/li>\n<li>We have to create a new variable that we will call &#8220;points&#8221; where we will accumulate the number of rebounds achieved before losing a life.\u00a0We must not forget to mark this variable when we finish creating it so that it can be viewed on the screen<\/li>\n<li>This variable &#8220;points&#8221; must start with a value of zero and must increase 1 each time the ball touches the racket:<br \/>\n<img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/07\/scratch-pong30.png.png\" alt=\"Control points\" \/><\/li>\n<\/ul>\n<\/div>\n<hr \/>\n<p><img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-icona_repte.png\" alt=\"Icon challenge\" width=\"32\" \/><strong>\u00a0Challenge 2:<\/strong><\/p>\n<p>We continue working on our\u00a0<strong>m2repte51<\/strong>\u00a0project\u00a0\u00a0<strong>\u00a0<\/strong>and add control points.<\/p>\n<p><img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-icona_pista.png\" alt=\"Icon track\" width=\"24\" \/>Track: every time the game begins, we have to put the point counter to 0. We have to combine the points with the lives.\u00a0How do we organize the blogs?<\/p>\n<hr \/>\n<p><img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-icona_projecte2.png\" alt=\"Icon project\" width=\"32\" \/>\u00a0<strong>Our project grows &#8230;<\/strong><\/p>\n<p>First of all, let&#8217;s take a look at these\u00a0<a href=\"https:\/\/scratch.mit.edu\/pdfs\/cards\/PongCards.pdf\"><strong>Scratch Cards<\/strong><\/a>\u00a0to see if our pong evolves well.\u00a0It is time to refer what has not just worked.<\/p>\n<p>In the previous session we have already decided how many lives we want to give the players in our\u00a0<b>pinball<\/b>\u00a0project\u00a0.\u00a0Now that we know how to count the points, we should think what we want the game to do when the player reaches a certain number of points and add it to the description.<\/p>\n<hr \/>\n<p><img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-icona_glosari.png\" alt=\"Glossary icon\" width=\"32\" \/>\u00a0<strong>Because we are programmers and programmers we talk about &#8230;<\/strong><\/p>\n<div>\n<ul>\n<li><b>Operators: <\/b>a\u00a0block that contains the actions that allow us to perform operations, approximations, unions, exclusions, random numbers &#8230;<\/li>\n<\/ul>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Work plan<\/p>\n<ul>\n<li>Control the variable &#8220;lifes&#8221;<\/li>\n<li>Point counter<\/li>\n<\/ul>\n<p>We better control your lives<br \/>\nIn the previous session we have seen what happened to us when we lost.\u00a0We created a variable called &#8220;lives&#8221; that was decreasing every time we achieved it by adding -1 to this variable every time the&hellip;  <a href=\"https:\/\/agora.xtec.cat\/esc-cancoll\/curs-scratch-primaria\/module-2-a-game-or-two\/session-5\/\" title=\"Read Session 5: Add lives and punctuation to the pong\">Llegeix m\u00e9s\u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":10141,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"class_list":["post-10156","page","type-page","status-publish","hentry"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/agora.xtec.cat\/esc-cancoll\/wp-json\/wp\/v2\/pages\/10156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/agora.xtec.cat\/esc-cancoll\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/agora.xtec.cat\/esc-cancoll\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/agora.xtec.cat\/esc-cancoll\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/agora.xtec.cat\/esc-cancoll\/wp-json\/wp\/v2\/comments?post=10156"}],"version-history":[{"count":2,"href":"https:\/\/agora.xtec.cat\/esc-cancoll\/wp-json\/wp\/v2\/pages\/10156\/revisions"}],"predecessor-version":[{"id":10184,"href":"https:\/\/agora.xtec.cat\/esc-cancoll\/wp-json\/wp\/v2\/pages\/10156\/revisions\/10184"}],"up":[{"embeddable":true,"href":"https:\/\/agora.xtec.cat\/esc-cancoll\/wp-json\/wp\/v2\/pages\/10141"}],"wp:attachment":[{"href":"https:\/\/agora.xtec.cat\/esc-cancoll\/wp-json\/wp\/v2\/media?parent=10156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}