{"id":24134,"date":"2016-08-20T03:01:58","date_gmt":"2016-08-19T17:01:58","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=24134"},"modified":"2019-11-09T18:12:56","modified_gmt":"2019-11-09T08:12:56","slug":"html5-device-orientation-events-game-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/html5-device-orientation-events-game-tutorial\/","title":{"rendered":"HTML5 Device Orientation Events Game Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/yaw_etc.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"HTML5 Device Orientation Events Game Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/yaw_etc.jpg\"  \/><\/a><p class=\"wp-caption-text\">HTML5 Device Orientation Events Game Tutorial<\/p><\/div>\n<p>Today we&#8217;ve written a web application suiting mobile devices, but probably not many laptops. That is because we are harnessing the power of the Device Orientation (today) and Device Motion (at a later date) events new to HTML5, and very well explained at this <a target=_blank title='Device Orientation and Device Motion events' href='http:\/\/www.html5rocks.com\/en\/tutorials\/device\/orientation\/'>tremendous link<\/a>, thanks.<\/p>\n<p>If you use a mobile device regularly, you&#8217;ll probably have seen mobile and web applications making use of the fact that the mobile device being used is moving itself, and has its screen orientation an option, rather than an awkwardly controlled hardware setting.  These dynamisms of what we are talking about harnessing today, and we closely follow the leads of the code supplied in the link above, and build a &#8220;Device Orientation&#8221; game based on these HTML5 and Javascript based smarts.<\/p>\n<p>The bottom line of this is that with this functionality we can glean the 3 rotations of the mobile device relative to the world around it, termed as &#8230;<\/p>\n<ul>\n<li>&#8220;Alpha&#8221; &#8230; or Direction, or Bearing, or in shipping &#8220;motion&#8221; terms, <a target=_blank href=\"https:\/\/en.wikipedia.org\/wiki\/Ship_motions\" title='Ship motion information from Wikipedia ... thanks'>&#8220;yaw&#8221;<\/a><\/li>\n<li>&#8220;Beta&#8221; &#8230; or Tilt Front\/Back, or in shipping &#8220;motion&#8221; terms, <a target=_blank href=\"https:\/\/en.wikipedia.org\/wiki\/Ship_motions\" title='Ship motion information from Wikipedia ... thanks'>&#8220;pitch&#8221;<\/a><\/li>\n<li>&#8220;Gamma&#8221; &#8230; or Tilt Left\/Right, or in shipping &#8220;motion&#8221; terms, <a target=_blank href=\"https:\/\/en.wikipedia.org\/wiki\/Ship_motions\" title='Ship motion information from Wikipedia ... thanks'>&#8220;roll&#8221;<\/a><\/li>\n<\/ul>\n<p>Defining those, our game can take you into the cockpit of a plane, perhaps, to set you tasks you try to achieve as accurately as possible, in a &#8220;seconds survived&#8221; game of skill and perseverance.<\/p>\n<p>The HTML and Javascript programming source code you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/yaw_etc.html--GETME\">yaw_etc.html<\/a> does not have to be played as a game in its <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/yaw_etc.html\">live run<\/a> form, and in that &#8220;non-game&#8221; mode of use, just gets you used to the way the three rotations above happen for mobile devices where the Javascript &#8230;<\/p>\n<p><code><br \/>\n&lt;script type='text\/javascript'&gt;<br \/>\nif (window.DeviceOrientationEvent) {<br \/>\n  \/\/ You're in business with HTML5 Device Orientation Events<br \/>\n}<br \/>\n&lt;\/script&gt;<br \/>\n<\/code> <\/p>\n<p> &#8230; which, happily, is the case for the <a target=_blank title='iPad screenshot' href='http:\/\/www.rjmprogramming.com.au\/Mac\/iPad\/siri_setup.jpg'>iPad screenshot<\/a> of today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/yaw_etc.jpg\" title='Tutorial picture is screenshot off iPad'>tutorial picture<\/a>.<\/p>\n<p>Image helping websites we&#8217;d like to thank are &#8230;<\/p>\n<ul>\n<li><a target=_blank title='Cockpit image' href='http:\/\/www.mobogenie.com\/download-ship-parking-simulation-3d-489590.html'>Cockpit<\/a><\/li>\n<li><a target=_blank title='Thanks to this compass needle image resource ... http:\/\/marylandlearninglinks.org\/wp-content\/themes\/learning-links\/img\/compass-needle.png' href='\/\/www.rjmprogramming.com.au\/HTMLCSS\/compass-needle.png'>Compass Needle<\/a><\/li>\n<\/ul>\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='#d24134' onclick='var dv=document.getElementById(\"d24134\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/html5\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d24134' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Today we&#8217;ve written a web application suiting mobile devices, but probably not many laptops. That is because we are harnessing the power of the Device Orientation (today) and Device Motion (at a later date) events new to HTML5, and very &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/html5-device-orientation-events-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,14,15,37],"tags":[1970,281,1971,354,400,476,477,576,578,590,630,652,795,1969,889,997,1072,1776,1319,1402],"class_list":["post-24134","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-games","category-tutorials","tag-bearing","tag-css","tag-direction","tag-dom","tag-event","tag-game","tag-games-2","tag-html","tag-html5","tag-image","tag-ipad","tag-javascript","tag-mobile","tag-mobile-device","tag-orientation","tag-programming","tag-rotation","tag-screenshot","tag-tutorial","tag-web-application"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/24134"}],"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=24134"}],"version-history":[{"count":8,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/24134\/revisions"}],"predecessor-version":[{"id":47119,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/24134\/revisions\/47119"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=24134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=24134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=24134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}