{"id":32400,"date":"2017-08-27T03:01:44","date_gmt":"2017-08-26T17:01:44","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=32400"},"modified":"2017-08-26T18:16:45","modified_gmt":"2017-08-26T08:16:45","slug":"yui-library-par-three-golf-game-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/yui-library-par-three-golf-game-primer-tutorial\/","title":{"rendered":"YUI Library Par Three Golf Game Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golf_par_three.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"YUI Library Par Three Golf Game Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golf_par_three.jpg\" title=\"YUI Library Par Three Golf Game Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">YUI Library Par Three Golf Game Primer Tutorial<\/p><\/div>\n<p>When last we created a web application golf game, with <a title='HTML Canvas Golf Accuracy Game Primer Tutorial' href='#htmlcgagpt'>HTML Canvas Golf Accuracy Game Primer Tutorial<\/a>, we used an HTML(5) canvas element, but today we thank <a target=_blank title='Great help, thanks' href='https:\/\/yuilibrary.com\/yui\/docs\/anim\/curve.html'>YUI Library: Animating Along a Curved Path<\/a> for the incredibly good <a target=_blank title='YUI 3 library by Yahoo' href='http:\/\/yuilibrary.com\/'>Javascript library code<\/a> (by <a target=_blank title='Yahoo' href='http:\/\/www.yahoo.com'>Yahoo<\/a>) there regarding animations and curves.<\/p>\n<p>Studying the link above, we realized the definition of a curve can represent the definition of the shots in a Par 3 Golf Hole.  So, we adjusted that elegant YUI code to intervene in CSS and Javascript, as needed, to &#8220;change things up&#8221; to turn this into a game.  We think a game has more interest when there is a scoring mechanism.  We&#8217;re not hung up on this though, but do like to offer the more competitive among us a means by which they can compare notes with previous attempts and\/or other users playing the same game, perhaps &#8230; collaboration later, methinks!  Is it the chicken or egg?  Do you invent the game, or the scoring mechanism, that is the question?  Today, we invented the game, and the scoring mechanism came after.  Hope it&#8217;s not too lame but it goes like &#8230;<\/p>\n<blockquote><p>\nDrag adjust Bunker and\/or Lake (and\/or, perhaps, Tee and\/or Green) positions to &#8230; end up with a (shown to you) &#8220;curve of golf shots&#8221; whereby maximum points are scored when the three shots you play go from longest through to middle range through to shortest distances, in order, and if you satisfy this you score for the distance of those shots totalled in relation to the number of golf holes you play <font size=1>&#8230; as easy as falling off a log, really?!<\/font>\n<\/p><\/blockquote>\n<p>Maybe you will also take an interest in that topmost link, and see a different opportunity.  In which case, as you create the game from its pieces (presented to you), please don&#8217;t be held up for hours the way I was, with a &#8220;non defined <i>getX<\/i> function error&#8221; <font size=1>(how&#8217;d I know &#8230; think, web browser web inspectors)<\/font> because I&#8217;d forgotten to <b>encase<\/b> a lot of the HTML elements within a &#8230;<\/p>\n<p><code><br \/>\n<b>&lt;div id=\"example\"&gt;<\/b><br \/>\n&lt;!-- lots of other Par 3 Golf Game HTML elements here --&gt;<br \/>\n<b>&lt;\/div&gt;<\/b><br \/>\n<\/code><\/p>\n<p> &#8230; enabling the <i>getX<\/i> function (within the YUI library) be properly accessed <font size=2>&#8230; trap for young <font size=1>(at heart)<\/font> players, methinks?!<\/font><\/p>\n<p>Feel free to <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golf_par_three.html\" title='Click picture'>have a go<\/a> and\/or to peruse the mostly YUI library HTML and Javascript and CSS <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golf_par_three.html_GETME\" title=\"golf_par_three.html\"> golf_par_three.html<\/a> code.<\/p>\n<hr>\n<p id='htmlcgagpt'>Previous relevant <a target=_blank title='HTML Canvas Golf Accuracy Game Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/html-canvas-golf-accuracy-game-primer-tutorial\/'>HTML Canvas Golf Accuracy 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\/golfshotcanvas.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"HTML Canvas Golf Accuracy Game Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golfshotcanvas.jpg\" title=\"HTML Canvas Golf Accuracy Game Primer Tutorial\"    \/><\/a><p class=\"wp-caption-text\">HTML Canvas Golf Accuracy Game Primer Tutorial<\/p><\/div>\n<p>The HTML <a target=_blank title='HTML Canvas element information from w3schools' href='http:\/\/www.w3schools.com\/tags\/ref_canvas.asp'>Canvas<\/a> element is great for games where you draw your own graphics based on interaction from the user &#8230; a great tool to have in your GUI toolbox &#8230;<\/p>\n<blockquote class=\"rightbq\"><p>\nyou download an app and start playing.\n<\/p><\/blockquote>\n<p><\/p>\n<p>A lot of the logic of these games stem from when a user clicks on the <i>canvas<\/i> element &#8230; translation:<br \/>\n&nbsp;<\/p>\n<blockquote class=\"rightbq\"><p>\ndon&#8217;t read any rules of the game and just start clicking away <strike>man<\/strike> &#8230; person.\n<\/p><\/blockquote>\n<p><\/p>\n<p>Lots of these games are based on sport  &#8230; translation:<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<blockquote class=\"rightbq\"><p>\ndoh!  show me the ball!  show me the ball!\n<\/p><\/blockquote>\n<p><\/p>\n<p>And quite often that sport is golf  &#8230; translation:<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<blockquote class=\"rightbq\"><p>\npass me the plus fours <strike>man<\/strike> &#8230; person &#8230; and forget the rules &#8230; show me the ball!  show me the ball!\n<\/p><\/blockquote>\n<p><\/p>\n<p>Today, if you&#8217;d like to <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golfshotcanvas.html\">play<\/a>, we get the user to click twice to simulate the start and end position of their golf shot, the direction and size of which is predetermined, and shown to them &#8230; translation:<br \/>\n&nbsp;<\/p>\n<blockquote class=\"rightbq\"><p>\nwhat?!  no ball &#8230; well then, show me the wrestler.\n<\/p><\/blockquote>\n<p><\/p>\n<p>Today we don&#8217;t show a ball, as such &#8230; it&#8217;s too small &#8230; translation:<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<blockquote class=\"rightbq\"><p>\nwe need this room for another meeting.<br \/>\n&nbsp;\n<\/p><\/blockquote>\n<p><\/p>\n<p>Hope you enjoy playing the game derived from <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/golfshotcanvas.html_GETME\" totle=\"golfshotcanvas.html\">golfshotcanvas.html<\/a> &#8230; you start with score of 3000 and excel by how many goes you survive with a score &#8230; translation:<\/p>\n<blockquote class=\"rightbq\"><p>\nbye.<br \/>\n&nbsp;<br \/>\nturn out the lights as you go.\n<\/p><\/blockquote>\n<p><\/p>\n<p>If you&#8217;re looking for <a target=_blank title='?' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/faint_grass_pattern_204850.jpg'>grass<\/a> <strike>man<\/strike> &#8230; person &#8230; the free background image came from <a target=_blank href=\"http:\/\/all-free-download.com\/free-photos\/ ... thanks\" title=\"Grass courtesy of http:\/\/all-free-download.com\/free-photos\/ ... thanks\">http:\/\/all-free-download.com\/free-photos\/<\/a> and then was modified for use here via Gimp (good old Gimp &#8230; reduction in Opacity to 40%) &#8230; thanks &#8230; translation:\n<\/p>\n<p><\/p>\n<p>There are night golf ranges you know!!!!<\/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='#d13308' onclick='var dv=document.getElementById(\"d13308\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=canvas\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d13308' 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='#d32400' onclick='var dv=document.getElementById(\"d32400\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/yui\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d32400' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>When last we created a web application golf game, with HTML Canvas Golf Accuracy Game Primer Tutorial, we used an HTML(5) canvas element, but today we thank YUI Library: Animating Along a Curved Path for the incredibly good Javascript library &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/yui-library-par-three-golf-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":[4,12,14,15,37],"tags":[84,281,305,2237,364,476,477,511,576,652,997,2319,1319,1404,2099,1487,1495],"class_list":["post-32400","post","type-post","status-publish","format-standard","hentry","category-animation","category-elearning","category-event-driven-programming","category-games","category-tutorials","tag-animation-2","tag-css","tag-debug","tag-drag","tag-drag-and-drop","tag-game","tag-games-2","tag-golf","tag-html","tag-javascript","tag-programming","tag-score","tag-tutorial","tag-web-browser","tag-web-inspector","tag-yahoo","tag-yui"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/32400"}],"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=32400"}],"version-history":[{"count":5,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/32400\/revisions"}],"predecessor-version":[{"id":32409,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/32400\/revisions\/32409"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=32400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=32400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=32400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}