{"id":18203,"date":"2015-11-10T05:01:39","date_gmt":"2015-11-09T19:01:39","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=18203"},"modified":"2016-06-03T10:06:29","modified_gmt":"2016-06-03T00:06:29","slug":"esl-vocabulary-getting-warmer-game-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/esl-vocabulary-getting-warmer-game-tutorial\/","title":{"rendered":"ESL Vocabulary Getting Warmer Game Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href='http:\/\/www.rjmprogramming.com.au\/pre_under_the_stairs.html' title='ESL Vocabulary Getting Warmer Game Tutorial'><img decoding=\"async\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/pre_under_the_stairs.gif\"  \/><\/a><p class=\"wp-caption-text\">ESL Vocabulary Getting Warmer Game Tutorial<\/p><\/div>\n<p>As we saw yesterday, the HTML <a target=_blank title='HTML map element information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_map.asp'>map<\/a> element can be used in a variety of ways, two of which we hone in on with today&#8217;s ESL Vocabulary Getting Warmer Game Tutorial, a variation on yesterday&#8217;s <a target=_blank title='ESL Under The Stairs Game Overlay Primer Tutorial' href='#eutsgopt'>ESL Under The Stairs Game Overlay Primer Tutorial<\/a> as shown below, where we add Javascript functionality to effectively find the shortest distance of a point to a polygon co-ordinate &#8220;set&#8221;, and a revisit of our previous <a target=_blank title='English Learning - Vocabulary - Under The Stairs' href='#elvuts'>English Learning &#8211; Vocabulary &#8211; Under The Stairs<\/a> as shown way below.  The HTML map element can be &#8230;<\/p>\n<ol>\n<li>a jigsaw &#8220;overlay&#8221; to the underlying image (in that we try to cover the whole area of the image with clickable HTML <a target=_blank title='HTML area element information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_area.asp'>area<\/a> &#8220;polygon&#8221; segments (the so called &#8220;Click and be Prompted&#8221; mode of use)) &#8230; but if the user selects a &#8220;Find Prompted Object&#8221; mode of use that same HTML map element is reworked to become like &#8230;<\/li>\n<li>a &#8220;Where&#8217;s Wally&#8221; scenario where the computer prompts the user for what they should click on, where the HTML map element has one defined HTML area tag plus one other default &#8220;nonhref&#8221; HTML area tag<\/li>\n<\/ol>\n<p>In that second mode of use today, we add a bit of fun by adding that &#8220;getting warmer&#8221; type of &#8220;bizzo&#8221; (sorry to get technical) to our game.<\/p>\n<p>To do this, as we&#8217;ve mentioned, we find the shortest distance of a point to a polygon co-ordinate &#8220;set&#8221; by &#8230;<\/p>\n<ol>\n<li>leave the HTML map to determine when a point is inside its first &#8220;polygon&#8221; section, and for all the rest, via that other &#8220;nohref&#8221; HTML area element&#8217;s onclick event, we arrange some Javascript that &#8230;<\/li>\n<li>breaks the problem into sets of 3 co-ordinate (x,y) arrangements for each polygon line segment (brought up to 3 by the point chosen by the user) &#8230;<\/li>\n<li>for each of these consider the three points as a triangle and use <a target=_blank title=\"Heron's Formula\" href='http:\/\/www.mathopenref.com\/heronsformula.html'>Heron&#8217;s Formula<\/a> to calculate the triangle area<br \/>\n<code><br \/>\nfunction herons_formula_triangle_area(x1, y1, x2, y2, x3, y3) {<br \/>\n  var a=Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));<br \/>\n  var b=Math.sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));<br \/>\n  var c=Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));<br \/>\n  var s=eval((a + b + c) \/ 2.0);<br \/>\n  return Math.sqrt(s * (s - a) * (s - b) * (s - c));<br \/>\n}<br \/>\n<\/code> &#8230;<\/li>\n<li>the base value in &#8220;area=base x height \/ 2&#8221; (area of a triangle) can be calculated as the line segment length (square root of the x co-ordinate difference squared plus the y co-ordinate difference squared)<br \/>\n<code><br \/>\nfunction find_dist(x1, y1, x2, y2) {<br \/>\n  return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));<br \/>\n}<br \/>\n<\/code> &#8230;<\/li>\n<li>so height=area x 2 \/ base &#8230;<br \/>\n<code><br \/>\nfunction calcdist() {<br \/>\n  var theseobjs, area=0.0, base=0.0, height=0.0, smallestijh=-1;<br \/>\n  var thesexy;<br \/>\n  eval(\"aconto.getElementById('\" + midis + \"').title='other';\");<br \/>\n  smallesth=-1.0;<br \/>\n  theseobjs=objects[snum].split(';');<br \/>\n  thesexy=theseobjs[1].split(',');<br \/>\n  for (var ijh=2; ijh&lt;eval(-2 + (thesexy.length \/ 1)); ijh+=2) {<br \/>\n         area=herons_formula_triangle_area(x, y, thesexy[eval(-2 + ijh)],  thesexy[eval(-1 + ijh)], thesexy[ijh],  thesexy[eval(1 + ijh)]);<br \/>\n         base=find_dist(thesexy[eval(-2 + ijh)],  thesexy[eval(-1 + ijh)], thesexy[ijh],  thesexy[eval(1 + ijh)]);<br \/>\n         height=eval((2.0 * area) \/ base);<br \/>\n         if (eval(height) &lt; eval(smallesth) || eval(smallesth) &lt; 0.0) {<br \/>\n           smallesth=height;<br \/>\n         }<br \/>\n  }<br \/>\n  var cnf;<br \/>\n  if (eval(smallesth) &lt; 3) {<br \/>\n   cnf=prompt(\"Sorry, this is not \" + thisobj + \", and it is boiling.  Cancel gives up, other answer will give dictionary view.\",\"\");<br \/>\n  } else if (eval(smallesth) &lt; 10) {<br \/>\n   cnf=prompt(\"Sorry, this is not \" + thisobj + \", and it is very hot.  Cancel gives up, other answer will give dictionary view.\",\"\");<br \/>\n  } else if (eval(smallesth) &lt; 20) {<br \/>\n   cnf=prompt(\"Sorry, this is not \" + thisobj + \", and it is very warm.  Cancel gives up, other answer will give dictionary view.\",\"\");<br \/>\n  } else if (eval(smallesth) &lt; 40) {<br \/>\n   cnf=prompt(\"Sorry, this is not \" + thisobj + \", and it is warm.  Cancel gives up, other answer will give dictionary view.\",\"\");<br \/>\n  } else if (eval(smallesth) &lt; 80) {<br \/>\n   cnf=prompt(\"Sorry, this is not \" + thisobj + \", and it is lukewarm.  Cancel gives up, other answer will give dictionary view.\",\"\");<br \/>\n  } else if (eval(smallesth) &lt; 120) {<br \/>\n   cnf=prompt(\"Sorry, this is not \" + thisobj + \", and it is cool.  Cancel gives up, other answer will give dictionary view.\",\"\");<br \/>\n  } else if (eval(smallesth) &lt; 160) {<br \/>\n   cnf=prompt(\"Sorry, this is not \" + thisobj + \", and it is cold.  Cancel gives up, other answer will give dictionary view.\",\"\");<br \/>\n  } else if (eval(smallesth) &lt; 160) {<br \/>\n   cnf=prompt(\"Sorry, this is not \" + thisobj + \", and it is freezing.  Cancel gives up, other answer will give dictionary view.\",\"\");<br \/>\n  }<br \/>\n  if (cnf == null) {<br \/>\n   eval(\"aconto.getElementById('\" + midis + \"').title='';\");<br \/>\n  } else {<br \/>\n   if (cnf.length == 0) {<br \/>\n    cnf=cnf;<br \/>\n    return true;<br \/>\n   } else {<br \/>\n    eval(\"aconto.getElementById('\" + midis + \"').title='lookup';\");<br \/>\n   }<br \/>\n  }<br \/>\n  return false;<br \/>\n}<br \/>\n<\/code>\n<\/li>\n<li>and our shortest distance can be thought of as the smallest of these &#8220;height&#8221; values (and you can see how we did this above)<\/li>\n<\/ol>\n<p> &#8230; and then the concept of &#8220;boiling&#8221; vs &#8220;very warm&#8221; etcetera etcetera should be worked out by trying it out (with alert box help).<\/p>\n<p>Again, with today&#8217;s work, we are in the area of study of &#8220;overlay&#8221;, the HTML map tag being a well established overlay method linking image data with co-ordinate intelligence, still a useful idea we think.<\/p>\n<p>HTML and Javascript codewise the original <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/under_the_stairs.html_GETME' title='under_the_stairs.html'>under_the_stairs.html<\/a> is unchanged from the way it was way below, but today, with our changed scenario, it is used within an HTML <a target=_blank title='HTML iframe element information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_iframe.asp'>iframe<\/a> element using our Client Pre-emptive Iframe techniques to glean HTML map information, and then reworked as necessary directly into that iframe, and the HTML and Javascript for this is <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/pre_under_the_stairs.html-GETME' title='pre_under_the_stairs.html'>pre_under_the_stairs.html<\/a> changed from yesterday as per <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/pre_under_the_stairs.html-GETME' title='pre_under_the_stairs.html'>this link<\/a>.<\/p>\n<p>This could all become very much clearer when you try a <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/pre_under_the_stairs.html' title='ESL Under The Stairs Game Overlay Primer Tutorial'>live run<\/a> and we hope it leaves you with some ideas to try out yourself in a project you are working on.<\/p>\n<hr>\n<p id='eutsgopt'>Previous relevant <a target=_blank title='ESL Under The Stairs Game Overlay Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/esl-under-the-stairs-game-overlay-primer-tutorial\/'>ESL Under The Stairs Game Overlay Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href='http:\/\/www.rjmprogramming.com.au\/pre_under_the_stairs.html' title='ESL Under The Stairs Game Overlay Primer Tutorial'><img decoding=\"async\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/pre_under_the_stairs.jpg\"  \/><\/a><p class=\"wp-caption-text\">ESL Under The Stairs Game Overlay Primer Tutorial<\/p><\/div>\n<p>The HTML <a target=_blank title='HTML map element information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_map.asp'>map<\/a> element can be used in a variety of ways, two of which we hone in on with today&#8217;s ESL Vocabulary game &#8220;Under the Stairs&#8221;, a revisit of our previous <a target=_blank title='English Learning - Vocabulary - Under The Stairs' href='#elvuts'>English Learning &#8211; Vocabulary &#8211; Under The Stairs<\/a> is shown below, where that same HTML map element used then, today, starts as &#8230;<\/p>\n<ol>\n<li>a jigsaw &#8220;overlay&#8221; to the underlying image (in that we try to cover the whole area of the image with clickable HTML <a target=_blank title='HTML area element information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_area.asp'>area<\/a> &#8220;polygon&#8221; segments (the so called &#8220;Click and be Prompted&#8221; mode of use)) &#8230; but if the user selects a &#8220;Find Prompted Object&#8221; mode of use that same HTML map element is reworked to become like &#8230;<\/li>\n<li>a &#8220;Where&#8217;s Wally&#8221; scenario where the computer prompts the user for what they should click on, where the HTML map element has one defined HTML area tag plus one other default &#8220;nonhref&#8221; HTML area tag<\/li>\n<\/ol>\n<p>Again, we are in the area of study of &#8220;overlay&#8221;, the HTML map tag being a well established overlay method linking image data with co-ordinate intelligence, still a useful idea we think.<\/p>\n<p>HTML and Javascript codewise the original <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/under_the_stairs.html_GETME' title='under_the_stairs.html'>under_the_stairs.html<\/a> is unchanged from the way it was below, but today, with our changed scenario, it is used within an HTML <a target=_blank title='HTML iframe element information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_iframe.asp'>iframe<\/a> element using our Client Pre-emptive Iframe techniques to glean HTML map information, and then reworked as necessary directly into that iframe, and the HTML and Javascript for this is <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/pre_under_the_stairs.html_GETME' title='pre_under_the_stairs.html'>pre_under_the_stairs.html<\/a> channeling those oft-mentioned CSS techniques &#8230;<\/p>\n<ol>\n<li><a target=_blank title='CSS position:absolute information from w3schools' href='http:\/\/www.w3schools.com\/cssref\/pr_class_position.asp'>position:absolute<\/a> property<\/li>\n<li><a target=_blank title='CSS z-index information from w3schools' href='http:\/\/www.w3schools.com\/cssref\/pr_pos_z-index.asp'>z-index<\/a><\/li>\n<li><a target=_blank title='CSS opacity property information from w3schools' href='http:\/\/www.w3schools.com\/cssref\/css3_pr_opacity.asp'>opacity<\/a><\/li>\n<\/ol>\n<p>The &#8220;overlay&#8221; concept comes into play, too, for the user to control the mode of use of the web application (ie. its HTML map element&#8217;s mode of use) via an HTML select tag &#8220;overlayed&#8221; on top of an HTML iframe element which exists that way for 20 seconds allowing the user to choose that other mode of use should they be interested.<\/p>\n<p>This could all become much clearer when you try a <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/pre_under_the_stairs.html' title='ESL Under The Stairs Game Overlay Primer Tutorial'>live run<\/a> and we hope it leaves you with some ideas to try out yourself in a project you are working on.<\/p>\n<hr>\n<p id='elvuts'>Previous relevant <a target=_blank title='English Learning - Vocabulary - Under The Stairs' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/english-learning-vocabulary-under-the-stairs\/'>English Learning &#8211; Vocabulary &#8211; Under The Stairs<\/a> is shown below.<\/p>\n<p><div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href='http:\/\/www.rjmprogramming.com.au\/under_the_stairs.html' title='Under The Stairs - Click to start class'><img loading=\"lazy\" decoding=\"async\" style=\"zoom: 30%;\" src=\"http:\/\/www.rjmprogramming.com.au\/Under_The_Stairs.jpg\" usemap=\"#ff92814\" width=\"2090\" height=\"1399\" alt=\"click map\" border=\"0\" \/><\/a><p class=\"wp-caption-text\">English Learning - Vocabulary - Under The Stairs<\/p><\/div><br \/>\n<a target=_blank href='http:\/\/www.rjmprogramming.com.au\/under_the_stairs.html' title='Under The Stairs - Click to start class'>Click to start class.  How many things can you name?<\/a><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d1069' onclick='var dv=document.getElementById(\"d1069\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?cat=45#content\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d1069' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d18180' onclick='var dv=document.getElementById(\"d18180\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/map\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d18180' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d18203' onclick='var dv=document.getElementById(\"d18203\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/vocabulary\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d18203' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>As we saw yesterday, the HTML map element can be used in a variety of ways, two of which we hone in on with today&#8217;s ESL Vocabulary Getting Warmer Game Tutorial, a variation on yesterday&#8217;s ESL Under The Stairs Game &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/esl-vocabulary-getting-warmer-game-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,13,15,37],"tags":[281,396,476,477,484,576,587,652,745,752,894,997,1319,1388,1453],"class_list":["post-18203","post","type-post","status-publish","format-standard","hentry","category-elearning","category-esl","category-games","category-tutorials","tag-css","tag-esl","tag-game","tag-games-2","tag-geometry","tag-html","tag-iframe","tag-javascript","tag-map","tag-mathematics","tag-overlay","tag-programming","tag-tutorial","tag-vocabulary","tag-word-game"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/18203"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=18203"}],"version-history":[{"count":5,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/18203\/revisions"}],"predecessor-version":[{"id":22472,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/18203\/revisions\/22472"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=18203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=18203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=18203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}