private void Initialize()
		{
			this.music = Assets.Default.Sounds.music.play(0, 9999);




			EgoView = new ViewEngine(DefaultWidth, DefaultHeight)
			{
				FloorAndCeilingVisible = false,
				RenderLowQualityWalls = false,
				ViewDirection = 0,
				ViewPosition = new Point()
			};

			EgoView.Image.scaleX = DefaultScale;
			EgoView.Image.scaleY = DefaultScale;
			EgoView.Image.alpha = 0;
			EgoView.Image.AttachTo(this);

			// show fps
			new TextField { textColor = 0xff0000, x = DefaultControlWidth / 2 }.AttachTo(this).Do(t => EgoView.FramesPerSecondChanged += () => t.text = "fps: " + EgoView.FramesPerSecond);

			EgoView.FramesPerSecondChanged +=
				delegate
				{
					if (EgoView.FramesPerSecond < 14)
						if (!EgoView.RenderLowQualityWalls)
							EgoView.RenderLowQualityWalls = true;

					if (EgoView.FramesPerSecond > 22)
						if (EgoView.RenderLowQualityWalls)
							EgoView.RenderLowQualityWalls = false;
				};


			this.HudContainer = new Sprite().AttachTo(this);
			this.HudContainer.alpha = 0;

			getpsyched = Assets.Default.getpsyched.AttachTo(this);

			getpsyched.scaleX = 2;
			getpsyched.scaleY = 2;
			getpsyched.MoveTo((DefaultControlWidth - getpsyched.width) / 2, (DefaultControlHeight - getpsyched.height) / 2);
			getpsyched.alpha = 0;

			InitializeWriteLine();

			getpsyched.FadeIn(
				delegate
				{
					Assets.Default.Sounds.gutentag.play();


					Assets.Default.dude5.ToBitmapArray(
						Bitmaps =>
						{
							var Spawn = default(Func<SpriteInfoExtended>);

							#region figure out
							if (Bitmaps == null)
								throw new Exception("No bitmaps");

							Func<Texture64[], Texture64[]> Reorder8 =
								p =>
									Enumerable.ToArray(
										from i in Enumerable.Range(0, 8)
										select p[(i + 6) % 8]
									);

							var BitmapStream = Bitmaps.Select(i => (Texture64)i).GetEnumerator();

							Func<Texture64[]> Next8 =
								delegate
								{
									// keeping compiler happy with full delegate form

									if (BitmapStream == null)
										throw new Exception("BitmapStream is null");

									return Reorder8(BitmapStream.Take(8));
								};


							var Stand = Next8();


							//if (Bitmaps.Length == 8)
							//{
							//    Spawn = () => CreateWalkingDummy(Stand);
							//}
							//else
							//{
							var Walk = new[]
							{
								Next8(),
								Next8(),
								Next8(),
								Next8(),
							};

							var Death = new List<Texture64>
							{
								BitmapStream.Take(),
								BitmapStream.Take(),
								BitmapStream.Take(),
								BitmapStream.Take(),
								BitmapStream.Take()
							};


							var Hit = new[] { BitmapStream.Take() };

							// funny ordering huh?
							Death.Add(BitmapStream.Take());

							Spawn = () => CreateWalkingDummy(Stand, Walk, Hit, Death.ToArray());

							//}

							#endregion

							CreateGuard = Spawn;




							InitializeMap();


						}
					);
				}
			);

		}
		private void Initialize()
		{
			this.stage.fullScreenSourceRect = new Rectangle
			{
				width = DefaultControlWidth,
				height = DefaultControlHeight
			};

			#region fullscreen support
			bool NextFullscreenMode = true;

			this.stage.fullScreen +=
				e =>
				{
					NextFullscreenMode = !e.fullScreen;

					// hide chat while fullscreen zoom
					this.GetStageChild().Siblings().ForEach(k => k.visible = !e.fullScreen);
				};
			
		
			this.contextMenu = new ContextMenuEx
			{
				{ "Fullscreen", 
					delegate
					{
						this.stage.SetFullscreen(NextFullscreenMode);
					}
				}
			};
			#endregion



			this.music = Assets.Default.Music.music.play(0, 9999, new SoundTransform(0.5));




			EgoView = new ViewEngine(DefaultWidth, DefaultHeight)
			{
				FloorAndCeilingVisible = false,
				RenderLowQualityWalls = false,
				ViewDirection = 0,
				ViewPosition = new Point(0, 0)
			};

			EgoView.Image.scaleX = DefaultScale;
			EgoView.Image.scaleY = DefaultScale;
			EgoView.Image.alpha = 0;
			EgoView.Image.AttachTo(this);

			EgoView.ViewPositionChanged +=
				delegate
				{
					this.NextViewPosition = EgoView.ViewPosition;
				};

			EgoView.ViewDirectionChanged +=
				delegate
				{
					this.NextViewDirection = EgoView.ViewDirection;
				};
		
			EgoView.FramesPerSecondChanged +=
				delegate
				{
					if (EgoView.FramesPerSecond < 14)
						if (!EgoView.RenderLowQualityWalls)
							EgoView.RenderLowQualityWalls = true;

					if (EgoView.FramesPerSecond > 20)
						if (EgoView.RenderLowQualityWalls)
							EgoView.RenderLowQualityWalls = false;
				};


			this.HudContainer = new Sprite().AttachTo(this);
			this.HudContainer.alpha = 0;

			getpsyched = Assets.Default.getpsyched.AttachTo(this);

			getpsyched.scaleX = 2;
			getpsyched.scaleY = 2;
			getpsyched.MoveTo((DefaultControlWidth - getpsyched.width) / 2, (DefaultControlHeight - getpsyched.height) / 2);
			getpsyched.alpha = 0;

			InitializeWriteLine();

			this.WriteLine("init: getpsyched");

			//WriteLine("with minimap");


			getpsyched.FadeIn(
				delegate
				{
					Assets.Default.Sounds.gutentag.play();

					this.WriteLine("init: gutentag");

					var TryLoad = default(Action);

					TryLoad =
						delegate
						{
							Assets.Default.dude5.ToBitmapArray(
								CachedGuardTextures,
								Bitmaps =>
								{
									TryLoad = null;
									LoadGuardTextures(Bitmaps);
								}
							);
						};


					10000.AtDelayDo(
						delegate
						{
							if (TryLoad != null)
								TryLoad();
						}
					);

					TryLoad();

				}
			);

		}
		public FlashTreasureHunt()
		{
			//this.music = Assets.Default.music.play(0, 9999);

			Assets.Default.gutentag.play();



			EgoView = new ViewEngine(DefaultWidth, DefaultHeight)
			{
				FloorAndCeilingVisible = false,
				RenderLowQualityWalls = false
			};

			EgoView.Image.scaleX = DefaultScale;
			EgoView.Image.scaleY = DefaultScale;
			EgoView.Image.alpha = 0;
			EgoView.Image.AttachTo(this);

			this.HudContainer = new Sprite().AttachTo(this);
			this.HudContainer.alpha = 0;

			//getpsyched = Assets.Default.getpsyched.AttachTo(this);

			//getpsyched.scaleX = 2;
			//getpsyched.scaleY = 2;
			//getpsyched.MoveTo((DefaultControlWidth - getpsyched.width) / 2, (DefaultControlHeight - getpsyched.height) / 2);


			ResetEgoPosition();

			Assets.Default.dude5.ToBitmapArray(
				Bitmaps =>
				{
					var Spawn = default(Func<SpriteInfoExtended>);

					#region figure out
					if (Bitmaps == null)
						throw new Exception("No bitmaps");

					Func<Texture64[], Texture64[]> Reorder8 =
						p =>
							Enumerable.ToArray(
								from i in Enumerable.Range(0, 8)
								select p[(i + 6) % 8]
							);

					var BitmapStream = Bitmaps.Select(i => (Texture64)i).GetEnumerator();

					Func<Texture64[]> Next8 =
						delegate
						{
							// keeping compiler happy with full delegate form

							if (BitmapStream == null)
								throw new Exception("BitmapStream is null");

							return Reorder8(BitmapStream.Take(8));
						};


					var Stand = Next8();


					if (Bitmaps.Length == 8)
					{
						Spawn = () => CreateWalkingDummy(Stand);
					}
					else
					{
						var Walk = new[]
                        {
                            Next8(),
                            Next8(),
                            Next8(),
                            Next8(),
                        };

						Spawn = () => CreateWalkingDummy(Stand, Walk);
					}
					#endregion

					CreateGuard = Spawn;

					InitializeMap();


				}
			);



		}