{"id":10160,"date":"2018-09-24T13:26:57","date_gmt":"2018-09-24T11:26:57","guid":{"rendered":"http:\/\/agora.xtec.cat\/esc-cancoll\/?page_id=10160"},"modified":"2019-02-20T12:52:03","modified_gmt":"2019-02-20T11:52:03","slug":"session-7","status":"publish","type":"page","link":"https:\/\/agora.xtec.cat\/esc-cancoll\/curs-scratch-primaria\/module-2-a-game-or-two\/session-7\/","title":{"rendered":"Session 7: Add levels"},"content":{"rendered":"<h2><span id=\"Pla_de_treball\">Work plan<\/span><\/h2>\n<div>\n<ul>\n<li>Conditions of change of level<\/li>\n<li>Speed of the ball<\/li>\n<li>Racket size<\/li>\n<li>Countdown<\/li>\n<\/ul>\n<h2><span id=\"Velocitat_i_mida_de_la_raqueta\">Speed and size of the racket<\/span><\/h2>\n<p>We will add different levels of difficulty to the game, so it is becoming more complicated to move forward and not get bored.<\/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=\"Step by step\" width=\"32\" \/>\u00a0<strong>Let&#8217;s do it step by step<\/strong><\/p>\n<div>\n<ul>\n<li>Entering our Scratch account, we open the\u00a0<strong>m2repte61<\/strong>\u00a0project\u00a0and set it as\u00a0<strong>m2repte71<\/strong><\/li>\n<li>Since we want the ball to go faster and faster, we have to create a variable called &#8220;speed&#8221;<\/li>\n<li>We initialize the &#8220;speed&#8221; variable at the beginning of the program:<br \/>\n<img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-pong37.png\" alt=\"We initialize the variable speed\" \/><\/li>\n<li>Now that we have this variable, we change the block\u00a0<strong>move 10<\/strong>\u00a0to\u00a0<strong>move &#8220;speed&#8221;<\/strong>\u00a0:<br \/>\n<img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-pong38.png\" alt=\"Move your speed\" \/><\/li>\n<li>Level management can be done in two ways, by time or by points.\u00a0For example, we can make a change in level every 15 seconds or every 10 points<\/li>\n<li>We do the management by points.\u00a0Inside the loop where the logic of the program is, just after verifying that the ball touches the racket, we put these blocks:<br \/>\n<img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-pong28.png\" alt=\"Increase speed by 3\" \/><\/li>\n<li>Another element we can add to increase the difficulty is to reduce the size of the racket.\u00a0However, since the program is in the ball and we want to act on another character, we will have to do it with the sending of a message, which we will have created previously, as we did in session 10 of module 1:<br \/>\n<img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-pong31.png\" alt=\"Message Reduce racket\" \/><\/li>\n<li>This message should be received by the racket, so we add this program to the racket.\u00a0Let&#8217;s say that\u00a0<strong>increasing -5<\/strong>\u00a0is the same as decreasing 5:<br \/>\n<img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-pong33.png\" alt=\"Reduce racquet\" \/><\/li>\n<li>We need to keep in mind that when we run the program again the size of the racket will be smaller.\u00a0In order for this to happen, we must put this block just behind the green flag of the racket program:<br \/>\n<img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-aspecte_fixalamida.png\" alt=\"Set the size to 100%\" \/><\/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 continue with the\u00a0<strong>m2repte71<\/strong>\u00a0project\u00a0and we have an increase in speed and a decrease in the size of the racket every 10 points (at 10 points, 20 points, 30 points &#8230;).<\/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: Note that &#8220;every 10 points&#8221; is the same as saying when the number of points is multiple of 10. To detect if the points are multiple of 10, we can divide the points between 10 and check if the residue is 0. We can use this blog:<br \/>\n<img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-pong40.png\" alt=\"Waste\" \/><\/p>\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 2:<\/strong><\/p>\n<p>Let&#8217;s make a copy of the challenge that we have open\u00a0<strong>m2repte71<\/strong>\u00a0with the name\u00a0<strong>m2repte72<\/strong>\u00a0.\u00a0In this challenge, the speed changes of the ball and the size of the racket must be managed based on the time that has elapsed taking advantage of the chronometer (instead of the points as in the previous challenge)<\/p>\n<hr \/>\n<h2><span id=\"Limit_de_temps\">Time limit<\/span><\/h2>\n<p>In the previous session we worked with the stopwatch and we said that we could manage the time in a similar way but using a variable.\u00a0The timer only allows us to increase the time automatically;\u00a0With a time variable we can control it by increasing it (count on) or decrease (countdown).<\/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=\"Step by step\" width=\"32\" \/>\u00a0<strong>Let&#8217;s do it step by step<\/strong><\/p>\n<div>\n<ul>\n<li>We continue with the\u00a0<strong>m2repte71<\/strong>\u00a0project<\/li>\n<li>We create a variable called &#8220;time&#8221;<\/li>\n<li>With this variable we can create a countdown, that we would do this way:<br \/>\n<img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-pong34.png\" alt=\"Countdown\" \/><\/li>\n<li>We insert this account back into our project so that each thing goes to its place.\u00a0The initialization of the time at the beginning and what is inside the loop where the logic of the program is<\/li>\n<li>This countdown should help us to finish the game when time reaches zero:<br \/>\n<img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/wp-content\/uploads\/usu604\/2017\/06\/scratch-pong35.png\" alt=\"Ends when time reaches 0\" \/><\/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 3:<\/strong><\/p>\n<p>We continue with the\u00a0<strong>m2repte71<\/strong>\u00a0project\u00a0.\u00a0As in terms of the score, we have increased the level (speed of the ball and size of the racket), we now increase the lives and the time available according to the points.<\/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>The level control that we have worked on in our pong, that is, changing the speed of the ball, the size of the rackets, as well as changing lives and time depending on the points accumulated can also apply to our final challenge of\u00a0<strong>pinball<\/strong>\u00a0.\u00a0We need to add to the description of our pinball as we want it to be the mechanics of the game in terms of scores, lives and levels.\u00a0These are actually the instructions to play your\u00a0<strong>pinball<\/strong>\u00a0.\u00a0At session 11 you will be asked that these instructions are clearly explained in the\u00a0<strong>instructions<\/strong>section of\u00a0your project.<\/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>Levels of play:<\/b>\u00a0\u00a0conditions that must be met to vary the complexity of the game.\u00a0They are usually sequential and depend on defined variables.<\/li>\n<\/ul>\n<\/div>\n<div class=\"addtoany_share_save_container addtoany_content_bottom\">\n<div class=\"a2a_kit a2a_kit_size_25 addtoany_list\" data-a2a-url=\"http:\/\/projectes.xtec.cat\/programacioirobotica\/curs-scratch-primaria\/modul-2\/sessio-7\/\" data-a2a-title=\"Sessi\u00f3 7. Afegim-hi nivells\"><a class=\"a2a_button_facebook\" title=\"Facebook\" href=\"http:\/\/projectes.xtec.cat\/#facebook\" target=\"_blank\" rel=\"nofollow noopener\"><span class=\"a2a_label\">Facebook<\/span><\/a><a class=\"a2a_button_twitter\" title=\"Twitter\" href=\"http:\/\/projectes.xtec.cat\/#twitter\" target=\"_blank\" rel=\"nofollow noopener\"><span class=\"a2a_label\">Twitter<\/span><\/a><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Work plan<\/p>\n<ul>\n<li>Conditions of change of level<\/li>\n<li>Speed of the ball<\/li>\n<li>Racket size<\/li>\n<li>Countdown<\/li>\n<\/ul>\n<p>Speed and size of the racket<br \/>\nWe will add different levels of difficulty to the game, so it is becoming more complicated to move forward and not get bored.<br \/>\n\u00a0Let&#8217;s do it step by step<\/p>\n<ul>\n<li>Entering our Scratch account,&hellip;  <a href=\"https:\/\/agora.xtec.cat\/esc-cancoll\/curs-scratch-primaria\/module-2-a-game-or-two\/session-7\/\" title=\"Read Session 7: Add levels\">Llegeix m\u00e9s\u00bb<\/a><br \/>\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-10160","page","type-page","status-publish","hentry"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/agora.xtec.cat\/esc-cancoll\/wp-json\/wp\/v2\/pages\/10160","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=10160"}],"version-history":[{"count":2,"href":"https:\/\/agora.xtec.cat\/esc-cancoll\/wp-json\/wp\/v2\/pages\/10160\/revisions"}],"predecessor-version":[{"id":10186,"href":"https:\/\/agora.xtec.cat\/esc-cancoll\/wp-json\/wp\/v2\/pages\/10160\/revisions\/10186"}],"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=10160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}