<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>android &#8211; Software, Fitness, and Gaming &#8211; Jesse Warden</title>
	<atom:link href="https://jessewarden.com/tag/android/feed" rel="self" type="application/rss+xml" />
	<link>https://jessewarden.com</link>
	<description>Software &#124; Fitness &#124; Gaming</description>
	<lastBuildDate>Mon, 08 Jul 2013 14:42:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://jessewarden.com/wp-content/uploads/2016/08/cropped-Lambda2-32x32.png</url>
	<title>android &#8211; Software, Fitness, and Gaming &#8211; Jesse Warden</title>
	<link>https://jessewarden.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>MVC in Corona via Robotlegs</title>
		<link>https://jessewarden.com/2013/06/mvc-in-corona-via-robotlegs.html</link>
					<comments>https://jessewarden.com/2013/06/mvc-in-corona-via-robotlegs.html#comments</comments>
		
		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Thu, 06 Jun 2013 00:03:19 +0000</pubDate>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[corona]]></category>
		<category><![CDATA[coronasdk]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[modelviewcontroller]]></category>
		<category><![CDATA[modelviewpresenter]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[mvp]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[responsivedesign]]></category>
		<category><![CDATA[robotlegs]]></category>
		<guid isPermaLink="false">http://jessewarden.com/?p=3560</guid>

					<description><![CDATA[I&#8217;ve recorded a new video series that goes over how to do Model View Controller development for medium to Enterprise mobile applications in Corona SDK via Robotlegs. It&#8217;s a popular framework from the Flash/Flex world that I&#8217;ve spent the last 2 years on and off porting from ActionScript 3 to Lua. It&#8217;s mature enough now [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve recorded a new video series that goes over how to do <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">Model View Controller</a> development for medium to Enterprise mobile applications in <a href="http://www.coronalabs.com/products/corona-sdk/">Corona SDK</a> via <a href="http://www.robotlegs.org/">Robotlegs</a>. It&#8217;s a popular framework from the Flash/Flex world that I&#8217;ve spent the last 2 years on and off porting from ActionScript 3 to Lua. It&#8217;s mature enough now that I can start actually recommending its usage, primarily to garner feedback for guiding it&#8217;s future implementation.</p>
<p>Additionally, I recorded a code walkthrough separately below. Code&#8217;s in the <a href="https://github.com/JesterXL/Robotlegs-for-Corona/tree/master/examples/cafe-townsend">Cafe Townsend</a> section in the <a href="https://github.com/JesterXL/Robotlegs-for-Corona">repo</a>.</p>
<p><iframe src="http://www.youtube.com/embed/videoseries?list=PLZEZPz6HkCZkQk_jnPczqab-Vk7rZ7mLf" height="360" width="640" allowfullscreen="" frameborder="0"></iframe></p>
<p><iframe src="http://www.youtube.com/embed/6MpuB654_hM" height="360" width="640" allowfullscreen="" frameborder="0"></iframe></p>
]]></content:encoded>
					
					<wfw:commentRss>https://jessewarden.com/2013/06/mvc-in-corona-via-robotlegs.html/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>One Game A Month &#8211; April Postmortem: Health Katas</title>
		<link>https://jessewarden.com/2013/05/one-game-a-month-april-postmortem-health-katas.html</link>
					<comments>https://jessewarden.com/2013/05/one-game-a-month-april-postmortem-health-katas.html#comments</comments>
		
		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Sun, 05 May 2013 14:19:21 +0000</pubDate>
				<category><![CDATA[CoronaSDK]]></category>
		<category><![CDATA[1gam]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[corona]]></category>
		<category><![CDATA[coronasdk]]></category>
		<category><![CDATA[gaming]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[onegameamonth]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[robotlegs]]></category>
		<guid isPermaLink="false">http://jessewarden.com/?p=3539</guid>

					<description><![CDATA[I&#8217;ve entered into the One Game a Month party. It&#8217;s like Ludum Dare, a challenge to make, and most importantly FINISH, a game in a set amount of time based on a theme. What makes #1GAM unique is you have an entire month and it spans an entire year. They have a thriving Twitter and [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve entered into the <a href="http://www.onegameamonth.com/">One Game a Month</a> party. It&#8217;s like <a href="http://www.ludumdare.com/compo/">Ludum Dare</a>, a challenge to make, and most importantly FINISH, a game in a set amount of time based on a theme. What makes #1GAM unique is you have an entire month and it spans an entire year. They have a thriving <a href="https://twitter.com/search?q=%231gam%20%23onegameamonth&amp;src=hash">Twitter</a> and <a href="https://plus.google.com/communities/117275686212402755276">Google+ group</a>.</p>
<p>I&#8217;ve entered strictly for learning purposes and to see if I can actually finish something. Game development is surprisingly very different from application development, and it&#8217;s nice to feel really stupid again.</p>
<p><span id="more-3539"></span><strong>Synopsis</strong></p>
<p>I fell back to my roots and attempted to build a mobile application that used &#8220;gamification&#8221;. Basically, you make the application fun through adding gaming elements to it. I&#8217;m good at building applications so figured if I fell back to my roots and adding just a little bit of game dev to it, I&#8217;d be able to create a lot more in the same period.</p>
<p>I changed my lifestyle last year in March of 2012 through adding fitness and changing my diet. A year later, I feel better and look better. I wondered how I could help others reach the same goals. While people tell you it&#8217;s 50% diet, 50% exercise, I felt for me 80% of the challenge was diet. I know nothing about cooking beyond what I&#8217;ve taught myself. My mom and grand mom taught me some stuff, but for whatever reason as I kid I just never really cared to better myself at it.</p>
<p>So, I made a list of all the smaller things I did that had longer term impact. I realize Type A Personality techniques of making huge changes with hardcore willpower are not the most effective way at changing people&#8217;s behavior. I&#8217;ve also read the statistics on how many actually keep weight off after they&#8217;ve lost it, and the time people devote to foodÂ preparationÂ vs.Â exercise. For Americans, it&#8217;s pretty dire. I took that list I wrote, and selected the ones that were the low hanging fruit, and hopefully easy attainable without requiring a Doctor&#8217;s note to attempt.</p>
<p>If you look at most nutrition advice, at least online or in books, it&#8217;s usually huge lifestyle changes. That&#8217;s asking a lot of people, and the #&#8217;s prove it doesn&#8217;t lead to longterm positive lifestyle changes. What DOES work is small habits that lead to longer term change. If you change a bunch of them, they collectively, slowly, lead to a more healthier, and more importantly, a self-empowered, individual. I started to make the application I wish I originally had: simple tips I could try everyday that didn&#8217;t totally shock my way of life, and that I could actually accomplish, and feel good about.</p>
<p><strong>Goals</strong></p>
<p>Give people simple healthy diet changes to try. From making people healthier, feel better, or empowering them to learn on their own. Giving someone 1 thing to try every day, even multiple times if they wished, to practice at being moreÂ healthy without having to focus 100% of their life on doing so. My hope was it&#8217;d be the least invasive thing in their life, thus hopefully maximizing the success rate. Kata&#8217;s are simpleÂ exercisesÂ you do in martial arts to practice and get better. I wanted something like that in a diet context vs. &#8220;OMG CHANGE YOUR LIFE!&#8221;</p>
<p>Additionally, they&#8217;d have both motivation in the form of videos and citations that show the positives of even minor diet changes as well as a world wideÂ achievementsÂ bored to see how many others had already accomplished each kata (or simpleÂ exerciseÂ  to also help with motivation.</p>
<p><strong>Actual Results</strong></p>
<p>I didn&#8217;t finish.</p>
<p>That said, all of the original katas are in the app, and you can try them, and have a record of your accomplishments. So it&#8217;s technically an early alpha, heh.</p>
<p><img fetchpriority="high" decoding="async" style="padding-left: 8px;" alt="" src="http://jessewarden.com/archives/blogentryimages/onegameamonth/apr/example-1.jpg" width="320" height="480" align="right" /></p>
<p>I ran out of time for motivations, and theÂ achievementsÂ board was slowed because it was the first time I used <a href="http://www.coronalabs.com/products/corona-cloud/">Corona&#8217;s Cloud</a> API.</p>
<p>The main problem with the data entered currently is that 3 important things are missing. I wanted to ensure all health recommendations I had were based on science that had at least 1 scientific study/citation. A lot of these studies are extremely wordy. Most people just want to know either WHY something isÂ healthy or how it&#8217;s POTENTIALLY healthy. The later is horrible in terms of how we humans operate, but it&#8217;s also a good tool to get people to do what you want them to do. Anyway, collecting +Â summarizingÂ all of that information is a ton of work. I&#8217;m constantly reading nutrition books and articles and taking notes, just not finished yet.</p>
<p>The other issue is turning those successes intoÂ congratulatoryÂ notes. When you complete a kata, you get a success message. For example, although I assumed users didn&#8217;t do drugs nor smoke, even just stopping smoking for example has a swath of awesome things that <a href="http://whyquit.com/whyquit/a_benefits_time_table.html">happen to your body</a>. It&#8217;s important you not only reward people forÂ accomplishingÂ the simpleÂ exercise, this builds self-confidence in them, but also you teach them WHY. Once someone knows the why and has self-confidence, change is afoot. Writing those is tough&#8230; even tweet size ones.</p>
<p>Finally, the questions are sometimes backwards; I need to add a boolean to the VO&#8217;s to say if yes leads to completing or starting the kata&#8230; or just make all the questions have &#8220;yes&#8221; lead to starting the kata. If you use the app now, just say yes to everything.</p>
<p><strong>What Went Wrong</strong></p>
<p>The main problems were:</p>
<ul>
<li><span style="line-height: 16px;">not enough free time</span></li>
<li>still learning nutritional science</li>
<li>Corona&#8217;s lack of basic GUI components and redraw invalidation</li>
<li>not enough documentation on Corona Cloud + having to learn a new API</li>
<li>Responsive Design</li>
<li>explaining to people how no longer eating their favorite unhealthy things is fun&#8230; in a mobileÂ application&#8230; yeah.</li>
</ul>
<p><strong>Free Time</strong></p>
<p>As usual, work both in client projects as well as outside took a lot of time. My main current client has a huge feature release coming up that we&#8217;ve all be tag teaming. This requires a lot of consistent communication as well as on-site visits which means I&#8217;m travelling a lot.Â I also travelled back to Georgia to sell my house. I&#8217;mÂ uncompromisingÂ in my workout schedule and picking up my kids from school which is 2 hours minimum a day. Also, it took me about 5 days to recover from March #1GAM burnout. Finally, <a href="http://webappsolution.com">my company</a> released the <a href="http://webappsolutioninc.github.io/flow-mvc">FlowMVC</a> framework based on the <a href="http://deftjs.org/">DeftJS</a> framework that all works atop <a href="http://www.sencha.com/">Sencha</a>, and that took a lot of time to ensure we got the alpha out as well.</p>
<p><strong>Nutrition Knowledge</strong></p>
<p>I&#8217;m notÂ classicallyÂ trained in nutrition, so am learning the same way I learned how to program: read online articles, read books, and asking questions of those who appear to be experts. Suffice to say it&#8217;s just as hard as programming to get to the real truth; it&#8217;s all masked in subjectivity and utter untruths. Making definitive statements is VERY hard to back up with science. America in particular has a ton of science around how to cure sickness, but very little on how to keep us not-sick via good nutrition. Frustrating. You have tread carefully when utilizing Qualitative science from qualified individuals. Bottom line there are a few facts, and a few of studies that reach conclusions but aren&#8217;t facts.</p>
<p>Sadly, a lot online is useless. At least with programming you can use sites like <a href="http://stackoverflow.com/">Stackoverflow.com</a>Â and communities that reference certain blogs/articles to find the good stuff. For nutrition, there are a few sites like that, but they don&#8217;t always cite their sources, nor differentiate between &#8220;the facts&#8221; and &#8220;the guesses based on the following studies which may/may not have contradictory studies&#8221;.</p>
<p>I wanted the app to have solid science, and getting solid science as a n00b is hard.</p>
<p><strong>Corona&#8217;s App State</strong></p>
<p>While Corona has made great strides on the widget front, their gaming focus, both as a company and in the runtime features are clearly biased. Even the <a href="https://github.com/coronalabs/framework-cloud">Corona cloud library</a> they posted on Github uses &#8220;name spacing&#8221;, aÂ pseudoÂ copy of how Python handles classes and packages. This, instead of using the proper class/module packages they introduced about a year ago. I reckon they did this to cater to game devs who freak out if you do 2 dots to get a &#8220;module&#8221; whereas for application developers, it&#8217;s just expected if you&#8217;re from a traditional OOP background and you get the time to actually think about class structure that often doesn&#8217;t change as much as it does in gaming.</p>
<p>This seems like a digression but it&#8217;s not; the simple fact they&#8217;re game focused makes even simple things application developers expect to be non-existent. For example, I DARE you to center a multiline block of text on the screen with arbitrary widths&#8230; and then put a different block of text in it. Works no problem in Flash/Flex and HTML(!). Corona doesn&#8217;tÂ recalculate/remeasure, and your registration point is off, and using simple x and width values to center the text suddenly fail. If you just create another text field, no problem, but even game developers know you object pool where possible.</p>
<p>Layout in this case is made worse as they abstract away device specific text fields. While it&#8217;s nice to use native device (iOS/Android) text fields that do render well, they don&#8217;t always render like you think on the simulator, namely the native options with backgrounds/borders disabled. Haveing to compile to view on the device is just awful. It defeats the whole purpose of Lua being an instantaneous code reload solution. If I wanted to recompile andÂ redeployÂ to the device, I&#8217;d use native XCode and Objective C.</p>
<p>These basic needs make building higher level abstractions that are actually efficient harder. As components scale in size and complexity,Â especiallyÂ data driven ones, you need some form ofÂ invalidationÂ routine. Invalidation is a huge topic <a href="http://jessewarden.com/2007/01/invalidation-strategies-for-flash-player.html">I&#8217;ve</a> <a href="http://jessewarden.com/2008/03/how-to-fix-the-flash-cs3-components.html">written</a> <a href="http://jessewarden.com/2005/06/dataselector-data-interaction-core-of-the-v2-framework-for-your-views.html">about</a> <a href="http://jessewarden.com/2009/03/creating-dynamic-lists-in-flex-flash.html">before</a>, but suffice to say it prevents common race conditions, is an efficient redrawÂ mechanismÂ for runtimes like Corona that share both code execution and redraw on the same thread (see <a href="http://updates.developmentarc.com/flex_4_lifecycle.pdf">elastic</a> <a href="http://www.quilix.com/node/61">race</a> <a href="http://books.google.com/books?id=Gn1fnqBIUEgC&amp;pg=PA363&amp;lpg=PA363&amp;dq=ted+patrick+elastic+racetrack&amp;source=bl&amp;ots=bfhJonDoW0&amp;sig=nyN5BaCrh1sEi7sJbpn3tF5v9Uk&amp;hl=en&amp;sa=X&amp;ei=iWWGUcL3OIeC8ATv44HYAQ&amp;ved=0CG0Q6AEwBg#v=onepage&amp;q=ted%20patrick%20elastic%20racetrack&amp;f=false">track</a> <a href="http://techie-jackie-blogs.blogspot.com/2012/11/elastic-racetrack-for-flash-9-and-avm2.html">articles</a>Â <a href="http://www.craftymind.com/2008/04/18/updated-elastic-racetrack-for-flash-9-and-avm2/">discussing</a>Â <a href="http://www.senocular.com/flash/tutorials/asyncoperations/">this</a>), and solve order of operation errors for developers using components that require multiple properties to be set to work.</p>
<p>I&#8217;m in the process of building one on top ofÂ theirÂ enterFrame, but it&#8217;s like a flash back to 2001 in Flash MX; i.e. it&#8217;s a lot of work for 1 person to complete. A company like Corona should have the resources to handle this. Either they don&#8217;t have the people working for them that know these problems, or they&#8217;re focused on other things. I think it&#8217;s the latter; game specific features like their 2.5 graphics and cloud initiatives whilst open sourcing the components are signs. That&#8217;s fine, but oy vey&#8230; pain&#8230;</p>
<p>Another annoying thing is some widgets/components don&#8217;t work with groups. I get why, but this makes layout a royal journey into frustration and workarounds, and just generally nasty looking code.</p>
<p>I will say the widgets they DO have are great overall and <a href="https://github.com/coronalabs/framework-widgets">open sourcing</a> them was a dope move. The API consistency, while I get challenging, needs to be improved in both the libraries they distribute and in their internal SDK.</p>
<p><strong>Responsive Design (lack thereof)</strong></p>
<p>Because of the above crunch, I didn&#8217;t get a very responsive design. This lead to some devices not scaling properly&#8230; which sucked. For games, you can just scale up or down; Corona does this automatically. For applications, however, you basically do a &#8220;<a href="http://en.wikipedia.org/wiki/Responsive_web_design">responsive </a><a href="http://mashable.com/2012/12/11/responsive-web-design/">design</a>&#8220;. While most web sites prefer to use <a href="http://alistapart.com/article/responsive-web-design">media queries</a> and <a href="http://www.html5rocks.com/en/mobile/responsivedesign/">funky</a> <a href="http://alistapart.com/article/fluidgrids">fontÂ measurements</a>Â to accomplish this, using things like Sencha, Flex, or even Corona, and you can simply have each component size itself and it&#8217;s children. As the application grows, this works out well because they&#8217;ll fill whatever space you tell them too.</p>
<p>The kicker here is &#8220;if the design supports it&#8221;. For example a toolbar can scale infinitely horizontally, but tends to stay 60 pixels high. On most smartphones, this is fine, but on tablets,Â especiallyÂ the high rez ones, it gets a bit too small to work. At that point you fall back to another nav. I didn&#8217;t even get that far&#8230; as soon as I went from a Nexus One to a Droid X, my app couldn&#8217;t even handle the extra 24 pixels.</p>
<p>I put a 640&#215;960 mask on stage and called it a day.</p>
<p><strong>Corona Cloud</strong></p>
<p><a href="http://coronalabs.com/blog/2013/03/20/corona-cloud-1-0-is-here/">Corona Cloud</a> is awesome. The documentation is ok. The example code is awesome, although completely ignores Corona&#8217;s package structure and they&#8217;ve foregone using metatable vs. closure based classes for the same reason a lot of JavaScript libraries do the &#8220;large object on global window&#8221; to avoid the closure vs. Object.prototype debates. Anyway, nothing major here, just hard to learn a new API in such a short time frame with all the other challenges going on, thus compounding it.</p>
<p><strong>Making Health Fun</strong></p>
<p>For me, I was sick and tired of being sick and tired. Once I make my mind up, there&#8217;s no changing my mind. I have discipline with certain things I set my mind to. I get that to make broader changes to the world, you need to be moreÂ pragmaticÂ about what you expect out of the general populace. I took the approach of &#8220;simple with positive messaging as instant reward and global awareness through achievements of other users&#8221;. The &#8220;simple&#8221; was simple, the CoronaÂ cloudÂ achievements isn&#8217;t something I need but totally get how others need thatÂ motivation.</p>
<p>The &#8220;positive messaging&#8221; though is rough. When you look at the back of a &#8220;Matt&#8217;s Organic Orange Juice&#8221; container for example, they&#8217;ll go off about Vitamin D, and how it&#8217;s greatest thing for you evarrr. It clearly was written by a talented marketing copy writer and put through a few revisions. Trying to do that, for every single kata, was rough. As you can see, I can write a lot, but saying a lot with few words is HARD. Fun, but hard.</p>
<p><strong>What Went Right</strong></p>
<p><img loading="lazy" decoding="async" style="padding-right: 8px;" alt="" src="http://jessewarden.com/archives/blogentryimages/onegameamonth/apr/example-2.jpg" width="320" height="480" align="left" />Finding a fitting design and icons I needed on <a href="http://graphicriver.net/">GraphicRiver</a> was <a href="http://graphicriver.net/item/zweir-complete-mobile-interface/2617224">uber</a> <a href="http://graphicriver.net/item/70-food-and-drink-icons/3543222">easy</a>. Getting the design to work in Corona, my component issues non-withstanding, also easy.</p>
<p>Setting up the MVC structure, also easy. I hadn&#8217;t messed with my port of <a href="https://github.com/JesterXL/Robotlegs-for-Corona">Robotlegs for Corona</a> for almost 2 years(!) since those kind of frameworks are more used for applications and less so games, so took the opportunity to bring it up to speed.</p>
<p>Coming up with simple things that are healthy for people to try was actually pretty easy as well. I just charted my own path andÂ rememberedÂ all the hard things I did, and modified the order based onÂ difficulty and organized into levels of lifestyle impact. The app was responsive on the device, and I only had minor masking problems with the Corona widgets. Once I got some good low level components, building the GUI&#8217;s was pretty quick and easy.</p>
<p><strong>Key Takeaways</strong></p>
<p>I think like my Februrary entry, I&#8217;d like to come back to this, finish it, and polish it. Even in application development, you can get into &#8220;the grind&#8221;, the last, brutal 10%. It&#8217;s easier to power through if you believe in the final product.</p>
<p>It&#8217;s also clear I shouldn&#8217;t do anything more GUI heavy without a Corona component framework ready before I start. Oh goody, another side project! *face palm*</p>
<p>I need to organize my notes about nutrition more. Most of it is for me related to fitness vs. justÂ pragmaticÂ well being. That and I forget what research/study/book told me what, and whether it was a &#8220;study&#8221; vs. a &#8220;paper&#8221; vs. a &#8220;theory&#8221; vs. a &#8220;scientific fact&#8221;&#8230; which greatly affects the other research/beliefs it&#8217;s related to. Like programming.</p>
<p>Finally, I need more time with Corona Cloud. It&#8217;s really cool, just haven&#8217;t had enough time to play to learn it more.</p>
<p><strong>Conclusions</strong></p>
<p>May: Go back to the 2D side scroller. From myÂ FebruaryÂ entry, it&#8217;s clear I liked making Box2D levels, and need more practice in making them, even if I don&#8217;t finish.</p>
<p>Once again, I&#8217;m burnt, and need a few days to recover. This time, though, I knew it was coming and planned for it: notes for May dev all ready, concepts documented from awhile ago when I&#8217;m ready to nail down an idea, and tons of alcohol and XBox games while I recover.</p>
<p>The <a href="https://github.com/JesterXL/Health-Katas">source code</a> is up on Github and you can <a href="https://play.google.com/store/apps/details?id=com.jessewarden.healthkatas">install on your Android device here</a>Â (although I&#8217;d wait until the version says &#8220;beta&#8221; hah).</p>
]]></content:encoded>
					
					<wfw:commentRss>https://jessewarden.com/2013/05/one-game-a-month-april-postmortem-health-katas.html/feed</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
		<item>
		<title>One Game A Month &#8211; March Postmortem: Manifest Crystal</title>
		<link>https://jessewarden.com/2013/04/one-game-a-month-march-postmortem-manifest-crystal.html</link>
		
		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Mon, 01 Apr 2013 13:40:14 +0000</pubDate>
				<category><![CDATA[Lua]]></category>
		<category><![CDATA[1gam]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[coronasdk]]></category>
		<category><![CDATA[gaming]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[onegameamonth]]></category>
		<category><![CDATA[programming]]></category>
		<guid isPermaLink="false">http://jessewarden.com/?p=3520</guid>

					<description><![CDATA[I&#8217;ve entered into the One Game a Month party. It&#8217;s like Ludum Dare, a challenge to make, and most importantly FINISH, a game in a set amount of time based on a theme. What makes #1GAM unique is you have an entire month and it spans an entire year. They have a thriving Twitter and [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve entered into the <a href="http://www.onegameamonth.com/">One Game a Month</a> party. It&#8217;s like <a href="http://www.ludumdare.com/compo/">Ludum Dare</a>, a challenge to make, and most importantly FINISH, a game in a set amount of time based on a theme. What makes #1GAM unique is you have an entire month and it spans an entire year. They have a thriving <a href="https://twitter.com/search?q=%231gam%20%23onegameamonth&amp;src=hash">Twitter</a> and <a href="https://plus.google.com/communities/117275686212402755276">Google+ group</a>.</p>
<p>I&#8217;ve entered strictly for learning purposes and to see if I can actually finish something. Game development is surprisingly very different from application development, and it&#8217;s nice to feel really stupid again.</p>
<p><span id="more-3520"></span><strong>Synopsis</strong></p>
<p>An role playing game in the play and art style of 1996&#8217;s Final Fantasy 6 released in 1994.</p>
<p>A group of 11 or so individuals come into contact with Manifest Crystals and come to terms with their new powers. Â They learn the true depth of humanity&#8217;s crystal exploitation as well as the ecological impact and purpose of crystals. Â They are tenuous allies with the military/government as they learn the truths, overcome some planetary threats, and work to stop the main antagonist.</p>
<p><strong>Manifest Crystal Goals</strong></p>
<p>I wanted to do an RPG, badly. It&#8217;s the whole reason I wanted to work for <a href="http://na.square-enix.com/">Squaresoft</a> when I grew up. However, I really struggled to get excited about <a href="http://getmoai.com/">Moai</a>. While they have grids and <a href="http://getmoai.com/docs/class_m_o_a_i_path_finder.html">pathfinding</a> built in, I just didn&#8217;t see how the low-level API helped me; what I&#8217;m doing is not that sophisticated in terms of GUI. <a href="http://www.giderosmobile.com/">Gideros</a> had aÂ similarÂ fate when with their simplistic API that was missing some things I wanted from <a href="http://coronalabs.com">Corona</a>. I looked at them specifically because their API is familiar and had bitmap features, like Moai, which Corona doesn&#8217;t have. Some tests I did of Corona last year moving large masked bitmaps were promising, so I figured I&#8217;d give her a go.</p>
<p><strong>Actual Results</strong></p>
<p>March was a no show. Not even a build.</p>
<p>First week I was extremely burnt out of #1GAM. I worked really hard for my February entry, so spent the first week fixing burn out: which means no computer.</p>
<p>Additionally, March is when taxes are due in the USA, so that was a lot of work as well aside from the normal quarterly state and federal filings</p>
<p>Also work was pretty rough in March. Lots of challenges in the code, working multiple projects with multiple developers; huge cognitive load that made me collapse at night with zero energy left for #1GAM. March is also the month when companies start hiring to close their 1st quarter budget or get plans for 2nd quarter, so fielded a lot of sales calls/emails.</p>
<p>Finally, I&#8217;ve been playing with my diet for fitness and health goals. That means 40% protein, 30% fats, 10% carbs + a 300 calorie deficit. This means 3 weeks of adjusting my head to the lack of carbs it needs to produce mad serotonin + being distracted by being hungry. That and I still struggle with getting enough sleep. Grumpy, tired me.</p>
<p>Not the best combination to tackle my hardest game challenge yet. At the end of the day, I prioritize work 1st, working out 2nd, and #1GAM 3rd so he&#8217;s the first to get cut from a busy life.</p>
<p><strong>What Went Wrong</strong></p>
<p>First, this is the 2nd time I attempted this game. The first was about 3 years ago. I picked the best people in the industry I knew at the time that I&#8217;d kill to work with, sent them a mass email, and laid out my plan. It was clear I could inspire, but not get people to actually do what I wanted them to do. Additionally, not sure everyone bought into the idea, and I think everyone wanted some more organization around tasks &amp; milestones. That, and doing a game on the side is asking a lot of people who are A players in this industry and already have a ton going on. You need to provide key incentives. I think.</p>
<p>I tried to learn from that mistake and organize things a bit more,Â especiallyÂ since what I learned fromÂ JanuaryÂ and March is that even spending 10 minutes to write, organize, and prioritize high level tasks has a HUGE impact down the line. I know what I&#8217;m supposed to be doing, if I hit a brick wall or just get tired of a task, I can jump to another one, and if scope becomes a problem it&#8217;s easier to see what I can cut vs. keep. It wasn&#8217;t enough, though; I probably should have spent 2 days vs. 10 minutes. An RPG, even a small one that&#8217;s story driven like mine, requires a ton more upfront work as I&#8217;ve found. Twice, hah!</p>
<p>At this point I&#8217;ve been content producing horrible game art myself. However, I misjudged just how much and the varied types I need for this game. I struggled to reduce the scope because evenÂ minimalistÂ design still has the responsibility to evoking the emotions in the player the story is trying to convey and key junctures. I could probably pull it off, but without a full list knowing what was needed, and where, it was too much work for me and sabotaged my momentum on art days.</p>
<p><strong>What Went Right</strong></p>
<p>I got a lot of great code out of this. Although I only put in maybe 10, 1 hour days, I now have a ton of great converted from ActionScript to Lua and new code I can use to try again later this year.</p>
<p>I also finally managed to get a highly level scalable battle system that I hired aÂ mathematicianÂ to verify.</p>
<p>I really enjoyed playing with various menu systems on mobile devices, and built my 2nd <a href="https://www.google.com/search?q=radial+menu&amp;hl=en&amp;source=lnms&amp;tbm=isch&amp;sa=X&amp;ei=9Y9ZUezxLof69gSil4CQAw&amp;ved=0CAoQ_AUoAQ&amp;biw=1311&amp;bih=726">pie / radial menu</a>, taking many cues from <a href="http://en.wikipedia.org/wiki/Secret_of_Mana">Secret of Mana</a>. I still haven&#8217;t gotten the <a href="http://www.swype.com/">Swype</a> esque way of using it down, but it&#8217;s good enough even with just taps.</p>
<p>My tile engine performed just fine with large textures on crappy Android devices so that was promising.</p>
<p>Finally, I learned yet again a ton whilst coding and designing and writing. Just a lot of little things that all add up to make even this failure totally worth it.</p>
<p><strong>Key Takeaways</strong></p>
<p>I&#8217;ve yet to see myself over plan. It&#8217;d be nice to make that mistake and see results.</p>
<p>I really should put a budget together for an artist to handle most of the game art, and I can handle the GUI well ahead of the start date at least to get discussions going. It was such a huge percentage of my time this month and required some iterations to get right both for story and technical reasons. I fail to see how I can do it all myself. Reducing scope is out of the question, so maybe I can write a different story to test all the engine + code out first for aÂ separateÂ game, much like <a href="http://www.gametrailers.com/full-episodes/ucf5sb/gt-retrospectives-final-fantasy-retrospective--part-iv">Square did back in 1995 (scrub to 11:45)</a> at Siggraph making 3D FF6 characters to test out the FF7 3D engine for the upcoming Playstation 1. It&#8217;d make a good tracer bullet, not sure how fun though, we&#8217;ll see.</p>
<p>Yet again I&#8217;ve proven even failures results in tons of good, reusable code and a lot of things learned.</p>
<p><strong>Conclusions</strong></p>
<p>I think I&#8217;ll postpone my next RPG attempt for June or August for a variety of reasons. First, I need some more practice getting teams to work together; would really rather tackle it NOT by myself even if it&#8217;s just an art + audio sub. Second, it&#8217;ll be summer then, and I&#8217;ll be outside more. While I&#8217;m taking Vitamin D supplements (yes, no dairy + no outside == deficient), by then the pool will be open and I&#8217;ll be taking the girls their daily. That and carbs will be 50% of my diet. Those&#8217;ll up the mood. Third, I&#8217;m burnt out on involved game mechanics, I need to fall back to my roots to get rejuvenated: app development.</p>
<p>April: A health and nutrition game both to educate people and get them eating better. While games like this exist, it&#8217;ll be more app like so that&#8217;s something I excel at, and it&#8217;ll help me to continue to learn about nutrition which I&#8217;ve been learning about on the side for awhile. Making this a game sounds fun.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Memory Corona SDK Time Lapse &#038; Code</title>
		<link>https://jessewarden.com/2012/05/memory-corona-sdk-time-lapse-code.html</link>
					<comments>https://jessewarden.com/2012/05/memory-corona-sdk-time-lapse-code.html#comments</comments>
		
		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Wed, 30 May 2012 14:43:40 +0000</pubDate>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[corona]]></category>
		<category><![CDATA[coronasdk]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[gaming]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[mobile]]></category>
		<guid isPermaLink="false">http://jessewarden.com/?p=3142</guid>

					<description><![CDATA[I built a Corona SDK game over Memorial Day weekend called &#8220;Memory&#8220;. It took me 12 hours and I recorded the whole thing using ScreenFlow. I&#8217;ve compressed it here down to 7 minutes. The code is up on Github. I&#8217;ll get to iOS/Nook/Kindle someday&#8230; &#160;]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" style="padding-right: 8px;" src="http://jessewarden.com/archives/blogentryimages/memory-logo.png" alt="Memory Logo" width="160" height="160" align="left" />I built a <a href="http://www.anscamobile.com/">Corona SDK</a> game over Memorial Day weekend called &#8220;<a href="https://play.google.com/store/apps/details?id=com.jessewarden.memory">Memory</a>&#8220;. It took me 12 hours and I recorded the whole thing using <a href="http://www.telestream.net/screen-flow/">ScreenFlow</a>. I&#8217;ve compressed it here down to 7 minutes. The <a href="https://github.com/JesterXL/Memory">code</a> is up on <a href="https://github.com">Github</a>. I&#8217;ll get to iOS/Nook/Kindle someday&#8230;</p>
<p>&nbsp;</p>
<p><iframe loading="lazy" width="640" height="480" src="http://www.youtube.com/embed/z-dQiIkAM3o?rel=0" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
					
					<wfw:commentRss>https://jessewarden.com/2012/05/memory-corona-sdk-time-lapse-code.html/feed</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Building An Elevator in Box2D</title>
		<link>https://jessewarden.com/2012/02/building-an-elevator-in-box2d.html</link>
					<comments>https://jessewarden.com/2012/02/building-an-elevator-in-box2d.html#comments</comments>
		
		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Thu, 23 Feb 2012 16:00:16 +0000</pubDate>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[box2d]]></category>
		<category><![CDATA[coronasdk]]></category>
		<category><![CDATA[gaming]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[programming]]></category>
		<guid isPermaLink="false">http://jessewarden.com/?p=3048</guid>

					<description><![CDATA[Introduction It took me 4 days to build an Elevator via Box2D in Corona SDK. I wrote the actual code and API for it in about 30 minutes. Getting the physics to work proved way more challenging than I anticipated. I&#8217;m still learning the ins and outs of Box2D as it relates to game development, [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>It took me 4 days to build an Elevator via <a href="http://box2d.org/">Box2D</a> in <a href="http://anscamobile.com">Corona SDK</a>. I wrote the actual code and API for it in about 30 minutes. Getting the physics to work proved way more challenging than I anticipated. I&#8217;m still learning the ins and outs of Box2D as it relates to game development, so wanted to report on how I went about it and what I learned.</p>
<p><span id="more-3048"></span>The following article talks about how I&#8217;m using Box2D in my game, the 4 approaches I took to building an elevator, and what I eventually decided upon.</p>
<p>Please keep in mind some of the things below are related to Corona SDK&#8217;s implementation of Box2D. Thus, some of the issues and compensation measures I took may not need to be done, nor happen, in other implementations and platforms.</p>
<p><strong>Why An Elevator?</strong></p>
<p>Elevators provide an interesting transition in both games and <a href="http://unrealitymag.com/index.php/2010/03/22/elevator-scenes-in-movies/">movies</a>. They also provide easier ways for game developers to unload and load a level, provide a rest for the player, and/or make it easy to provide cut scene dialogue to prepare for the player for an upcoming part. In a lot of horror movies, they actually are the focal point of a lot of scary scenes such as <a href="http://www.youtube.com/watch?v=wexyYCt_0_c&amp;t=4m53s">Resident Evil</a>, and also provide a perfect setting for <a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/UncomfortableElevatorMoment">comedic relief</a> such as such as Spiderman 2 and <a href="http://www.youtube.com/watch?v=S2ua0UCrzxs&amp;t=4m0s">Deep</a> <a href="http://www.youtube.com/watch?v=n4HAfe14i_M">Rising</a>Â (good ole <a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/TheElevatorFromIpanema">Ipanema</a>).</p>
<p>One of my favorite easter eggs was from Max Payne was in an elevator. You walk into a shoddy NYC apartment building elevator alone, with the notorious off-kilter 3rd person camera. Combined with the absurd brightness in the elevator&#8217;s interior amongst a very noir game, the tell tale &#8220;elevator muzak&#8221; is playing. If you shoot the overhead speaker, Max utters a smirk filled, 2nd word annunciated &#8220;<a href="http://www.youtube.com/watch?v=Z53X9CxHiOE">Thank you!</a>&#8220;.</p>
<p>Romance, fear, death. In such a confined space clearly only meant for short periods of stay, elevators can force us to view the human condition ever more clearly. Many writers play up theÂ claustrophobiaÂ aspect, the lack of control as a metaphor for life taking us where it wills to, or preying on our fear of the unknown when you hear bad things just outside the lift walls.</p>
<p>It also helps players in games get from one floor to another in a controlled manner. Kind of like they do in the real world.</p>
<p><strong>How Does Mine Need to Work?</strong></p>
<p>A game I&#8217;m building requires that a character inside a building go up a floor in the building he is in. It&#8217;s based on a Brooklyn apartment building that has 13 floors with 12 ft ceilings. The character is on the 12th floor and needs to use the standard elevator. It has a call switch on the outside. You press a button and the elevator will arrive at the floor the button was pressed. You can optionally walk into the elevator and press the up or down buttons for the same effect. The elevator does not move on it&#8217;s own, only when a button is pressed. It currently only operates on 2 floors.</p>
<p>Simple, right? Code wise, it was. Here&#8217;s the <a href="https://github.com/JesterXL/ZombieStick/blob/StateMachineBranch/code/com/jxl/zombiestick/gamegui/levelviews/Elevator.lua">Lua class on Github</a>. The only thing to really note is the goUp, goDown, and tick functions. The goUp and goDown simply set flags so the elevator knows where to go. The tick function handles the actual movement via the <a href="https://github.com/JesterXL/ZombieStick/blob/StateMachineBranch/code/com/jxl/zombiestick/core/GameLoop.lua">game loop</a>. Distance joints, which I&#8217;ll cover in a minute, are not powered by motors, so I just increment or decrement the length to move it up or down.</p>
<p><strong>Brief On Box2D</strong></p>
<p>I&#8217;ve fullyÂ committedÂ to Box2D. That means that a lot of things are handled for me such as gravity, forces, and collisions&#8230; basically all the physics code. If you&#8217;re not familiar with Box2D, here&#8217;s a brief synopsis.</p>
<p>From the <a href="http://box2d.org/about/">site</a>:</p>
<blockquote><p>Box2D is an open source C++ engine for simulating rigid bodies in 2D. Box2D is developed by Erin Catto&#8230;</p></blockquote>
<p>It&#8217;s basically a physics engine for games, although it can be used for other things as well. It&#8217;s been ported to a lot of other languages and platforms, such as <a href="http://box2dflash.sourceforge.net/">ActionScript</a>,Â <a href="http://code.google.com/p/dartbox2d/">Dart</a>, and <a href="http://box2d-js.sourceforge.net/">JavaScript</a>.</p>
<p>It&#8217;s recently regained popularity because it can ease the creation of <a href="http://seb.ly/2012/01/live-iphone-coding-video-now-online/">Angry Birds</a> like games.</p>
<p><iframe loading="lazy" width="640" height="360" src="http://www.youtube.com/embed/LBnBml2KFFk" frameborder="0" allowfullscreen></iframe></p>
<p><strong>Box2D Constraints</strong></p>
<p>You give up a lot of control when you use Box2D and also have to develop a certain way. For example, all bodies (or things in the world that can bump into each other) default to dynamic. This means they are affected by gravity, which you usually default to <a href="http://en.wikipedia.org/wiki/Terminal_velocity">9.8</a> to simulate the real world.</p>
<p>If you&#8217;ve read the <a href="http://oos.moxiecode.com/blog/tutorials/tilebased-games-in-flash-5-part-12/">Jailbitch</a> tutorials and/or others of it&#8217;s ilk, you basically write code like:</p>
<pre lang="javascript">thisObject.y += speed;
if(thisObject.y >= theGround.y)
{
	stopFalling();
	thisObject.y = theGround.y;
}</pre>
<p>Notice that gravity is applied, by you, on a per object basis. No code, no gravity. No code, no collisions.</p>
<p>This makes building elevators, or &#8220;platforms that raise up and down&#8221; pretty straightforward. You just increase or decrease the y value of an object. You can detect to see if the character is touching the elevator, and make sure she rises and falls with the platform.</p>
<p><strong>Using Y</strong></p>
<p>In Box2D, all dynamic objects have gravity by default and all the collisions are handled for you. Additionally, how the collisions happen can be tweaked on a per object basis if you like. Things like how heavy something is hitting something soft, the friction, and the bounce. You do not have to write any code for this; it&#8217;s just how the world works.</p>
<p>However, making a dynamic object in Box2D rise and fall isn&#8217;t as straightforward as you would think. Box2D has a neat feature which allows developers to set a body&#8217;s x and y value, and it&#8217;ll apply theÂ necessaryÂ gravity, forces, and collisions at the next redraw/tick. However, if you want something to move up, you have to treat it JUST like you would in the real world: through <a href="http://www.youtube.com/watch?v=YI-JC6w_Eqc">force</a>Â (NSFW).</p>
<p>If I immediately set an apple above my head at a y of 0, it&#8217;ll eventually fall on my head. If I want to stay there, I have to keep setting it to 0 using an enter frame/interval/timer&#8230; like a juggler. That&#8217;s redonk.</p>
<p><strong>Using Forces</strong></p>
<p>Box2D provides, at least in Corona SDK, a variety ways of applying force; as an impulse/jolt as well as force over time. The 2 in particular are <a href="http://developer.anscamobile.com/reference/index/bodyapplyforce">body:applyForce</a> and <a href="http://developer.anscamobile.com/reference/index/bodyapplylinearimpulse">body:applyLinearImpulse</a>.</p>
<p>The applyLinearImpulse is momentary jolt or shove.</p>
<p><iframe loading="lazy" width="640" height="360" src="http://www.youtube.com/embed/cluijVRD6WQ" frameborder="0" allowfullscreen></iframe></p>
<p>The applyForce is like a jet pack; you have to continually apply it via a timer/tick/enter frame to move something.</p>
<p><iframe loading="lazy" width="640" height="360" src="http://www.youtube.com/embed/VThnqp3ALkM" frameborder="0" allowfullscreen></iframe></p>
<p>As you can see, this makes things more complicated. Instead of simply &#8220;moving an object by changing it&#8217;s y position&#8221; you&#8217;re now having to compensate for the gravity of t3h erf.</p>
<p><strong>Using Kinematic Bodies</strong></p>
<p>The other simpler option is to utilize kinematic bodies. Instead of dynamic, kinematic allows a body to be affected by forces, like things bumping into it, the functions above, but NOT gravity. Ideal for an elevator, right? In theory yes. I&#8217;ll explain why I didn&#8217;t end up going this route in a bit. The only drawback here is that kinematic objects don&#8217;t &#8220;look&#8221; like real world objects. They don&#8217;t &#8220;sway&#8221; in the wind, or of something pushes it it just slightly moves. It doesn&#8217;t look &#8220;real&#8221; and defeats the purpose of using Box2D. While following <a href="http://en.wikipedia.org/wiki/Newton's_laws_of_motion">Newton&#8217;s Laws of Motion</a>, it looks like an elevator in space vs. on Earth with gravity.</p>
<p>The whole point of kinematic is for the user to drag them via touch or mouse, for cut scene animations where a character can still affect the physical world but you need to move elsewhere&#8230; or for things you specifically don&#8217;t want to be affected by gravity.</p>
<p><strong>Using Joints</strong></p>
<p>The 3rd option is constructing a realistic elevator so that Box2D can do it&#8217;s job: simulate rigid bodies in a 2D space. The mantra I&#8217;ve heard repeated by those more experienced in Box2D is keep it simple (or just abandon Box2D and write it yourself&#8230; but um&#8230; no). Instead of building a real car in Box2D, just build simple geometry (bodies and joints), and let the image of the car itself make the player think it&#8217;s real.</p>
<p>An elevator in Box2D terms is basically a box you can walk in and has a cable that attaches the box to a firm ceiling. This means, you create 2 boxes and a joint.</p>
<p>&#8230;but what TYPE of joint? And how do you apply it? THAT is what took 4 days.</p>
<p><strong>Version 1: Distance Joint</strong></p>
<p>A distance joint is a line that connects 2 things. You can shorten the line, and like a fishing pole, will reel in the body it&#8217;s attached to while it&#8217;s dangling below. Perfect for an elevator right?</p>
<p><iframe loading="lazy" width="640" height="360" src="http://www.youtube.com/embed/elfceCfHX4c" frameborder="0" allowfullscreen></iframe></p>
<p>Bleh.</p>
<p>My first problem was the box was off-kilter. I made it in a C shape so the player could walk in with a wall to the right, and a ceiling to connect the joint too. Being a non-square, however, this made the elevator&#8217;s weightÂ distributionÂ un even. It would immediately rotate even if nothing was on it because the weight of the right wall was heavier then the left side with none.</p>
<p>While increasing the friction the elevator had the consistency of velcro, thus ensuring our character wouldn&#8217;t fall out, if the player DID walk left, they&#8217;d plummet to their death in the elevator shaft, even if you made the shaft just wide enough to fix the box. While you could shrink the shaft and increase <a href="http://developer.anscamobile.com/reference/index/physicssetpositioniterations">Box2D&#8217;s sensitivity</a>, it&#8217;d sometimes get stuck.</p>
<p><iframe loading="lazy" width="640" height="360" src="http://www.youtube.com/embed/YD6rdYuEK-I" frameborder="0" allowfullscreen></iframe></p>
<p>While I could set <a href="http://developer.anscamobile.com/reference/index/bodyisfixedrotation">isFixedRotation</a> to ensure the elevator no longer rotated, and make the distance joint a little more like a rubber band via its frequency and dampingRatio properties, it still didn&#8217;t look as cool.</p>
<p><strong>Version 2: Multiple Distance Joints</strong></p>
<p>Most modern elevatorsÂ nowadaysÂ have a variety of attachments beyond a single cable. Magnetic locks with tracks&#8230; and usually more than 1 cable. So, I did the same thing and added 2 more cables to compensate.</p>
<p><iframe loading="lazy" width="640" height="360" src="http://www.youtube.com/embed/phnU11TTXNc" frameborder="0" allowfullscreen></iframe></p>
<p>At first, I was like eureka. But then I hit problems, and was like, no wai!</p>
<p>For some reason, if I changed the length of the first joint to reel in the elevator, AND set the other 2 joints to have the same length&#8230; sometimes it didn&#8217;t work. Yes, the values would change, but the elevator would just remain stuck. !? I don&#8217;t know if this was my code, the Corona simulator, or&#8230; Box2D.</p>
<p>At any rate, our intrepid heros can&#8217;t run from zombies if an elevator &#8220;sometimes works&#8221;. While a great plot device, it&#8217;s only good if I can control said plot device.</p>
<p><strong>Version 3: Piston Joint</strong></p>
<p>Piston joints are just that: a piston. You can control and constrain their linear movement so moves just like a normalÂ hydraulicÂ piston on carnival rides, etc. Fine, I&#8217;ll lose the elevator swaying/dangling behavior, but with piston constraints, it should make the coding easier, right?</p>
<p><iframe loading="lazy" width="640" height="480" src="http://www.youtube.com/embed/rzNjNBKYuGI" frameborder="0" allowfullscreen></iframe></p>
<p>Wrong.</p>
<p>Piston constraints, and Box2D in general in Corona totally breaks down when you introduce groups. In HTML, this is div&#8217;s within div&#8217;s. In Flash, this is Sprites within Sprites. In Corona, Groups are basically the same thing. When creating a game level, you can put the whole thing in a group, and just move the group to move your level.</p>
<p>Box2D, however, doesn&#8217;t like this at all. It assumes all bodies are in a same group. While you CAN put things in different groups, things get visually very strange.</p>
<p>Here is some boxes on top of each other.</p>
<p><iframe loading="lazy" width="640" height="480" src="http://www.youtube.com/embed/aXQM2feMlSQ" frameborder="0" allowfullscreen></iframe></p>
<p>Now, here&#8217;s where I move the group the 2nd box is in. You&#8217;ll see boxes pile on top of one another even though visually they are floating in space.</p>
<p><iframe loading="lazy" width="640" height="480" src="http://www.youtube.com/embed/DGR-F9M8TXw" frameborder="0" allowfullscreen></iframe></p>
<p>This change of global space also affects calls to the pistons setLimit function. Given <a href="http://lua.org">Lua</a> in Corona doesn&#8217;t have a lot of built in methods to affect coordinate space on the fly, you&#8217;re pretty much forced to keep things in a single group to keep it simple. While fine, you still have to CONTINUALLY update the coordinate space&#8230; and that doesn&#8217;t work if you a lot of classes affecting this as well as the fact that joints can move.</p>
<p><strong>Version 4: Kinematic Floor</strong></p>
<p>I knew I could knock this out in 20 minutes in Flash. So&#8230; I coded it like I could code it in Flash: Make a box, decrease its y to move it up, increase its y to move it down. In simple tests, this worked great. Again, I lost the realism factor (the whole point of using Box2D beyond saving a lot of code writing for collisions), but whatever, you MUST git-r-done and move on. Analysis paralysis == bad news bears. Kill t3h scope creep, man.</p>
<p>&#8230;however, once I applied <a href="http://developer.anscamobile.com/forum/2010/10/25/collision-filters-helper-chart">collision filters</a>, this fell on it&#8217;s face. The same exact code works just fine using a dynamic body, but kinematic? <a href="http://darthno.ytmnd.com/">NOoooooOOOOOooo</a>&#8230;.</p>
<p><iframe loading="lazy" width="640" height="360" src="http://www.youtube.com/embed/cwARXbQHnKg" frameborder="0" allowfullscreen></iframe></p>
<p>Debugging collision filters are impossible; they either work, or they don&#8217;t, and your only 2 options are to check your math again or give up. The most frustrating part is that collision filters are the main reason I like using Box2D vs. my own code. When they break (or appear to&#8230; no way my math is wrong&#8230; ever&#8230; specially when I&#8217;m changing the body type&#8230; right?), they erode to whole purpose of using Box2D in the first place.</p>
<p>I have a rule: if you can&#8217;t solve something in an hour, it&#8217;s time to move on. Whether that&#8217;s another problem/bug/feature, or solution in this case, so be it. So that&#8217;s what I did. My #&#8217;s checked out, but even in the isolation tests I did, the kinematic box would NOT collide with my character and no collision events were dispatched.</p>
<p>Things got REALLY weird when I created complex bodies using filters for each part; you can see the kruft multiple body code in the elevator class on github. Totally unrelatedÂ geometryÂ would act very strange. I&#8217;m pretty positive it&#8217;s a bug in Ansca&#8217;s implementation as I suspect most are merely creating a single polygonal body for complex shapes vs. multiple (like I was for my floor, wall, and elevator ceiling).</p>
<p>Maybe if I spent another hour with a lot of sleep and no kids around I could figure it out, but the rule is there for a reason.</p>
<p><strong>Solution</strong></p>
<p>So I went back to Version 1 and just turned isFixedRotation to true. I also found that sometimes the elevator&#8217;s distance joint would get stuck at the top or bottom and even with a high maxMotorForce, the joint was simplyÂ incapableÂ of dislodging the elevator. Worse, the values WOULD continue to change and I&#8217;d receive no code errors, and visually nothing would change. Simply applying some light applyLinearImpulse (a quick jolt) up or down fixed it every time.</p>
<p>Now, when my character passes by an elevator switch or touches the elevator, the GUI appears for him to go up or down. He&#8217;d sometimes fall through the 20 pixel floor, so I increased the Box2D <a href="http://developer.anscamobile.com/reference/index/physicssetpositioniterations">position sensitivity</a>Â from 8 to 10, slowed down the elevator a tad, and this seemed to fix it. Increasing the Elevator floor&#8217;s height + density seemed to help as well.</p>
<p><strong>Conclusions</strong></p>
<p>As you can see, what I thought would be simple was made harder by my not knowing the quirks of Box2D, nor having built an Elevator with floor collisions before. That said, Box2D is really fun, and I can see how the more I learn about it, the more time it saves me for certain types of things&#8230; like my <a href="http://www.youtube.com/watch?v=BjGIhff0QDU">Die Hard</a> fire hose.</p>
<p><iframe loading="lazy" width="640" height="360" src="http://www.youtube.com/embed/-8o_vaTCaJo" frameborder="0" allowfullscreen></iframe></p>
<p>Basically, the things I need to keep in mind and learned:</p>
<ol>
<li>Keep all Box2D objects in Corona in a single Display Object; inject child dependencies if a class needs to create composited objects</li>
<li>If a joint has a length &amp; motor, but things get stuck, try increasing the body&#8217;s density, reduce nearby body&#8217;s friction, and applying a tincy bit of impulse to &#8220;git er unstuck&#8221;&#8221;.</li>
<li>Create visual test harnesses; a place where you can test your components in isolation. It&#8217;s amazing how frustrating debugging reference points are in Corona SDK as a Flash Developer. In Flash, everything is aligned top left unless you move stuff manually. You can&#8217;t even edit the registration point. In Corona, my convention is to default everything to <a href="http://developer.anscamobile.com/reference/index/objectsetreferencepoint">top left</a> to emulate how Flash works, and thus make my visual alignment coding appear cleaner&#8230; except for groups. Being able to test the elevator alone, and then in game, allowed me to quickly diagnose problems.</li>
<li>To heck with you piston joint. You&#8217;reÂ awesome, but until Corona makes it easier for you to adjust being in a different global coordinate space, I&#8217;m sticking with <a href="http://developer.anscamobile.com/content/game-edition-physics-joints">distance and touch joints</a>.</li>
<li>I really wish I knew why my kinematic bodies aren&#8217;t working with my collision filters. In isolated tests, it works just fine.</li>
</ol>
<p>I hope this helps you in your Box2D adventures.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://jessewarden.com/2012/02/building-an-elevator-in-box2d.html/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
