{"id":27896,"date":"2017-01-30T03:01:20","date_gmt":"2017-01-29T17:01:20","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=27896"},"modified":"2017-01-30T16:00:10","modified_gmt":"2017-01-30T06:00:10","slug":"golden-ratio-game-css-tutorial-2","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/golden-ratio-game-css-tutorial-2\/","title":{"rendered":"Golden Ratio Game CSS Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golden_ratio_game.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Golden Ratio Game CSS Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golden_ratio_game_difficulty.JPG\" title=\"Golden Ratio Game CSS Tutorial\"  style=\"float:left;\"  \/><\/a><p class=\"wp-caption-text\">Golden Ratio Game CSS Tutorial<\/p><\/div>\n<p>We wanted to add some styling to improve on our Golden Ratio Game we started yesterday with our <a title='Golden Ratio Game Primer Tutorial' href='#grgpt'>Golden Ratio Primer Tutorial<\/a>.  These styling improvements relate to us wanting to add a Degree of Difficulty mode of play for the game, because we see that there is scope to &#8230;<\/p>\n<ul>\n<li>make the answer terribly predictable for the whole game<\/li>\n<li>make the rectangles more or less similar in their dimensions approximating the Golden Ratio dimensions<\/li>\n<li>rotate the rectangles and introduce overlaying and non-even display conditions, for obfuscation purposes<\/li>\n<\/ul>\n<p>  &#8230; which allows for scope for some differentiation with the scoring in the game, in that the harder modes of use score more points per correct choice.<\/p>\n<p>Also wanted to introduce a nuanced 3D look to the HTML div elements that are the rectangles in the game.  We found an excellent website <a target=_blank title='Useful website' href='http:\/\/stackoverflow.com\/questions\/33203148\/how-to-make-a-div-box-look-3d\/33203203#33203203'>here<\/a> to help with achieving this with a shadow box and some border effects.<\/p>\n<p>And we add more (of our favourite) CSS <i>backgroundColor<\/i> effects to help section off parts of the game display from others.<\/p>\n<p>As far as the the HTML div element rotations go in that &#8220;Hardest&#8221; level of difficulty (mode of play) we, perhaps, could have arranged a CSS way of doing this, by the same &#8230;<\/p>\n<p><code>location.href=document.URL.split('#')[0].split('?')[0] + '?score=' + score + '&goes=' + goes + '&difficulty=' + this.value;<\/code><\/p>\n<p> &#8230; HTML (select element) <i>difficulty<\/i> &#8220;dropdown&#8221; <i>onchange<\/i> event logic means of doing it, but today, as we&#8217;ve done before, at <a target=_blank title='Analogue Clock Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/analogue-clock-Primer-Tutorial\/'>Analogue Clock Primer Tutorial<\/a>, we&#8217;ve dynamically arranged the three HTML div elements to get three Javascript DOM arranged rotations, as each new set of 3 rectangles is displayed.  See that previous link for the basis of the code used to do this.<\/p>\n<p>So that leaves us with the HTML and Javascript and CSS <a target=_blank title='golden_ratio_game.html' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golden_ratio_game.html-GETME'>golden_ratio_game.html<\/a> is associated with this <a target=_blank title='Click picture' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golden_ratio_game.html'>live run<\/a> link, and which changed in <a target=_blank title='golden_ratio_game.html' href='http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golden_ratio_game.html-GETME'>this way<\/a>.   We hope you try out the game, enjoy it, and perhaps use it as the launching pad for ideas of your own.<\/p>\n<hr>\n<p id='grgpt'>Previous relevant <a target=_blank title='Golden Ratio Game Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/golden-Ratio-game-primer-Tutorial\/'>Golden Ratio Game 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\/HTMLCSS\/golden_ratio_game.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Golden Ratio Game Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golden_ratio_game.JPG\" title=\"Golden Ratio Game Primer Tutorial\"  style=\"float:left;\"  \/><\/a><p class=\"wp-caption-text\">Golden Ratio Game Primer Tutorial<\/p><\/div>\n<p>Today we have a Golden Ratio Game for you.  In mathematics and architectural design, there is a ratio of rectangular dimensions that appeals to the human pysche, and this magical irrational number, close to &#8230;<\/p>\n<p><code>1.6180339887<\/code><\/p>\n<p> &#8230; we gleaned from Wikipedia&#8217;s <a target=_blank title='Golden Ratio information from Wikipedia ... thanks' href='https:\/\/en.m.wikipedia.org\/wiki\/Golden_ratio'>Golden Ratio<\/a> webpage, so, thanks.<\/p>\n<p>These Golden Ratio proportions are no mathematical accident, and you should read more at that Wikipedia link above, which, in summary, tells us that that irrational number above equates to &#8230;<\/p>\n<p><code>(1 + \u221a5) \/ 2<\/code><\/p>\n<p>The code today is HTML with some Javascript DOM workings could be called <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golden_ratio_game.html_GETME\" title=\"golden_ratio_game.html\">golden_ratio_game.html<\/a> And you can try it out with today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golden_ratio_game.html\" title=\"Click picture\">live run<\/a> link, and see whether you can pick what appeals to so many others.  As with many games, it features lots of calls such as &#8230;<br \/>\n<code><br \/>\ncolis[0]=bcols[<a target=_blank title='Math.floor information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/jsref_floor.asp'>Math.floor<\/a>(<a target=_blank title='Math.random information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/jsref_random.asp'>Math.random<\/a>() * bcols.length)];<br \/>\n<\/code><\/p>\n<p> &#8230; to add that element of randomosity to your web application games.<\/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='#d27860' onclick='var dv=document.getElementById(\"d27860\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/game\/\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d27860' 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='#d27896' onclick='var dv=document.getElementById(\"d27896\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/css\/\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d27896' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>We wanted to add some styling to improve on our Golden Ratio Game we started yesterday with our Golden Ratio Primer Tutorial. These styling improvements relate to us wanting to add a Degree of Difficulty mode of play for the &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/golden-ratio-game-css-tutorial-2\/\">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":[1],"tags":[2129,281,354,476,477,2131,576,2130,652,752,997,2132,1212,1319],"class_list":["post-27896","post","type-post","status-publish","format-standard","hentry","category-uncategorised","tag-architecture","tag-css","tag-dom","tag-game","tag-games-2","tag-golden-ratio","tag-html","tag-irrational-number","tag-javascript","tag-mathematics","tag-programming","tag-rectangle","tag-styling","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/27896"}],"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=27896"}],"version-history":[{"count":7,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/27896\/revisions"}],"predecessor-version":[{"id":27920,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/27896\/revisions\/27920"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=27896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=27896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=27896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}