// level specification

var numberOfLevels = 20;

// Level Text
var hintText = new Array ("",
"Use left / right arrow keys",
 "Catch all the balls",
 "Don't catch the yellow ball",
 "Explosions turn yellow balls into red balls",
 "You can hide below the grey block",
 "Explode the box for bonus points",
 "Explode the box to create extra balls",
 "Powerup lets you catch yellow balls",
 "Bouncy bouncy!",
 "Powerup City",
 "'Fly' powerup enables up / down arrows!",
 "All together now",
 "Flying school",
 "Mexican wave",
 "What goes up must come down",
 "Pachinko!",
 "Catch me if you can",
 "Blocks on the Move",
 "A load of balls",
 "Chaotic behaviour");

// source locations (easier than typing the same numbers each time)
var source_y = 4; // all sources start at same height

// one or three sources - use source_x_02 for single source
var source_x_01 = 86;
var source_x_02 = 176;
var source_x_03 = 268;

// two sources
var source_x_04 = 115;
var source_x_05 = 237;

// four sources
var source_x_06 = 66;
var source_x_07 = 139;
var source_x_08 = 213;
var source_x_09 = 286;

// five sources - use source_x_02 for middle sources
var source_x_10 = 53;
var source_x_11 = 119;
var source_x_12 = 237;
var source_x_13 = 298;

 var source1_x = 4;
var source1_y = 4;
var source2_x = 168;
var source2_y = 4;
var source3_x = 336;
var source3_y = 4;

function CreateLevels()
{
	// reference for creating level objects
	// CreateSource(colour, x_pos, y_pos) - colour is just the graphic
	// StartSource(oSource, number, colour, interval, delay) - colour of balls created
	// CreatePowerup(type, x_pos, y_pos, vx, vy, speed) - vx, vy must be unit vector
	
	// mapwidth = 368 px
	// map height = 380 px
	// no objects above 50 px
	
	switch (currentLevel)
	{
		case 1:
			// create source
			var oSource2 = CreateSource("red", source_x_02, source_y);
				
			// start the red balls
			ballsToCatch = 1;
			StartSource(oSource2, ballsToCatch, "red", 4, 0); 
			break;
		case 2:
			// create source
			var oSource2 = CreateSource("red", source_x_02, source_y);
				
			// start the red balls
			ballsToCatch = 5;
			StartSource(oSource2, ballsToCatch, "red", 4, 0); 
			break;
		case 3:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_04, source_y);
			var oSource2 = CreateSource("red", source_x_05, source_y);
			
			// start the red balls
			ballsToCatch = 5;
			StartSource(oSource2, ballsToCatch, "red", 4, 0);
			
			// start some yellow balls with a delay
			StartSource(oSource1, 1, "yellow", 8, 2);
			break;
		case 4:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_01, source_y);
			var oSource2 = CreateSource("red", source_x_02, source_y);
			var oSource3 = CreateSource("yellow", source_x_03, source_y);
			
			// start the red balls
			ballsToCatch = 10;
			StartSource(oSource2, ballsToCatch, "red", 4, 0);
			
			// start some yellow balls with a delay
			StartSource(oSource1, 4, "yellow", 12, 2);
			StartSource(oSource3, 4, "yellow", 12, 6);
			break;
		case 5:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_01, source_y);
			var oSource2 = CreateSource("red", source_x_02, source_y);
			var oSource3 = CreateSource("yellow", source_x_03, source_y);
			
			// start the red balls
			ballsToCatch = 10;
			StartSource(oSource2, ballsToCatch, "red", 4, 0);
			
			// start some yellow balls with a delay
			StartSource(oSource1, 4, "yellow", 12, 2);
			StartSource(oSource3, 4, "yellow", 12, 6);
			
			// create blocks
//			CreatePowerup("block", 20, 314, 1, 0, 0);
			CreatePowerup("block", 284, 314, 1, 0, 0);
			break;
		case 6:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_04, source_y);
			var oSource2 = CreateSource("red", source_x_05, source_y);
			
			// start the red balls
			ballsToCatch = 10;
			StartSource(oSource2, ballsToCatch, "red", 4, 0);
			
			// start the yellow balls
			StartSource(oSource1, 5, "yellow", 8, 2);
			
			// create a powerup
			CreatePowerup("points", 152, 254, 1, 0, 0);
			break;
		case 7:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_01, source_y);
			var oSource2 = CreateSource("red", source_x_02, source_y);
			var oSource3 = CreateSource("yellow", source_x_03, source_y);
			
			// start the red balls
			ballsToCatch = 10;
			StartSource(oSource2, ballsToCatch, "red", 4, 0);
			
			// start some yellow balls with a delay
			StartSource(oSource1, 4, "yellow", 16, 4);
			StartSource(oSource3, 4, "yellow", 16, 4);
			
			// create blocks
			CreatePowerup("block", 152, 170, 1, 0, 10);
			CreatePowerup("balls", 152, 235, 1, 0, 0);
			break;
		case 8:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_01, source_y);
			var oSource2 = CreateSource("red", source_x_02, source_y);
			var oSource3 = CreateSource("yellow", source_x_03, source_y);
			
			// start the red balls
			ballsToCatch = 10;
			StartSource(oSource2, ballsToCatch, "red", 6, 8);
			
			// start some yellow balls with a delay
			StartSource(oSource1, 4, "yellow", 3, 0);
			StartSource(oSource3, 4, "yellow", 3, 1);
			
			// create blocks
			CreatePowerup("catchyellows", 152, 180, 1, 0, 10);
			CreatePowerup("catchyellows", 152, 235, -1, 0, 10);
			break;
		case 9:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_01, source_y);
			var oSource2 = CreateSource("red", source_x_02, source_y);
			var oSource3 = CreateSource("yellow", source_x_03, source_y);
			
			// start the red balls
			ballsToCatch = 10;
			StartSource(oSource2, ballsToCatch, "red", 8, 0);
			
			// start some yellow balls with a delay
			StartSource(oSource1, 4, "yellow", 24, 4);
			StartSource(oSource3, 4, "yellow", 24, 12);
			
			// create blocks
			CreatePowerup("block", 152, 120, 1, 0, 0);
			CreatePowerup("catchyellows", 152, 170, 0, -1, 10);
			CreatePowerup("block", 152, 314, 1, 0, 0);
			
			CreatePowerup("points", 20, 254, 0, -1, 0);
			CreatePowerup("balls", 254, 254, 0, -1, 0);
			break;
		case 10:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_01, source_y);
			var oSource2 = CreateSource("red", source_x_02, source_y);
			var oSource3 = CreateSource("yellow", source_x_03, source_y);
			
			// start the red balls
			ballsToCatch = 10;
			StartSource(oSource2, ballsToCatch, "red", 8, 8);
			
			// start some yellow balls with a delay
			StartSource(oSource1, 5, "yellow", 10, 0);
			StartSource(oSource3, 5, "yellow", 10, 4);
			
			// create blocks
			CreatePowerup("catchyellows", 20, 209, 1, 0, 10);
			CreatePowerup("balls", 280, 209, 0, -1, 10);
			CreatePowerup("catchyellows", 280, 254, -1, 0, 10);
			CreatePowerup("balls", 20, 254, 0, 1, 10);
			
			CreatePowerup("points", 152, 170, 0, -1, 0);
			break;
		case 11:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_01, source_y);
			var oSource2 = CreateSource("red", source_x_02, source_y);
			var oSource3 = CreateSource("yellow", source_x_03, source_y);
						
			// create a powerup
			CreatePowerup("fly", 152, 200, 1, 0, 0);
			
			ballsToCatch = 30;
			StartSource(oSource2, ballsToCatch, "red", 4, 0);
			
			// start some yellow balls with a delay
			StartSource(oSource1, 10, "yellow", 16, 3);
			StartSource(oSource3, 10, "yellow", 16, 5);
			break;
		case 12:
			// create sources
			var oSource1 = CreateSource("red", source_x_10, source_y);
			var oSource2 = CreateSource("yellow", source_x_11, source_y);
			var oSource3 = CreateSource("red", source_x_02, source_y);
			var oSource4 = CreateSource("yellow", source_x_12, source_y);
			var oSource5 = CreateSource("red", source_x_13, source_y);
			
			// create a powerup
			CreatePowerup("fly", 152, 249, 0, -1, 0);
			
			ballsToCatch = 30;
			StartSource(oSource1, 10, "red", 16, 0);
			StartSource(oSource3, 10, "red", 16, 0);
			StartSource(oSource5, 10, "red", 16, 0);
			
			// start some yellow balls with a delay
			StartSource(oSource2, 10, "yellow", 16, 0);
			StartSource(oSource4, 10, "yellow", 16, 0);
			break;
		case 13:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_04, source_y);
			var oSource2 = CreateSource("red", source_x_05, source_y);
			
			// start the red balls
			ballsToCatch = 20;
			StartSource(oSource2, ballsToCatch, "red", 4, 0);
			
			// start the yellow balls
			StartSource(oSource1, 20, "yellow", 8, 2);
			
			// create powerups
			CreatePowerup("block", 48, 348, 0, -1, 0);
			CreatePowerup("block", 256, 348, 0, -1, 0);
			
			CreatePowerup("balls", 48, 256, 0, -1, 0);
			CreatePowerup("fly", 152, 170, 0, -1, 0);
			CreatePowerup("catchyellows", 256, 88, 0, -1, 0);
			break;
		case 14:
			// create sources
			var oSource1 = CreateSource("red", source_x_10, source_y);
			var oSource2 = CreateSource("yellow", source_x_11, source_y);
			var oSource3 = CreateSource("red", source_x_02, source_y);
			var oSource4 = CreateSource("yellow", source_x_12, source_y);
			var oSource5 = CreateSource("red", source_x_13, source_y);
			
			// create a powerup
			CreatePowerup("catchyellows", 1, 117, 0, -1, 0);
			CreatePowerup("catchyellows", 1, 168, 0, -1, 0);
			CreatePowerup("points", 303, 212, 0, -1, 0);
			CreatePowerup("fly", 303, 263, 0, -1, 0);
			
			ballsToCatch = 30;
			StartSource(oSource1, 10, "red", 10, 0);
			StartSource(oSource3, 10, "red", 10, 1);
			StartSource(oSource5, 10, "red", 10, 2);
			
			// start some yellow balls with a delay
			StartSource(oSource2, 10, "yellow", 10, 0.5);
			StartSource(oSource4, 10, "yellow", 10, 1.5);
			break;
		case 15:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_01, source_y);
			var oSource2 = CreateSource("red", source_x_02, source_y);
			var oSource3 = CreateSource("yellow", source_x_03, source_y);
			
			// create powerups
			CreatePowerup("block", 40, 179, 0, -1, 10);
			CreatePowerup("block", 152, 179, 0, -1, 10);
			CreatePowerup("block", 264, 179, 0, -1, 10);
			CreatePowerup("fly", 152, 249, 0, -1, 0);
			
			ballsToCatch = 30;
			StartSource(oSource2, ballsToCatch, "red", 4, 0);
			
			// start some yellow balls with a delay
			StartSource(oSource1, 8, "yellow", 16, 3);
			StartSource(oSource3, 8, "yellow", 16, 5);
			break;
		case 16:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_04, source_y);
			var oSource2 = CreateSource("red", source_x_05, source_y);
			
			// start the red balls
			ballsToCatch = 30;
			StartSource(oSource2, ballsToCatch, "red", 4, 0);
			
			// start the yellow balls
			StartSource(oSource1, 10, "yellow", 16, 2);
			
			// create powerups
			CreatePowerup("block", 80, 83, 0, -1, 0);
			CreatePowerup("block", 224, 83, 0, -1, 0);
			
			CreatePowerup("block", 1, 150, 0, -1, 0);
			CreatePowerup("block", 152, 150, 0, -1, 0);
			CreatePowerup("block", 303, 150, 170, -1, 0);
			
			CreatePowerup("block", 80, 215, 0, -1, 0);
			CreatePowerup("block", 224, 215, 0, -1, 0);
			CreatePowerup("fly", 152, 215, 0, -1, 0);
			break;
		case 17:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_01, source_y);
			var oSource2 = CreateSource("red", source_x_02, source_y);
			var oSource3 = CreateSource("yellow", source_x_03, source_y);
			
			// start the red balls
			ballsToCatch = 30;
			StartSource(oSource2, ballsToCatch, "red", 8, 0);
			
			// start some yellow balls with a delay
			StartSource(oSource1, 10, "yellow", 24, 4);
			StartSource(oSource3, 10, "yellow", 24, 12);
			
			// create blocks
			CreatePowerup("block", 40, 97, 1, 0, 0);
			CreatePowerup("block", 264, 97, 0, -1, 0);
			
			CreatePowerup("block", 1, 129, -1, 0, 0);
			CreatePowerup("block", 303, 129, 0, 1, 0);
			
			CreatePowerup("block", 40, 161, 1, 0, 0);
			CreatePowerup("block", 264, 161, 0, -1, 0);
			
			CreatePowerup("fly", 152, 230, 0, -1, 10);
			
			CreatePowerup("balls", 1, 230, 1, 0, 10);
			CreatePowerup("balls", 303, 274, -1, 0, 10);
			break;
		case 18:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_04, source_y);
			var oSource2 = CreateSource("red", source_x_05, source_y);
			
			// start the red balls
			ballsToCatch = 30;
			StartSource(oSource2, ballsToCatch, "red", 4, 0);
			
			// start the yellow balls
			StartSource(oSource1, 10, "yellow", 16, 2);
			
			// create blocks
			CreatePowerup("block", 26, 178, 0, -1, 10);
			
			CreatePowerup("block", 152, 128, 1, 0, 10);
			CreatePowerup("block", 152, 178, 1, 0, 10);
			CreatePowerup("block", 152, 228, 1, 0, 10);
			
			CreatePowerup("block", 277, 178, 0, -1, 10);
			
			CreatePowerup("balls", 1, 280, 0, -1, 0);
			CreatePowerup("fly", 303, 280, 0, -1, 0);
			break;
		case 19:
			// create sources
			var oSource1 = CreateSource("red", source_x_10, source_y);
			var oSource2 = CreateSource("yellow", source_x_11, source_y);
			var oSource3 = CreateSource("red", source_x_02, source_y);
			var oSource4 = CreateSource("yellow", source_x_12, source_y);
			var oSource5 = CreateSource("red", source_x_13, source_y);
			
			ballsToCatch = 30;
			StartSource(oSource1, 10, "red", 16, 0);
			StartSource(oSource3, 10, "red", 16, 0);
			StartSource(oSource5, 10, "red", 16, 0);
			
			// start some yellow balls with a delay
			StartSource(oSource2, 8, "yellow", 16, 0);
			StartSource(oSource4, 8, "yellow", 16, 0);
			
			// create a powerup
			CreatePowerup("block", 88, 130, 0, -1, 0);
			CreatePowerup("block", 152, 130, 0, -1, 0);
			CreatePowerup("block", 216, 130, 0, -1, 0);
			
			CreatePowerup("block", 57, 162, 0, -1, 0);
			CreatePowerup("catchyellows", 121, 162, 0, -1, 0);
			CreatePowerup("balls", 185, 162, 0, -1, 0);
			CreatePowerup("block", 249, 162, 0, -1, 0);
			
			CreatePowerup("block", 1, 264, 0, -1, 0);
			CreatePowerup("block", 303, 264, 0, -1, 0);
			
			CreatePowerup("fly", 152, 260, 0, -1, 10);
			break;
		case 20:
			// create sources
			var oSource1 = CreateSource("yellow", source_x_01, source_y);
			var oSource2 = CreateSource("red", source_x_02, source_y);
			var oSource3 = CreateSource("yellow", source_x_03, source_y);
			
			ballsToCatch = 30;
			StartSource(oSource2, ballsToCatch, "red", 4, 0);
			
			// start some yellow balls with a delay
			StartSource(oSource1, 10, "yellow", 12, 3);
			StartSource(oSource3, 10, "yellow", 12, 5);
			
			// create a powerup
			var oPowerup1 = CreatePowerup("block", 20, 82, 1, 0, 10);
			var oPowerup2 = CreatePowerup("block", 283, 82, 0, 1, 10);
			var oPowerup3 = CreatePowerup("block", 283, 270, -1, 0, 10);
			var oPowerup4 = CreatePowerup("block", 20, 270, 0, -1, 10);
			
			var oPowerup1 = CreatePowerup("catchyellows", 152, 128, 1, 0, 0);
			var oPowerup1 = CreatePowerup("balls", 152, 178, 1, 0, 0);
			var oPowerup1 = CreatePowerup("fly", 152, 228, 1, 0, 0);
			break;
		// CreateSource(colour, x_pos, y_pos)
		// StartSource(oSource, number, colour, interval, delay)
		// CreatePowerup(type, x_pos, y_pos, vx, vy, speed)
	}
	return;
}
