{"author_name":"athanazio","cat":"LD #14 - Advancing Wall of Doom - 2009","comments":[{"author_name":"Jpfed","time":"May 4, 2009 8:08 pm","epoch":1241485680,"text":"Regarding destroying objects: I&#8217;m weirded out by modifying the game objects table while iterating over it.  Even if it works, it seems like it shouldn&#8217;t.  I do something like","spam":"N"}],"epoch":1241320020,"likes":0,"metadata":{"p_key":"73289","p_author":"athanazio","p_authorkey":"825","p_urlkey":"109111","p_title":"Diodontidae \u2013 postmortem","p_cat":"LD #14 - Advancing Wall of Doom - 2009","p_event":"LD14","p_time":"1241320020","p_likes":"0","p_comments":"1","p_status":"UPD5","us_key":"825","us_name":"athanazio","us_username":"athanazio","event_start":"1239926400","event_key":"90","event_name":"LD14"},"text":"<p>I believe a better name than post mortem would be lessons learned, so let&#8217;s see my lessons learned from the\u00a0 competition. I would love to read this before the compo, as I can&#8217;t make the time go backawards, let try at least to help other newbies.<br \/>\n <strong>1. create the menu navigation at the start of the competition<\/strong><br \/>\n As I was fighting agains some physics problems during the development process most of the menu was left behind. Then I realized 30 minutes to the end that my menu would be an image =) and a play button&#8230;<\/p>\n <p>The lesson on this would be, use time in the middle of the nightmares to do these brainless activities, because what can go wrong while build a menu ? =)<\/p>\n <p><strong>2. draw in the paper build and color in the computer<\/strong><br \/>\n That helped alot, I save my day manipulate the lines with inkscape, but &#8230; in order to slice images I have a nightmare with inkscape, go with Gimp works as a breeze<\/p>\n <p><strong>3. dont split images, let the engine split for you<\/strong><br \/>\n ahhhh I spend some hours cutting images lol !!, could use something like http:\/\/love2d.org\/docs\/love_graphics_draws_1.html to draw a subsprite of the image &#8230;<\/p>\n <p><strong>4. make physics work for you<\/strong><br \/>\n Oh Well after the physics hit me in the head, I learned some details and was able to make it work in a decent way, special note for the boats that hang around over the sea, for that I created a sequence of x,y that is the path to the boats, and I try to follow the path, I believe if I make the water line as an object and change its group to only colide with the boat would be the best to move the boat around.<\/p>\n <p><strong>5. clean the tables in one place only.<\/strong><br \/>\n Not sure why, buit when I was removing items from my objects list in teh collision handler the LOVE was just crashing &#8230; workaroiund that I found : flag to items to be removed and remove in the update() method and one by one from each table, this is call at the end of the update() for each cleanable table :<\/p>\n <p>[code]&#8212; clean the tables<br \/>\n function cleanTable(table2Clean)<\/p>\n <p>for n=1,table.getn(table2Clean),1 do<br \/>\n if table2Clean[n].dirty ~= nill then<br \/>\n table2Clean[n].poly:destroy()<br \/>\n table2Clean[n].body:destroy()<br \/>\n table.remove( table2Clean, n )<br \/>\n break<br \/>\n end<br \/>\n end<br \/>\n end<br \/>\n [\/code]<\/p>\n <p>and at the collision handler, I dont remove the pig from the list, just flag it<br \/>\n and I believe that this would be a nice way to animate the pig booom =)<br \/>\n by using a multistate, like alive\/almost dead\/dying\/im outa here <img src=\"http:\/\/ludumdare.com\/compo\/wp-includes\/images\/smilies\/simple-smile.png\" alt=\":)\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><br \/>\n would change the image section, or play an animation &#8230; and at the end remove from the list<br \/>\n that would be great &#8230;<\/p>\n <p>[code]<br \/>\n function killThePig( id )<\/p>\n <p>love.audio.play( audioCollision, 1 )<br \/>\n pigsKilled = pigsKilled +1<\/p>\n <p>for n=1,table.getn(pigs),1 do<br \/>\n if pigs[n].poly:getData() == id then<br \/>\n pigs[n].dirty = true<br \/>\n break<br \/>\n end<br \/>\n end<br \/>\n end<br \/>\n [\/code]<\/p>\n <p><strong>6. reusable files should be in a folder<\/strong><br \/>\n I&#8217;m using for labels the .lua classes that I made called LOVEly-eyes, but I had this problem with the Text object that wasnt transparent &#8230; Oh well I went in the code changed the super class, Rectangle to handle this and the Text is transparent by default, cool, but but but &#8230; <img src=\"http:\/\/ludumdare.com\/compo\/wp-includes\/images\/smilies\/simple-smile.png\" alt=\":)\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> after that I just copied all the files from the LOVEly-eyes folder to my game folder &#8230; too bad because I copied a main.lua file together &#8230; If I wasnt using subversion would be a nightmare &#8230; now LOVELy-eyes are in a separated folder =)<\/p>\n <p><strong>7. use a version control system<\/strong><br \/>\n I used subversion, saved me when I made an stupid folder copy &#8230; revert and just lost some minutes of work&#8230; bu remember keep on committing =)<\/p>\n <p><strong>8. put together a zip with everything<\/strong><br \/>\n Better that just the .love file, create a package with the execs, the best would be create an installer.<\/p>\n <p><strong>9. level up level up !!!<\/strong><br \/>\n people like rewards, so more than the score I should add level concept, just with faster attack of the pigs, or a different scenario with different speed .. hummmm that would be cool a .lua file for each level <img src=\"http:\/\/ludumdare.com\/compo\/wp-includes\/images\/smilies\/simple-smile.png\" alt=\":)\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><\/p>\n <p><strong>10. collision has 2 sides &#8230; A and B<\/strong><br \/>\n It took me some time to realize that A and B collision data, first they are the DATA from the polygon nothing else, just disconnected data, not a reference, not and pointer &#8230; hehehhe string data what makes very nice and unplugged from the code, and you have to test both sides, if wherever A colide on B and the oposite, this was my colision code<\/p>\n <p>[code]function collision(a, b, c)<\/p>\n <p>if string.starts(a, &#8220;pig&#8221;) and string.starts(b, &#8220;battery&#8221;) then<br \/>\n killThePig( a )<br \/>\n removeTheBattery( b )<br \/>\n elseif string.starts(b, &#8220;pig&#8221;) and string.starts(a, &#8220;battery&#8221;) then<br \/>\n killThePig( b )<br \/>\n removeTheBattery( a )<br \/>\n elseif a == DIODONTIDAE and string.starts(b, &#8220;food&#8221;) then<br \/>\n eatFood( b )<br \/>\n elseif b == DIODONTIDAE and string.starts(a, &#8220;food&#8221;) then<br \/>\n eatFood( a )<br \/>\n end<\/p>\n <p>end<\/p>\n <p>function string.starts(String,Start)<br \/>\n return string.sub(String,1,string.len(Start))==Start<br \/>\n end<br \/>\n [\/code]<\/p>\n <p>note that I used start() because I add the object id after the type, so I can grabb it from the list, something like &#8220;crap_2&#8221;, &#8220;crap_3&#8221;<\/p>\n <p><strong>11. scroll the view is possible Luke&#8230; use the force !<\/strong><br \/>\n Ha ! not the force, at the end I solved the screen scrolling with a simple solution, calculated a shif from the main character and update this shift in the update() method and every single draw has this shift. So the camera is following the character, thats stays in the screen all the time, and to avoid the char to drop outside the world I add invisible walls on left and right side and check if the cameraX is in the possible range,<\/p>\n <p>this in the start of the code<\/p>\n <p>[code]<br \/>\n startCameraX = love.graphics.getWidth( ) \/ 2<br \/>\n startCameraY = 200<\/p>\n <p>cameraX = -startCameraX<br \/>\n cameraXLimit = {}<br \/>\n cameraXLimit.start\u00a0 = 0<br \/>\n cameraXLimit.finish = -2905<br \/>\n [\/code]<\/p>\n <p>+ cameraX on each draw<br \/>\n [code]<br \/>\n love.graphics.draw(diodontidae.image,<br \/>\n diodontidae.theChar:getX() + cameraX,<br \/>\n diodontidae.theChar:getY())<\/p>\n <p>&#8212;&#8212; draw the batteries<br \/>\n for n=1,table.getn(batteries),1 do<br \/>\n love.graphics.draw(<br \/>\n imageBattery,<br \/>\n batteries[n].body:getX() + cameraX,<br \/>\n batteries[n].body:getY(),<br \/>\n batteries[n].body:getAngle() )<br \/>\n end<br \/>\n [\/code]<br \/>\n this on the update()<\/p>\n <p>[code]\u00a0\u00a0\u00a0 cameraX = startCameraX &#8211; diodontidae.theChar:getX()<\/p>\n <p>&#8212; keep the camera in the boundaries<br \/>\n if cameraX &gt; cameraXLimit.start then<br \/>\n cameraX = cameraXLimit.start<br \/>\n elseif cameraX &lt; cameraXLimit.finish then<br \/>\n cameraX = cameraXLimit.finish<br \/>\n end<br \/>\n [\/code]<\/p>\n \n <p>Tags: <a href=\"http:\/\/ludumdare.com\/compo\/tag\/diodontidae\/\" rel=\"tag\">Diodontidae<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/lessons-learned\/\" rel=\"tag\">lessons learned<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/love\/\" rel=\"tag\">Love<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/lua\/\" rel=\"tag\">lua<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/postmortem\/\" rel=\"tag\">postmortem<\/a><\/p>","time":"May 2nd, 2009 10:07 pm","title":"Diodontidae \u2013 postmortem"}