 
 Tile = require('./Tile.coffee')
 Sprite = require('./Sprite.coffee')
+
+class Nodule
+    constructor: ($rootScope, noduleName, onEntry, onExit)->
+        @scope = $rootScope
+        @name = noduleName
+        @onEntry = onEntry
+        @onExit = onExit
+        @isActive = false
+
+        @scope.$on('switchToModule', (event, nextModule)=>
+            console.log('switch to nodule', @)
+            if not @isActive
+                if nextModule == @name  # if switching to this module
+                    @isActive = true
+                    @onEntry()
+            else
+                # switching from this module to another
+                @isActive = false
+                @onExit()
+        )
+
+
+    # mock functions for optional constructor args
+    onEntry: ()->
+        return
+    onExit: ()->
+        return
+
 
 # switching to javascript here...
 `

    vm.shipW = 150;
    vm.shipH = 338;

    vm.active = false;
    vm.music = new Howl({
        urls: ['assets/sound/music/ambience1/ambience1.mp3', 'assets/sound/music/ambience1/ambience1.ogg'],
        loop: true

        var result = $interval.cancel(timeoutId);
        if (result == true) timeoutId = undefined;
    }

    vm.stopTravel = function(){
        vm.travelling = false;
