src/segment.js
/*
 * Create a random level segment.
 */
Create a random level segment.
Create a random level segment .
function makeSegment(game) {
	var bufW = param.Level.BufferWidth, x = -128;
	var seg = new Segment(x);
	var y0 = seg.floor.y, y1 = seg.ceiling.y;
	var buffers = [[x + 0.5 * bufW, 0.5 * (y0 + y1)]];
	x += bufW;
	seg.addBorder(y0, x, false, true);
	seg.addBorder(y1, x, true, true);
	var type = util.randInt(0, 1);
	switch (type) {
	default:
	case 0: seg.generateOpen(game); break;
	case 1: seg.generateMedium(game); break;
	case 2: seg.generateClosed(game); break;
	}
	y0 = seg.floor.y;
	y1 = y0 + param.Level.MaxGap;
	x = seg.x1;
	seg.extendBorders(x);
	buffers.push([x + 0.5 * bufW, 0.5 * (y0 + y1)]);
	x += bufW;
	seg.addBorder(y0, x, false, true);
	seg.addBorder(y1, x, true, true);
	seg.emit(game);
	game.buffers = buffers;
}
function makeSegment ( game ) { var bufW = param . Level . BufferWidth , x = - 128 ; var seg = new Segment ( x ) ; var y0 = seg . floor . y , y1 = seg . ceiling . y ; var buffers = [ [ x + 0.5 * bufW , 0.5 * ( y0 + y1 ) ] ] ; x += bufW ; seg . addBorder ( y0 , x , false , true ) ; seg . addBorder ( y1 , x , true , true ) ; var type = util . randInt ( 0 , 1 ) ; switch ( type ) { default : case 0 : seg . generateOpen ( game ) ; break ; case 1 : seg . generateMedium ( game ) ; break ; case 2 : seg . generateClosed ( game ) ; break ; } y0 = seg . floor . y ; y1 = y0 + param . Level . MaxGap ; x = seg . x1 ; seg . extendBorders ( x ) ; buffers . push ( [ x + 0.5 * bufW , 0.5 * ( y0 + y1 ) ] ) ; x += bufW ; seg . addBorder ( y0 , x , false , true ) ; seg . addBorder ( y1 , x , true , true ) ; seg . emit ( game ) ; game . buffers = buffers ; }
Create a random level segment.
Create a random level segment .