Saturday, April 26, 2014

MelonJS collision with entities not working

I recently started playing around with MelonJS to create a simple platformer game. Quickly I ran into an issue where my character was not colliding with other entities. The strange this is that the character was respecting the solid objects specified in the collision layer of the TMX map. This lead to several problems like not being able to pick up coins and being unable to change to the next level. The problem turned out to be that in the player's update method, I was not telling the game engine to process these types of collisions.
    update: function(dt) {

        // check entity collision
        var res = me.game.world.collide(this);
 
        // check & update player movement
        this.updateMovement();

        ...
    },
The key is to make sure you have the me.game.world.collide(this) call.

Wednesday, February 26, 2014

Tortoise SVN log merge multiple revision diffs

If you are doing a review, it can often be hard to see what was changed across multiple commits. Sometimes the same file is edited multiple times and you want to see what the difference between the initial and the final revisions are instead of trying to mentally add up all of the changes. If you are using Tortoise SVN, this is very easy and intuitive. To see a unified diff between multiple revisions, open the GUI Tortoise SVN log client. Then simply select multiple revisions by holding shift or ctrl and all the work is done for you. The bottom most pane will have the unified diff of all the revisions that were selected!

Tuesday, February 25, 2014

Word 2013 Cookies Must Be Enabled

I came across an issue where I was not able to sign in to SkyDrive/OneDrive with my Microsoft account with Word 2013. I constantly came across a popup that told me that "Cookies Must Be Enabled". Some simple searching showed that a possible solution was to set Privacy settings to Low in Internet Explorer. This did not fix the issue for me. However, to fix it I ended up allowing cookies from microsoft.com and live.com. To do this go to Sites and type in those two sites to allow.

Wednesday, February 19, 2014

Ant execute actions based on if else conditions for an environment variable

Sometimes you may need to take different actions during your Java application build process depending on if an environment variable is set. A scenario that I came across is that if a particular environment variable was set, then files needed to be copied from one location, otherwise from another. Apache Ant is not meant to be a programming language so it is often difficult to accomplish tasks like this. However, I found a way to do this by creating two sub-targets for each boolean value of a conditional. Each target is conditionally executed by using if and unless attributes which check the property if the environment variable VARIABLE was set.
<property environment="env"/>

<condition property="exists.envVar">
    <isset property="env.VARIABLE"/>
</condition>

<target name="task" depends="-task-true, -task-false"/>

<target name="-task-true" if="exists.envVar">
    <echo>Execute something here</echo>
</target>

<target name="-task-false" unless="exists.envVar">
    <echo>Or execute this instead</echo>
</target>
The sub-targets are prepended with - character and are missing documentation attribute so that they cannot be executed from the command line. The user calls the main target (task in this example), and the logic does the rest.