function buildAfro01 {
	makefog2(1,0,-512,lightBundleFogRed,lightBundleFogGreen,lightBundleFogBlue);
	SetFogParam(fogStart,fogEnd,lightBundleFogRed,lightBundleFogGreen,lightBundleFogBlue);
	
	// ceiling
	makelobbyceil(0,768,-7168,90,0,0);
	makelobbyceil(0,768,-6144,90,0,0);
	makelobbyceil(0,768,-5120,90,0,0);
	makelobbyceil(0,768,-4096,90,0,0);
	makelobbyceil(0,768,-3072,90,0,0);
	makelobbyceil(0,768,-2048,90,0,0);
	makelobbyceil(0,768,-1024,90,0,0);
	makelobbyceil(0,768,0,90,0,0);

	makelobbyceil(1024,768,-7168,90,0,0);
	makelobbyceil(1024,768,-6144,90,0,0);
	makelobbyceil(1024,768,-5120,90,0,0);
	makelobbyceil(1024,768,-4096,90,0,0);
	makelobbyceil(1024,768,-3072,90,0,0);
	makelobbyceil(1024,768,-2048,90,0,0);
	makelobbyceil(1024,768,-1024,90,0,0);
	makelobbyceil(1024,768,0,90,0,0);
	
	makelobbyvloer(0,-256,-7168,90,0,0);
	makelobbyvloer(0,-256,-6144,90,0,0);
	makelobbyvloer(0,-256,-5120,90,0,0);
	makelobbyvloer(0,-256,-4096,90,0,0);
	makelobbyvloer(0,-256,-3072,90,0,0);
	makelobbyvloer(0,-256,-2048,90,0,0);
	makelobbyvloer(0,-256,-1024,90,0,0);
	makelobbyvloer(0,-256,0,90,0,0);

	// tapijt (over vloer heen)
	makelobbytapijt(640,-255,0,90,0,0);
	makelobbytapijt(640,-255,-1024,90,0,0);
	makelobbytapijt(640,-255,-2048,90,0,0);
	makelobbytapijt(640,-255,-3072,90,0,0);
	makelobbytapijt(640,-255,-4096,90,0,0);
	makelobbytapijt(640,-255,-5120,90,0,0);
	makelobbytapijt(640,-255,-6144,90,0,0);
	makelobbytapijt(640,-255,-7168,90,0,0);	
	
	// rechter muur (glas)
	makelobbyglasmuur(-512,256,0,0,90,0);
	makelobbyglasmuur(-512,256,-1024,0,90,0);
	makelobbyglasmuur(-512,256,-2048,0,90,0);
	makelobbyglasmuur(-512,256,-3072,0,90,0);
	makelobbyglasmuur(-512,256,-4096,0,90,0);
	makelobbyglasmuur(-512,256,-5120,0,90,0);
	makelobbyglasmuur(-512,256,-6144,0,90,0);
	makelobbyglasmuur(-512,256,-7168,0,90,0);	

	// anim lichtmuur
	makelobbyglasmuur2(-512,256,-7168,0,90,0,lightBundleRed,lightBundleGreen,lightBundleBlue);
	makelobbyglasmuur2(-512,256,-6144,0,90,0,lightBundleRed,lightBundleGreen,lightBundleBlue);
	makelobbyglasmuur2(-512,256,-5120,0,90,0,lightBundleRed,lightBundleGreen,lightBundleBlue);
	makelobbyglasmuur2(-512,256,-4096,0,90,0,lightBundleRed,lightBundleGreen,lightBundleBlue);
	makelobbyglasmuur2(-512,256,-3072,0,90,0,lightBundleRed,lightBundleGreen,lightBundleBlue);	
	makelobbyglasmuur2(-512,256,-2048,0,90,0,lightBundleRed,lightBundleGreen,lightBundleBlue);
	makelobbyglasmuur2(-512,256,-1024,0,90,0,lightBundleRed,lightBundleGreen,lightBundleBlue);			
	makelobbyglasmuur2(-512,256,0,0,90,0,lightBundleRed,lightBundleGreen,lightBundleBlue);	
	
	randomlightBundle1; randomlightBundle2; randomlightBundle3; updateBundelXY;
	
	ascent(i in 0..8) { makelichtbundel(-128,lightBundle1[i][0]-128,-6656+lightBundle1[i][1],lightBundleRed,lightBundleGreen,lightBundleBlue,1); } 
	ascent(i in 0..8) { makelichtbundel(-128,lightBundle2[i][0]-128,-5632+lightBundle2[i][1],lightBundleRed,lightBundleGreen,lightBundleBlue,2); } 
	ascent(i in 0..8) { makelichtbundel(-128,lightBundle3[i][0]-128,-4608+lightBundle3[i][1],lightBundleRed,lightBundleGreen,lightBundleBlue,3); } 
	ascent(i in 0..8) { makelichtbundel(-128,lightBundle2[i][0]-128,-3584+lightBundle2[i][1],lightBundleRed,lightBundleGreen,lightBundleBlue,2); } 
	ascent(i in 0..8) { makelichtbundel(-128,lightBundle1[i][0]-128,-2560+lightBundle1[i][1],lightBundleRed,lightBundleGreen,lightBundleBlue,1); }
	ascent(i in 0..8) { makelichtbundel(-128,lightBundle2[i][0]-128,-1536+lightBundle2[i][1],lightBundleRed,lightBundleGreen,lightBundleBlue,2); }
	ascent(i in 0..8) { makelichtbundel(-128,lightBundle3[i][0]-128,-512+lightBundle3[i][1],lightBundleRed,lightBundleGreen,lightBundleBlue,3); } 		
	
	makemirrorbal(512,640,-5120,0,0,0);
	makemirrorbal(512,640,-1024,0,0,0);
	makemirrorlicht(512,640,-5100,0,0,0);
	makemirrorlicht(512,640,-1000,0,0,0);	
	
	makestoel(512,0,-192-6144,180);
	makestoel(512,0,192-6144,0);
	makestoel(352,0,0-6144,270);
	makestoel(672,0,0-6144,90);
	
	makestoel(512,0,-192-4096,180);
	makestoel(512,0,192-4096,0);
	makestoel(352,0,0-4096,270);
	makestoel(672,0,0-4096,90);
	
	makestoel(512,0,-192-2048,180);
	makestoel(512,0,192-2048,0);
	makestoel(352,0,0-2048,270);
	makestoel(672,0,0-2048,90);
	
	makestoel(512,0,-192,180);
	makestoel(512,0,192,0);
	makestoel(352,0,0,270);
	makestoel(672,0,0,90);

	// tafel rechts
	maketafel(512,0,0);
	maketafel(512,0,-2048);
	maketafel(512,0,-4096);
	maketafel(512,0,-6144);
	
} 

function buildAfro02 {
	SetFogParam(fogStart,fogEnd,128,96,64);
			
	// skyline
	makeafrocity(2048,0,0,0,90,180,2);
	makeafrocity(-2048,0,0,0,90,180,2);	
	makeafrocity(0,0,-2048,0,180,180,1);
	makeafrocity(0,0,2048,0,180,180,1);	

	// stars
	makeafrolucht(0,2044,-2048,0,180,0);
	makeafrolucht(0,2044,2048,0,180,0);
	makeafrolucht(-2048,2044,0,0,90,0);
	makeafrolucht(2048,2044,0,0,90,0);
	
	makeafrolucht(0,4096,-2048,0,180,0);
	makeafrolucht(0,4096,2048,0,180,0);
	makeafrolucht(-2048,4096,0,0,90,0);
	makeafrolucht(2048,4096,0,0,90,0);			
	
	// flatgebouw
	makeafroflat(0,1536,-384,0,0,0);			// achterkant
	makeafroflat(-192,1536,-192,0,90,0);	
	makeafroflat(192,1536,-192,0,90,0);				
	makeafroflat(0,1536,0,0,0,0);				// voorkant	
	
	makeafroflat(0,767,-384,0,0,0);				// achterkant
	makeafroflat(-192,767,-192,0,90,0);	
	makeafroflat(192,767,-192,0,90,0);			
	makeafroflat(0,767,0,0,0,0);				// voorkant

	makeafroflat(0,0,-384,0,0,0);				// achterkant
	makeafroflat(-192,0,-192,0,90,0);	
	makeafroflat(192,0,-192,0,90,0);					
	makeafroflat(0,0,0,0,0,0);					// voorkant
	
	makeafroflat(0,-768,-384,0,0,0);			// achterkant	
	makeafroflat(-192,-768,-192,0,90,0);	
	makeafroflat(192,-768,-192,0,90,0);	
	makeafroflat(0,-768,0,0,0,0);				// voorkant
	
	scrollStageY;
	
	// hoog
	makeafrowolk(640,4352-f,0,0,45,90,128,96,64,2);	// rechts 2
	makeafrowolk(512,4096-f,0,0,45,0,128,96,64,2);	// rechts
	makeafrowolk(-512,4608-f,0,0,45,0,128,96,64,3);	// links
	makeafrowolk(0,4096-f,256,0,45,0,128,96,64,2);	// voor	
	makeafrowolk(0,4864-f,-768,0,45,0,128,96,64,3);	// achter			

	// midden
	makeafrowolk(640,2304-f,0,0,45,90,128,96,64,2);	// rechts 2
	makeafrowolk(512,2048-f,0,0,45,0,128,96,64,2);	// rechts
	makeafrowolk(-512,2560-f,0,0,45,0,128,96,64,3);	// links
	makeafrowolk(0,2048-f,256,0,45,0,128,96,64,2);	// voor	
	makeafrowolk(0,2816-f,-768,0,45,0,128,96,64,3);	// achter
	
	// laag
	makeafrowolk(640,256-f,0,0,45,90,128,96,64,2);	// rechts 2
	makeafrowolk(512,0-f,0,0,45,0,128,96,64,2);		// rechts
	makeafrowolk(-512,512-f,0,0,45,0,128,96,64,3);	// links
	makeafrowolk(0,0-f,256,0,45,0,128,96,64,2);		// voor		
	makeafrowolk(0,768-f,-768,0,45,0,128,96,64,3);	// achter
} 

function buildAfro03 {
	SetFogParam(fogStart,fogEnd,128,96,64);
			
	// skyline
	makeafrocity(2048,0,0,0,90,180,2);
	makeafrocity(-2048,0,0,0,90,180,2);	
	makeafrocity(0,0,-2048,0,180,180,1);
	makeafrocity(0,0,2048,0,180,180,1);	
	
	// stars
	makeafrolucht(0,2044,-2048,0,180,0);
	makeafrolucht(0,2044,2048,0,180,0);
	makeafrolucht(-2048,2044,0,0,90,0);
	makeafrolucht(2048,2044,0,0,90,0);
			
	// dak + decoratie	
	makeafrodak(0,0,0,90,90,0);

	makeafrohpad(256,1,256,90,0,0);		
	makeafrodakrand(-1024,32,0,0,90,0,"sides");			// links
	makeafrodakrand(1024,32,0,0,90,0,"sides");			// rechts
	
	makeflare2(-32,8,-32,155,1,255,0,0,false);
	makeflare2(544,8,-32,155,1,255,0,0,false);
	makeflare2(-32,8,544,155,1,255,0,0,false);
	makeflare2(544,8,544,155,1,255,0,0,false);	
	
	makeafrodakrand(0,32,-1024,0,0,0,"fronts");			// achter
	makeafrodakrand(0,32,1024,0,0,0,"fronts");			// voor		

	// muur 1 malig.
	makeafroflat2(-112,-383,1024,0,0,0);	
	makeafroflat2(112,-383,1024,0,0,0);	
	
	makeafroairco(-768,64,-640,270);
	makeafroairco(-768,64,-832,270);
	
	makeafroairco(-512,64,-640,270);
	makeafroairco(-512,64,-832,270);

	makeafroairco(-256,64,-640,270);
	makeafroairco(-256,64,-832,270);
	
}

// Task to scroll stage. Reads values from the two arrays.
task scrollSprite(obj) { 
	while(!Obj_IsDeleted(obj)) { 
		ObjSprite3D_SetSourceDestRect(obj,0,1+s,512,768+s);
		yield;	
	}
}

// task to update the colour of the wall. 
task updateStageFog(obj) { 
	while(!Obj_IsDeleted(obj)) {
		ObjRender_SetColor(obj,lightBundleFogRed,lightBundleFogGreen,lightBundleFogBlue);
		yield;
	}
} 

// task to update to the colour of the bundles of light and their position
task updateBundelColour(obj,obj2,id) { 
	while(!Obj_IsDeleted(obj)) { 	
		if(id == 1) { 
			ObjRender_SetColor(obj,lightBundleRed,lightBundleGreen,lightBundleBlue);
			ObjRender_SetAlpha(obj,lightBundleAlpha1);
			ObjRender_SetColor(obj2,lightBundleRed,lightBundleGreen,lightBundleBlue);
			ObjRender_SetAlpha(obj2,lightBundleAlpha1);
		} 
		else if(id == 2) { 
			ObjRender_SetColor(obj,lightBundleRed,lightBundleGreen,lightBundleBlue);
			ObjRender_SetAlpha(obj,lightBundleAlpha2);
			ObjRender_SetColor(obj2,lightBundleRed,lightBundleGreen,lightBundleBlue);
			ObjRender_SetAlpha(obj2,lightBundleAlpha2);
		} 
		else if(id == 3) { 
			ObjRender_SetColor(obj,lightBundleRed,lightBundleGreen,lightBundleBlue);
			ObjRender_SetAlpha(obj,lightBundleAlpha3);
			ObjRender_SetColor(obj2,lightBundleRed,lightBundleGreen,lightBundleBlue);
			ObjRender_SetAlpha(obj2,lightBundleAlpha3);
		} 
		yield;	
	}
} 

// function to reposition the light rays
function updateBundelXY {
		ascent(i in 0..length(lightBundleID)) {
			Obj_Delete(lightBundleID[i]);
			Obj_Delete(lightBundleID2[i]);
		}	
}

// task to update the colour of the wall. 
task updateMuurColour(obj) { 
	while(!Obj_IsDeleted(obj)) {
		ObjRender_SetColor(obj,lightBundleRed,lightBundleGreen,lightBundleBlue);
		//SetFogParam(fogStart,fogEnd,lightBundleFogRed,lightBundleFogGreen,lightBundleFogBlue);	
		fogRed = lightBundleFogRed;
		fogGreen = lightBundleFogGreen;
		fogBlue = lightBundleFogBlue;
		yield;
	}
} 

// stg2 lichtbundle handler
task randomlightBundle1 { 
	
	lightBundle1 = lightBundleCoordinates[rand_int(0,3)];
	let colLicht = [[255, 16, 16],[16,255,16],[16,16,255],[16,255,255],[255,16,255],[255,255,16],[255,128,16]];
	let colLicht2 = [[32, 16, 16],[16,32,16],[16,16,32],[16,32,32],[32,16,32],[32,32,16],[32,16,8]];
	let colLichtKies = 0;
	let isFade = true;
	let bundelswitch = 0;
	
	// handling the fade in/out and swapping pattern
	loop { 	
		// If the bundle is fading, make a new one
		colLichtKies = rand_int(0,7);
		lightBundleRed = colLicht[colLichtKies][0]; lightBundleGreen = colLicht[colLichtKies][1]; lightBundleBlue = colLicht[colLichtKies][2];
		lightBundleFogRed = colLicht2[colLichtKies][0]; lightBundleFogGreen = colLicht2[colLichtKies][1]; lightBundleFogBlue = colLicht2[colLichtKies][2];
		
		while(isFade == true ) { 
			lightBundleAlpha1+=2; 
			lightBundleAlpha+=2;
			if (lightBundleAlpha1 == 128) { isFade = false; } 
			yield;
		} 
		while(isFade == false ) { 
			lightBundleAlpha1-=2; 
			lightBundleAlpha-=2;
			if (lightBundleAlpha1 == 0) { isFade = true; bundelswitch = 1; } 
			yield;
		}			
		if(bundelswitch == 1) { lightBundle1 = lightBundleCoordinates[rand_int(0,4)]; bundelswitch = 0; } 			
		loop(20) { yield; }
	}
}

task randomlightBundle2 { 
	lightBundle2 = lightBundleCoordinates[rand_int(0,4)];
	let colLicht = [[255, 16, 16],[16,255,16],[16,16,255],[16,255,255],[255,16,255],[255,255,16],[255,128,16]];
	let colLichtKies = 0;
	let isFade = true;
	let bundelswitch = 0;
	loop(60) { yield; } 
	
	// handling the fade in/out and swapping pattern
	loop { 	
		//lightBundleAlpha2 = 255;
		while(isFade == true ) { 
			lightBundleAlpha2+=2; 
			if (lightBundleAlpha2 == 128) { isFade = false; } 
			yield;
		} 
		while(isFade == false ) { 
			lightBundleAlpha2-=2; 
			if (lightBundleAlpha2 == 0) { isFade = true; bundelswitch = 1; } 
			yield;
		}				
		if(bundelswitch == 1) { lightBundle2 = lightBundleCoordinates[rand_int(0,4)]; bundelswitch = 0; } 	
		loop(20) { yield; }
	}
}

task randomlightBundle3 { 
	lightBundle3 = lightBundleCoordinates[rand_int(0,4)];
	let colLicht = [[255, 16, 16],[16,255,16],[16,16,255],[16,255,255],[255,16,255],[255,255,16],[255,128,16]];
	let colLichtKies = 0;
	let isFade = true;	
	let bundelswitch = 0; 
	loop(30) { yield; } 
	
	// handling the fade in/out and swapping pattern
	loop { 	 
		while(isFade == true ) { 
			lightBundleAlpha3+=2; 
			if (lightBundleAlpha3 == 128) { isFade = false; } 
			yield;
		} 
		while(isFade == false ) { 
			lightBundleAlpha3-=2; 
			if (lightBundleAlpha3 == 0) { isFade = true; bundelswitch = 1; } 
			yield;
		}		
		if(bundelswitch == 1) { lightBundle3 = lightBundleCoordinates[rand_int(0,4)]; bundelswitch = 0; }
		loop(20) { yield; }
	}
}	