     kind:     sprite_dict.kind
     position: sprite_dict.position
 
-  if level.sprites[index]?
-    $.extend level.sprites[index], sprite
-  else
-    level.sprites.push sprite
-
-  custom_level.set level
+  update_level (level) ->
+    if level.sprites[index]?
+      $.extend level.sprites[index], sprite
+    else
+      level.sprites.push sprite
 
 delete_sprite = (world, sprite) ->
   level_sprite_index = get_sprite_index sprite
 
   return unless level_sprite_index > -1
 
-  level = get_level_copy()
-  level.sprites.splice level_sprite_index, 1
+  update_level (level) ->
+    level.sprites.splice level_sprite_index, 1
 
   custom_level.set level
 


  return unless level_sprite_index > -1

  level = get_level_copy()
  level.sprites[level_sprite_index][key] = value

  custom_level.set level

sprite_created = (world, sprite) ->
  return unless level_sprite_index > -1

  level = get_level_copy()
  level.sprites[level_sprite_index]

sprite_index = 0
make_sprite = (world, sprite_dict) ->


get_level_copy = ->
  $.extend {}, custom_level.get()

update_level = (change) ->
  level = get_level_copy()
  change level
  custom_level.set level

index_of_conditional = (list, condition) ->
  index = -1
