{"author_name":"jovoc","cat":"LD #15 - Caverns - 2009","comments":[{"author_name":"","time":"August 28, 2009 2:54 am","epoch":1251446040,"text":"Cool, I&#8217;ve been meaning to investigate this ever since reading that thread, but (predictably) have never gotten around to it.","spam":"N"},{"author_name":"","time":"August 28, 2009 3:12 am","epoch":1251447120,"text":"This is awesome! Does it still work if you do something like #define ZOMBIE_SPEED (_TV(10)) and then use ZOMBIE_SPEED several times?","spam":"N"},{"author_name":"jovoc","time":"August 28, 2009 10:16 am","epoch":1251472560,"text":"No, #defines won&#8217;t work because it depends on the __COUNTER__ macro which would get expanded differently every time you use ZOMBIE_SPEED. The best way to do that is just make a local like &#8220;const int ZOMBIE_SPEED = _TV(10);&#8221; Or if you need it to be used everywhere, make it a global and just don&#8217;t make it const and then reassign the value somewhere in your mainloop. You can always change it to a #define later once you&#8217;re done tweaking that value.","spam":"N"},{"author_name":"","time":"August 28, 2009 10:49 am","epoch":1251474540,"text":"Cool! I&#8217;m glad to see that that is working for you! <img src=\"http:\/\/ludumdare.com\/compo\/wp-includes\/images\/smilies\/simple-smile.png\" alt=\":)\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> The MollyRocket guys are really smart. \ud83d\ude09","spam":"N"},{"author_name":"professor opinion","time":"August 28, 2009 11:16 am","epoch":1251476160,"text":"Umm.. ever heard of a config file? Yeesh&#8230; sorry, this seems a little crazy. A lot crazy, actually.","spam":"N"},{"author_name":"SpaceManiac","time":"August 28, 2009 2:48 pm","epoch":1251488880,"text":"I&#8217;m using this.","spam":"N"}],"epoch":1251439440,"likes":0,"metadata":{"p_key":"73135","p_author":"jovoc","p_authorkey":"34","p_urlkey":"108957","p_title":"tweakval ftw.","p_cat":"LD #15 - Caverns - 2009","p_event":"LD15","p_time":"1251439440","p_likes":"0","p_comments":"6","p_status":"UPD5","us_key":"34","us_name":"jovoc","us_username":"jovoc","event_start":"1251417600","event_key":"1","event_name":"LD15"},"text":"<p>Alright, I&#8217;m in. I&#8217;ve got a case of iced coffee drinks and a clear schedule for the weekend. Looking forward to this.<\/p>\n <p>Also, I learned a really neat trick today (just in time for LD) and thought I&#8217;d share. In an <a title=\"Glacier\" href=\"http:\/\/www.ludumdare.com\/compo\/2009\/04\/18\/progress-and-tuning\/\">earlier post<\/a> during the &#8220;advancing wall&#8221; contest, I mentioned my experiment with trying to tune the gameplay using automatically reloading config files. That didn&#8217;t really work out so well, it worked but it was too much of a pain to add each new value to the config file. I think I only had one or two in the end. Waste of time.<\/p>\n <p>But&#8230; Ben Garney, who inspired the \u00a0approach in the first place, commented and pointed me to <a href=\"https:\/\/mollyrocket.com\/forums\/viewtopic.php?t=556\">this thread<\/a> which discusses a really neat way to handle this.<\/p>\n <p><a href=\"http:\/\/www.vickijoel.org\/tweakval.png\"><img class=\"alignnone size-medium wp-image-6866\" src=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2009\/08\/tweakval1-300x140.png\" alt=\"tweakval\" width=\"300\" height=\"140\" \/><\/a><\/p>\n <p>Click the image to expand to readable size.<\/p>\n <p>Basically, everywhere you put a constant that you want to tune, you can instead use a macro like _TV( 4.2 ) instead. The _TV stands for tweakable value. In a release build it does nothing, but in a debug build, it checks if the source file changed and updates automagically. \u00a0You can see a simple example of usage in the screenshot, I&#8217;m editing and saving the values in the source, and the printfs in the console reflect the changes.<\/p>\n <p>I just hacked this together so it&#8217;s probably a little flaky, it&#8217;s pretty much untested. \u00a0It should work on linux as well, if you&#8217;re using gcc 4.3 or above, but I haven&#8217;t tried it yet. \u00a0I&#8217;ve added this to my<a href=\"http:\/\/code.google.com\/p\/ld48jovoc\/source\/browse\/#svn\/util\/tweakval\"> ld code dump<\/a>, you just need the .h and .cpp file if you want to try it, or you can probably roll your own.<\/p>","time":"August 28th, 2009 1:04 am","title":"tweakval ftw."}