{"author_name":"FoxyGrandpa","cat":"LD #29","comments":[{"author_name":"","time":"April 25, 2014 12:47 pm","epoch":1398448020,"text":"I think this is fine.  With the full &#8220;rolling toolboxes&#8221; I&#8217;ve seen others swinging around here, no one should complain about a couple of utility functions like these.","spam":"N"},{"author_name":"FoxyGrandpa","time":"April 25, 2014 2:35 pm","epoch":1398454500,"text":"I&#8217;ll also may be using Box2dWeb-2.1.a.3.min hopefully that won&#8217;t be a problem either.","spam":"N"}],"epoch":1398447360,"likes":0,"metadata":{"p_key":"32898","p_author":"FoxyGrandpa","p_authorkey":"0","p_urlkey":"68419","p_title":"Base Code, libraries","p_cat":"LD #29","p_event":"LD29","p_time":"1398447360","p_likes":"0","p_comments":"2","p_status":"UPD5","us_key":null,"us_name":null,"us_username":null,"event_start":"1398384000","event_key":"22","event_name":"LD29"},"text":"<p>I&#8217;m completely new to this so sorry if this post is annoying but I think I have to write a post about any core libraries I&#8217;m going to use? So I guess This is where I have to do that.<\/p>\n <hr \/>\n <p>I&#8217;ll be using jquery-1.10.2 (I&#8217;m assuming you don&#8217;t want me to paste all the code in there)<\/p>\n <p>key_status.js Contents:<\/p>\n <blockquote><p>$(function() {<br \/>\n window.keydown = {};<\/p>\n <p>function keyName(event) {<br \/>\n return jQuery.hotkeys.specialKeys[event.which] ||<br \/>\n String.fromCharCode(event.which).toLowerCase();<br \/>\n }<\/p>\n <p>$(document).bind(&#8220;keydown&#8221;, function(event) {<br \/>\n keydown[keyName(event)] = true;<br \/>\n });<\/p>\n <p>$(document).bind(&#8220;keyup&#8221;, function(event) {<br \/>\n keydown[keyName(event)] = false;<br \/>\n });<br \/>\n });<\/p><\/blockquote>\n <p>jquery.hotkeys.js alone with it&#8217;s COMPONENT JSON Contents:<\/p>\n <p>JQUERY.HOTKEYS.JS<\/p>\n <blockquote><p>\/*<br \/>\n * jQuery Hotkeys Plugin<br \/>\n * Copyright 2010, John Resig<br \/>\n * Dual licensed under the MIT or GPL Version 2 licenses.<br \/>\n *<br \/>\n * Based upon the plugin by Tzury Bar Yochay:<br \/>\n * http:\/\/github.com\/tzuryby\/hotkeys<br \/>\n *<br \/>\n * Original idea by:<br \/>\n * Binny V A, http:\/\/www.openjs.com\/scripts\/events\/keyboard_shortcuts\/<br \/>\n *\/<\/p>\n <p>(function(jQuery){<\/p>\n <p>jQuery.hotkeys = {<br \/>\n version: &#8220;0.8+&#8221;,<\/p>\n <p>specialKeys: {<br \/>\n 8: &#8220;backspace&#8221;, 9: &#8220;tab&#8221;, 13: &#8220;return&#8221;, 16: &#8220;shift&#8221;, 17: &#8220;ctrl&#8221;, 18: &#8220;alt&#8221;, 19: &#8220;pause&#8221;,<br \/>\n 20: &#8220;capslock&#8221;, 27: &#8220;esc&#8221;, 32: &#8220;space&#8221;, 33: &#8220;pageup&#8221;, 34: &#8220;pagedown&#8221;, 35: &#8220;end&#8221;, 36: &#8220;home&#8221;,<br \/>\n 37: &#8220;left&#8221;, 38: &#8220;up&#8221;, 39: &#8220;right&#8221;, 40: &#8220;down&#8221;, 45: &#8220;insert&#8221;, 46: &#8220;del&#8221;,<br \/>\n 96: &#8220;0&#8221;, 97: &#8220;1&#8221;, 98: &#8220;2&#8221;, 99: &#8220;3&#8221;, 100: &#8220;4&#8221;, 101: &#8220;5&#8221;, 102: &#8220;6&#8221;, 103: &#8220;7&#8221;,<br \/>\n 104: &#8220;8&#8221;, 105: &#8220;9&#8221;, 106: &#8220;*&#8221;, 107: &#8220;+&#8221;, 109: &#8220;-&#8220;, 110: &#8220;.&#8221;, 111 : &#8220;\/&#8221;,<br \/>\n 112: &#8220;f1&#8221;, 113: &#8220;f2&#8221;, 114: &#8220;f3&#8221;, 115: &#8220;f4&#8221;, 116: &#8220;f5&#8221;, 117: &#8220;f6&#8221;, 118: &#8220;f7&#8221;, 119: &#8220;f8&#8221;,<br \/>\n 120: &#8220;f9&#8221;, 121: &#8220;f10&#8221;, 122: &#8220;f11&#8221;, 123: &#8220;f12&#8221;, 144: &#8220;numlock&#8221;, 145: &#8220;scroll&#8221;, 188: &#8220;,&#8221;, 190: &#8220;.&#8221;,<br \/>\n 191: &#8220;\/&#8221;, 224: &#8220;meta&#8221;<br \/>\n },<\/p>\n <p>shiftNums: {<br \/>\n &#8220;`&#8221;: &#8220;~&#8221;, &#8220;1&#8221;: &#8220;!&#8221;, &#8220;2&#8221;: &#8220;@&#8221;, &#8220;3&#8221;: &#8220;#&#8221;, &#8220;4&#8221;: &#8220;$&#8221;, &#8220;5&#8221;: &#8220;%&#8221;, &#8220;6&#8221;: &#8220;^&#8221;, &#8220;7&#8221;: &#8220;&amp;&#8221;,<br \/>\n &#8220;8&#8221;: &#8220;*&#8221;, &#8220;9&#8221;: &#8220;(&#8220;, &#8220;0&#8221;: &#8220;)&#8221;, &#8220;-&#8220;: &#8220;_&#8221;, &#8220;=&#8221;: &#8220;+&#8221;, &#8220;;&#8221;: &#8220;: &#8220;, &#8220;&#8216;&#8221;: &#8220;\\&#8221;&#8221;, &#8220;,&#8221;: &#8220;&lt;&#8220;,<br \/>\n &#8220;.&#8221;: &#8220;&gt;&#8221;, &#8220;\/&#8221;: &#8220;?&#8221;, &#8220;\\\\&#8221;: &#8220;|&#8221;<br \/>\n }<br \/>\n };<\/p>\n <p>function keyHandler( handleObj ) {<\/p>\n <p>var origHandler = handleObj.handler,<br \/>\n \/\/use namespace as keys so it works with event delegation as well<br \/>\n \/\/will also allow removing listeners of a specific key combination<br \/>\n \/\/and support data objects<br \/>\n keys = (handleObj.namespace || &#8220;&#8221;).toLowerCase().split(&#8221; &#8220;);<br \/>\n keys = jQuery.map(keys, function(key) { return key.split(&#8220;.&#8221;); });<\/p>\n <p>\/\/no need to modify handler if no keys specified<br \/>\n \/\/Added keys[0].substring(0, 12) to work with jQuery ui 1.9.0<br \/>\n \/\/Added accordion, tabs and menu, then jquery ui can use keys.<\/p>\n <p>if (keys.length === 1 &amp;&amp; (keys[0] === &#8220;&#8221; ||<br \/>\n keys[0].substring(0, 12) === &#8220;autocomplete&#8221; ||<br \/>\n keys[0].substring(0, 9) === &#8220;accordion&#8221; ||<br \/>\n keys[0].substring(0, 4) === &#8220;tabs&#8221; ||<br \/>\n keys[0].substring(0, 4) === &#8220;menu&#8221;)) {<br \/>\n return;<br \/>\n }<\/p>\n <p>handleObj.handler = function( event ) {<br \/>\n \/\/ Don&#8217;t fire in text-accepting inputs that we didn&#8217;t directly bind to<br \/>\n \/\/ important to note that $.fn.prop is only available on jquery 1.6+<br \/>\n if ( this !== event.target &amp;&amp; (\/textarea|select\/i.test( event.target.nodeName ) ||<br \/>\n event.target.type === &#8220;text&#8221; || $(event.target).prop(&#8216;contenteditable&#8217;) == &#8216;true&#8217; )) {<br \/>\n return;<br \/>\n }<\/p>\n <p>\/\/ Keypress represents characters, not special keys<br \/>\n var special = event.type !== &#8220;keypress&#8221; &amp;&amp; jQuery.hotkeys.specialKeys[ event.which ],<br \/>\n character = String.fromCharCode( event.which ).toLowerCase(),<br \/>\n key, modif = &#8220;&#8221;, possible = {};<\/p>\n <p>\/\/ check combinations (alt|ctrl|shift+anything)<br \/>\n if ( event.altKey &amp;&amp; special !== &#8220;alt&#8221; ) {<br \/>\n modif += &#8220;alt_&#8221;;<br \/>\n }<\/p>\n <p>if ( event.ctrlKey &amp;&amp; special !== &#8220;ctrl&#8221; ) {<br \/>\n modif += &#8220;ctrl_&#8221;;<br \/>\n }<\/p>\n <p>\/\/ TODO: Need to make sure this works consistently across platforms<br \/>\n if ( event.metaKey &amp;&amp; !event.ctrlKey &amp;&amp; special !== &#8220;meta&#8221; ) {<br \/>\n modif += &#8220;meta_&#8221;;<br \/>\n }<\/p>\n <p>if ( event.shiftKey &amp;&amp; special !== &#8220;shift&#8221; ) {<br \/>\n modif += &#8220;shift_&#8221;;<br \/>\n }<\/p>\n <p>if ( special ) {<br \/>\n possible[ modif + special ] = true;<\/p>\n <p>} else {<br \/>\n possible[ modif + character ] = true;<br \/>\n possible[ modif + jQuery.hotkeys.shiftNums[ character ] ] = true;<\/p>\n <p>\/\/ &#8220;$&#8221; can be triggered as &#8220;Shift+4&#8221; or &#8220;Shift+$&#8221; or just &#8220;$&#8221;<br \/>\n if ( modif === &#8220;shift_&#8221; ) {<br \/>\n possible[ jQuery.hotkeys.shiftNums[ character ] ] = true;<br \/>\n }<br \/>\n }<\/p>\n <p>for ( var i = 0, l = keys.length; i &lt; l; i++ ) {<br \/>\n if ( possible[ keys[i] ] ) {<br \/>\n return origHandler.apply( this, arguments );<br \/>\n }<br \/>\n }<br \/>\n };<br \/>\n }<\/p>\n <p>jQuery.each([ &#8220;keydown&#8221;, &#8220;keyup&#8221;, &#8220;keypress&#8221; ], function() {<br \/>\n jQuery.event.special[ this ] = { add: keyHandler };<br \/>\n });<\/p>\n <p>})( jQuery );<\/p><\/blockquote>\n <p>COMPONENT<\/p>\n <blockquote><p>{<br \/>\n &#8220;name&#8221;: &#8220;jquery.hotkeys&#8221;,<br \/>\n &#8220;repo&#8221;: &#8220;tzuryby\/jquery.hotkeys&#8221;,<br \/>\n &#8220;description&#8221;: &#8220;jquery.hotkeys plugin lets you easily add and remove handlers for keyboard events&#8221;,<br \/>\n &#8220;version&#8221;: &#8220;1.0.0&#8221;,<br \/>\n &#8220;keywords&#8221;: [],<br \/>\n &#8220;dependencies&#8221;: {},<br \/>\n &#8220;development&#8221;: {},<br \/>\n &#8220;license&#8221;: &#8220;MIT&#8221;,<br \/>\n &#8220;main&#8221;: &#8220;jquery.hotkeys.js&#8221;,<br \/>\n &#8220;scripts&#8221;: [<br \/>\n &#8220;jquery.hotkeys.js&#8221;<br \/>\n ]<br \/>\n }<\/p><\/blockquote>\n <p>and Spriter.js Contents:<\/p>\n <blockquote><p>function SpriterAtlas(jsonArray) {<br \/>\n this.srcArray = jsonArray;<br \/>\n this.spriteSheetLocation = jsonArray.meta.image;<\/p>\n <p>this.SpriteSheet;<\/p>\n <p>this.getSprite = function(filename) {<br \/>\n var foundSprite = false;<br \/>\n for (var i = 0; i &lt; this.srcArray.frames.length; i++) {<br \/>\n if (this.srcArray.frames[i].filename == filename) {<br \/>\n var wantedSprite = this.srcArray.frames[i];<br \/>\n return {<br \/>\n srcImage: this.SpriteSheet,<br \/>\n srcx: wantedSprite.frame.x,<br \/>\n srcy: wantedSprite.frame.y,<br \/>\n srcwidth: wantedSprite.frame.w,<br \/>\n srcheight: wantedSprite.frame.h,<br \/>\n width: wantedSprite.frame.w,<br \/>\n height: wantedSprite.frame.h,<br \/>\n scale: 1.0,<br \/>\n draw: function(context, posx, posy) {<br \/>\n context.drawImage(this.srcImage, this.srcx, this.srcy, this.srcwidth, this.srcheight, posx, posy, this.width * this.scale, this.height * this.scale);<br \/>\n }<br \/>\n };<br \/>\n }<br \/>\n }<\/p>\n <p>return null;<br \/>\n };<br \/>\n };<\/p>\n <p>&nbsp;<\/p>\n <p>Sorry about the format<\/p>\n <p>But I guess now it&#8217;s okay that I use them?<\/p>\n <p>Please let me know if I horribly embarrassed myself.<\/p>\n <p>&nbsp;<\/p><\/blockquote>\n <p>And also may use Box2dWeb-2.1.a.3.min<\/p>","time":"April 25th, 2014 12:36 pm","title":"Base Code, libraries"}