{"id":53938,"date":"2021-11-15T03:01:54","date_gmt":"2021-11-14T17:01:54","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=53938"},"modified":"2021-11-17T20:48:02","modified_gmt":"2021-11-17T10:48:02","slug":"ants-up-a-wall-game-fixed-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/ants-up-a-wall-game-fixed-tutorial\/","title":{"rendered":"Ants Up a Wall Game Fixed Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/ants_up_the_wall.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Ants Up a Wall Game Fixed Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/ants_up_the_wall_modified.jpg\" title=\"Ants Up a Wall Game Fixed Tutorial\"   \/><\/a><p class=\"wp-caption-text\">Ants Up a Wall Game Fixed Tutorial<\/p><\/div>\n<p>It&#8217;s often hard, with web application games, to know how much &#8220;randomosity&#8221; is good.  Too little, and little interest, but too much and the game might become scatter-brained, and thereby less interesting at the other end of the spectrum.<\/p>\n<p>Do not know whether it tweaked with you, but yesterday&#8217;s <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/ITblog\/hashtag-navigation-scrolling-tweaks-primer-tutorial\/' title='Hashtag Navigation Scrolling Tweaks Primer Tutorial'>Hashtag Navigation Scrolling Tweaks Primer Tutorial<\/a> (<a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/hashtag_and_a_bit.html_GETME\" title=\"hashtag_and_a_bit.html\">hashtag_and_a_bit.html<\/a>&#8216;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/hashtag_and_a_bit.html\" title=\"Click picture\">web application<\/a>) used a technique of interest to us, the &#8230;<\/p>\n<p><code><br \/>\nCSS <a target=_blank title='CSS position property information from W3schools' href='https:\/\/www.w3schools.com\/cssref\/pr_class_position.asp'>\"position\"<\/a> transition change from its default \"relative\" value to \"fixed\" via Javascript DOM<br \/>\n<\/code><\/p>\n<p> &#8230; the &#8220;relative&#8221; initial setting getting us to a suitable &#8220;y&#8221; (or &#8220;top&#8221;) positioning and a &#8220;less suitable for our purposes&#8221; &#8220;x&#8221; (or &#8220;left&#8221;) positioning, which our &#8230;<\/p>\n<ol>\n<li>&#8220;position&#8221; property &#8220;fixed&#8221; change, in anticipation of scrolling that might happen later, can be supplemented by &#8230;<\/l>\n<li>glean a good &#8220;top&#8221; (or &#8220;y&#8221;) co-ordinate via [element].<a target=_blank title='Javascript getBoundingClientRect information from W3schools' href='https:\/\/www.w3schools.com\/jsref\/met_element_getboundingclientrect.asp'>getBoundingClientRect<\/a>().top (of its naturally occurring and suitable &#8220;top&#8221; position)<\/li>\n<li>forced suitable &#8220;left&#8221; (or &#8220;x&#8221;) co-ordinate to suit our purposes (ended up at 220 to suit an iPhone)<\/li>\n<\/ol>\n<p> &#8230; the best of both woooorrrrrlllllldddsss, we reckon?!<\/p>\n<p>And today, we&#8217;re onto improving <a title='Ants Up a Wall Game Primer Tutorial' href='#auwgpt'>Ants Up a Wall Game Primer Tutorial<\/a>&#8216;s &#8220;Ants Up the Wall&#8221; game, adding randomosity, this time introducing toggles of the CSS &#8220;position&#8221; property between &#8220;absolute&#8221; and &#8220;fixed&#8221;, so that you get &#8230;<\/p>\n<ul>\n<li>normal calm ants &#8230; that can become &#8230;<\/li>\n<li>&#8220;transfixed&#8221; (ie. CSS position: fixed; and no movement) &#8230; but come out of that &#8230;<\/li>\n<li>energised ants &#8230; that can move faster and in a different direction<\/li>\n<\/ul>\n<p>To change the scoring, or not to change the scoring, that is the question?  And the answer is &#8230;<\/p>\n<blockquote><p>\nNo\n<\/p><\/blockquote>\n<p> &#8230; we&#8217;ll just leave it to the user to tweak to the better tactics now with <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/ants_up_the_wall.html-GETME\" tile=\"ants_up_the_wall.html\">our changed<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/ants_up_the_wall.html-GETME\" title=\"ants_up_the_wall.html\">ants_up_the_wall.html<\/a> &#8230;<\/p>\n<div class=\"container demo animated\"><iframe id=antif style='width:100%;height:750px;' src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/ants_up_the_wall.html\"><\/iframe><\/div>\n<p> &#8230; <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/ants_up_the_wall.html\" title=\"Click picture\">&#8220;Ants Up the Wall&#8221; game<\/a>!<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/ants-up-a-wall-game-fixed-tutorial\/'>Ants Up a Wall Game Fixed Tutorial<\/a>.<\/p-->\n<hr>\n<p id='auwgpt'>Previous relevant <a target=_blank title='Ants Up a Wall Game Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/ants-up-a-wall-game-primer-tutorial\/'>Ants Up a Wall 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\/ants_up_the_wall.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Ants Up a Wall Game Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/ants_up_the_wall.jpg\" title=\"Ants Up a Wall Game Primer Tutorial\"   \/><\/a><p class=\"wp-caption-text\">Ants Up a Wall Game Primer Tutorial<\/p><\/div>\n<p>We&#8217;d like to thank the brick wall inspiration of this <a target=_blank title='Brick wall idea, thanks' href='http:\/\/lea.verou.me\/css3patterns\/#bricks'>very useful link<\/a> we talked about yesterday with <a target=_blank  href='https:\/\/www.rjmprogramming.com.au\/ITblog\/css-style-display-and-visibility-tall-poppies-tutorial\/'>CSS Style Display and Visibility Tall Poppies Tutorial<\/a> for the reason to take on our &#8220;Ants Up a Wall&#8221; game today.<\/p>\n<p>Today, though, we arrange it that the wall sits down the bottom of the screen, where, as you would all know, any self respecting ant will emerge from, if they take an interest in your computer equipment.<\/p>\n<blockquote><p>\nYour mission, <a target=_blank title='?' href='https:\/\/www.youtube.com\/watch?v=0TiqXFssKMY'>Jim<\/a>, should you decide to accept it is to protect your food supplies on the wall from marauding ants.  We&#8217;ve assembled a crack team for you, Jim, or you can come up with your own Bee Team (chortle, chortle).  As always, should you or any of your I.M. Force be caught or killed, the Secretary will disavow any knowledge of your actions.\n<\/p><\/blockquote>\n<p>Aspects of today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/ants_up_the_wall.html\" title=\"Click picture\">&#8220;Ants Up a Wall&#8221;<\/a> game&#8217;s HTML and Javascript and CSS <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/ants_up_the_wall.html_GETME\" title=\"ants_up_the_wall.html\">ants_up_the_wall.html<\/a> source code for your perusal &#8230;<\/p>\n<ul>\n<li>brick wall inspired as above, thanks, and represented as an HTML hr (horizontal rule) element, positioned via use of &#8230;<\/li>\n<li>CSS <a target=_blank title='CSS3 calc information' href='https:\/\/www.htmlgoodies.com\/html5\/css\/using-the-css3-calc-function.html'>calc<\/a><\/li>\n<li>CSS <a target=_blank href='https:\/\/www.w3schools.com\/cssref\/css3_pr_transform.asp' title='CSS transform property rotation information from w3schools'>rotation<\/a><\/li>\n<li>Javascript <a target=_blank title='Javascript Object information from w3schools' href='https:\/\/www.w3schools.com\/js\/js_object_constructors.asp'>Object<\/a> OOP style syntax &#8230; for a &#8230;<\/li>\n<li>data structure which is an Array of Javascript (Ant) objects &#8230; and as for yesterday&#8217;s game, all of &#8230;<\/li>\n<li>(<a target=_blank title='Javascript Math.random() information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/jsref_floor.asp'>Math.floor<\/a>(<a target=_blank title='Javascript Math.random() information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/jsref_random.asp'>Math.random()<\/a> * [integerRange]) +\/- [integerOffset])  \/\/ randomosity aid<\/li>\n<li><a target=_blank title='Javascript setTimeout method information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_win_settimeout.asp'><i>setTimeout<\/i><\/a> (and <a target=_blank title='Javascript setInterval method information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_win_setinterval.asp'><i>setInterval<\/i><\/a> (to derive a &#8220;seconds elapsed&#8221; idea to the game)) timer methods &#8230; and, lately, at least &#8230;<\/li>\n<li>Emoji usage<\/li>\n<\/ul>\n<p>The marauding ants need a limit of their numbers, in case users leave the web application running forever, and that is where we relieve memory requirements by using the <a target=_blank title='Javascript Array methods' href='https:\/\/www.w3schools.com\/js\/js_array_methods.asp'>delete<\/a> (array member) method of keeping the (array) indexes constant but save on memory requirements over time.<\/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='#d36510' onclick='var dv=document.getElementById(\"d36510\"); 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='d36510' 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='#d53938' onclick='var dv=document.getElementById(\"d53938\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/position\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d53938' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s often hard, with web application games, to know how much &#8220;randomosity&#8221; is good. Too little, and little interest, but too much and the game might become scatter-brained, and thereby less interesting at the other end of the spectrum. Do &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/ants-up-a-wall-game-fixed-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":[4,12,14,15,37],"tags":[2824,84,2631,2682,2008,281,354,385,3037,476,2208,576,652,3855,1988,997,2047,2945,1917,1107,1209,1319],"class_list":["post-53938","post","type-post","status-publish","format-standard","hentry","category-animation","category-elearning","category-event-driven-programming","category-games","category-tutorials","tag-absolute","tag-animation-2","tag-ants","tag-background-colour","tag-clipart","tag-css","tag-dom","tag-emoji","tag-fixed","tag-game","tag-getboundingclientrect","tag-html","tag-javascript","tag-oops","tag-position","tag-programming","tag-random","tag-relative","tag-scroll","tag-scrolling","tag-style","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/53938"}],"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=53938"}],"version-history":[{"count":11,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/53938\/revisions"}],"predecessor-version":[{"id":53984,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/53938\/revisions\/53984"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=53938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=53938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=53938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}