{"id":29253,"date":"2017-04-01T03:01:57","date_gmt":"2017-03-31T17:01:57","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=29253"},"modified":"2017-04-28T18:51:13","modified_gmt":"2017-04-28T08:51:13","slug":"close-relatives-game-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/close-relatives-game-primer-tutorial\/","title":{"rendered":"Close Relatives Game Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/close_relatives.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Close Relatives Game Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/close_relatives.jpg\" title=\"Close Relatives Game Primer Tutorial\"   \/><\/a><p class=\"wp-caption-text\">Close Relatives Game Primer Tutorial<\/p><\/div>\n<p>We&#8217;ve got an <a target=_blank title='ESL information from Wikipedia ... thanks' href='https:\/\/en.m.wikipedia.org\/wiki\/English_as_a_second_or_foreign_language'>ESL<\/a> game, written in HTML and Javascript today, that we&#8217;ve called &#8220;Close Relatives Game&#8221; and its main feature is an HTML <a target=_blank title='HTML table element information from W3schools' href='http:\/\/www.w3schools.com\/tags\/tag_table.asp'>table<\/a> element, whose contents is filled out via the data of &#8230;<\/p>\n<p><code>an array of Javascript objects<\/code><\/p>\n<p> &#8230; the index of which is chosen by our <b>favourite<\/b> (Javascript) random selection technique &#8230;<\/p>\n<p><code><br \/>\n&lt;script type='text\/javascript'&gt;<br \/>\nvar vsnw=[0,0,0,0];<br \/>\nvar which=0, score=0, goes=0;<br \/>\nvar defsel='&lt;select id=? onchange=\"changed(this);\"&gt;&lt;option value=\"a\"&gt;a&lt;\/option&gt;&lt;option value=\"b\"&gt;b&lt;\/option&gt;&lt;option value=\"c\"&gt;c&lt;\/option&gt;&lt;option value=\"d\"&gt;d&lt;\/option&gt;&lt;option value=\"e\"&gt;e&lt;\/option&gt;&lt;option value=\"f\"&gt;f&lt;\/option&gt;&lt;option value=\"g\"&gt;g&lt;\/option&gt;&lt;option value=\"h\"&gt;h&lt;\/option&gt;&lt;option value=\"i\"&gt;i&lt;\/option&gt;&lt;option value=\"j\"&gt;j&lt;\/option&gt;&lt;option value=\"k\"&gt;k&lt;\/option&gt;&lt;option value=\"l\"&gt;l&lt;\/option&gt;&lt;option value=\"m\"&gt;m&lt;\/option&gt;&lt;option value=\"n\"&gt;n&lt;\/option&gt;&lt;option value=\"o\"&gt;o&lt;\/option&gt;&lt;option value=\"p\"&gt;p&lt;\/option&gt;&lt;option value=\"q\"&gt;q&lt;\/option&gt;&lt;option value=\"r\"&gt;r&lt;\/option&gt;&lt;option value=\"s\"&gt;s&lt;\/option&gt;&lt;option value=\"t\"&gt;t&lt;\/option&gt;&lt;option value=\"u\"&gt;u&lt;\/option&gt;&lt;option value=\"v\"&gt;v&lt;\/option&gt;&lt;option value=\"w\"&gt;w&lt;\/option&gt;&lt;option value=\"x\"&gt;x&lt;\/option&gt;&lt;option value=\"y\"&gt;y&lt;\/option&gt;&lt;option value=\"z\"&gt;z&lt;\/option&gt;&lt;\/select&gt;';<br \/>\n<i>function pickobject()<\/i> {<br \/>\n  var tdbit='',j,k;<br \/>\n  which=<b>Math.floor(Math.random() * thedefaults.length)<\/b>;<br \/>\n  document.getElementById('nameof').innerHTML=thedefaults[which].name;<br \/>\n  vsnw=thedefaults[which].numwords;<br \/>\n  for (j=0; j&lt;4; j++) {<br \/>\n    tdbit='';<br \/>\n    document.getElementById('clue' + eval(1 + j)).innerHTML=thedefaults[which].clues[j];<br \/>\n    for (k=0; k&lt;thedefaults[which].clues[j].length; k++) {<br \/>\n     if (thedefaults[which].clues[j].substring(k, eval(1 + k)) == \" \") {<br \/>\n      tdbit+=\"&lt;select style='background-color:yellow;'&gt;&lt;option value=' '&gt; &lt;\/option&gt;&lt;\/select&gt;\";<br \/>\n     } else {<br \/>\n      tdbit+=defsel.replace('?', 'ans_' + eval(1 + j) + '_' + eval(1 + k)).replace(\"&gt;\" + thedefaults[which].clues[j].substring(k, eval(1 + k)) + \"&lt;\",\" selected&gt;\" + thedefaults[which].clues[j].substring(k, eval(1 + k)) + \"&lt;\").replace(\"&gt;\" + thedefaults[which].answers[j].substring(k, eval(1 + k)) + \"&lt;\",\" title=' '&gt;\" + thedefaults[which].answers[j].substring(k, eval(1 + k)) + \"&lt;\");<br \/>\n     }<br \/>\n    }<br \/>\n    document.getElementById('answer' + eval(1 + j)).innerHTML=tdbit;<br \/>\n  }<br \/>\n}<br \/>\n<b><\/b><br \/>\n&lt;\/script&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body onload=' <i>pickobject();<\/i> ' style='background-color:yellow;'&gt;<br \/>\n<\/code><\/p>\n<p>Featuring in the Javascript coding for Object use is a &#8220;Constructor&#8221; function feeling arrangement as <i>an array of Javascript objects<\/i> is initialized and that &#8220;Constructor&#8221; function is called via keyword <b>new<\/b> as per &#8230;<\/p>\n<p><code><br \/>\nvar thedefaults = [<br \/>\n <b>new<\/b> Close_Relative('Category One',['clue1of4|answer1of4','clue2of4|answer2of4','clue3of4|answer3of4','clue4of4|answer4of4']),<br \/>\n <b>new<\/b> Close_Relative('Last Category',['clue1of4|answer1of4','clue2of4|answer2of4','clue3of4|answer3of4','clue4of4|answer4of4'])<br \/>\n];<br \/>\n<\/code><\/p>\n<p> &#8230; type of usage for our Constructor &#8230;<\/p>\n<p><code><br \/>\nfunction Close_Relative(name, darray) {<br \/>\n  this.name = name;<br \/>\n  this.clues = [darray[0].split('|')[0], darray[1].split('|')[0], darray[2].split('|')[0], darray[3].split('|')[0]];<br \/>\n  this.answers = [darray[0].split('|')[1], darray[1].split('|')[1], darray[2].split('|')[1], darray[3].split('|')[1]];<br \/>\n  this.numwords = [darray[0].split('|')[0].split(' ').length, darray[1].split('|')[0].split(' ').length, darray[2].split('|')[0].split(' ').length, darray[3].split('|')[0].split(' ').length];<br \/>\n}<br \/>\n<\/code><\/p>\n<p>As far as content goes we&#8217;d like to thank <a target=_blank title='Science Puzzles for Young Einsteins by Helene Hovanec ISBN 0-8069-3542-1' href='https:\/\/books.google.com.au\/books?isbn=0806958499'>Science Puzzles for Young Einsteins<\/a> by Helene Hovanec ISBN 0-8069-3542-1 &#8230; thanks for the inspiration.<\/p>\n<p>So here&#8217;s the HTML and Javascript and CSS going into this ESL game design above you could call <a target=_blank title='close_relatives.html' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/close_relatives.html_GETME'>close_relatives.html<\/a> for your perusal, or you can try with this <a target=_blank title='close_relatives.html' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/close_relatives.html'>live run<\/a> link.  We will be returning, because there is more to show you here, regarding making this ESL web application game better.  We hope you hang around for the whole thread of blog postings on this.<\/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='#d29253' onclick='var dv=document.getElementById(\"d29253\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/esl\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d29253' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;ve got an ESL game, written in HTML and Javascript today, that we&#8217;ve called &#8220;Close Relatives Game&#8221; and its main feature is an HTML table element, whose contents is filled out via the data of &#8230; an array of Javascript &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/close-relatives-game-primer-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,28,37],"tags":[2078,396,476,477,576,652,849,2010,875,997,1319,1452],"class_list":["post-29253","post","type-post","status-publish","format-standard","hentry","category-elearning","category-esl","category-games","category-oop","category-tutorials","tag-constructor","tag-esl","tag-game","tag-games-2","tag-html","tag-javascript","tag-object","tag-object-oriented-programming","tag-oop","tag-programming","tag-tutorial","tag-word"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/29253"}],"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=29253"}],"version-history":[{"count":10,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/29253\/revisions"}],"predecessor-version":[{"id":29873,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/29253\/revisions\/29873"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=29253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=29253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=29253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}