 
       Smalruby.Views.CharacterModalView.setCharacter(c).render()
 
-    @new_block_position = _.clone(Smalruby.CharacterSelectorView.NEW_BLOCK_POSITION)
-    @prev_block = null
-
     @render()
 
   render: ->

        e.preventDefault()
        Smalruby.Views.CharacterModalView.setCharacter(character).render()

      addBlockButton = html.find('a.add-block-button')
      addBlockButton.click (e) =>
        e.preventDefault()

        if @prev_block
          xy = @prev_block.getRelativeToSurfaceXY()
          console.log(xy)
          console.log(@new_block_position)

        block = new Blockly.Block(Blockly.mainWorkspace, 'character_new')
        block.setCharacter(character)
        block.initSvg()
        block.render()
        block.moveBy(@new_block_position.x, @new_block_position.y)
        block.select()

        @prev_block = block
        klass = Smalruby.CharacterSelectorView
        @new_block_position.x += klass.NEW_BLOCK_DISTANCE
        if @new_block_position.x > klass.NEW_BLOCK_MAX_POSITION.x
          @new_block_position.x = klass.NEW_BLOCK_POSITION.x
        @new_block_position.y += klass.NEW_BLOCK_DISTANCE
        if @new_block_position.y > klass.NEW_BLOCK_MAX_POSITION.y
          @new_block_position.y = klass.NEW_BLOCK_POSITION.y

        character.set('using', true)

      removeButton = html.find('a.remove-button')
      removeButton.click (e) ->
        e.preventDefault()
        unless character.get('using')
          Smalruby.Collections.CharacterSet.remove(character)
      if character.get('using')
        removeButton.hide()


  el: '#character-selector-tab'

  initialize: ->
    @klass = Smalruby.CharacterSelectorView

    @listenTo(@model, name, @render) for name in ['add', 'remove', 'reset', 'change']

    @templateText = $('#character-selector-template').text()
