Beispiel #1
0
void setDingy( screen &green_grid, screen &red_grid, bool ship_locations[4][4] ) {
	reset_locations( ship_locations );
	green_grid.clearGrid();
	unsigned char input_direction;					//var used to move ship on board
	unsigned char row, col;							//coordinate variables
	row = 0;
	col = 0;
	green_grid.addLight( row, col );		//lights up coordinate ( 1, A ) 
	while (  1 ) {
		input_direction = getInput( green_grid, red_grid );
		if ( input_direction == 0 && row != 0 ) {
			green_grid.subLight( row, col );
			row--;
		}
		else if ( input_direction == 1 && row != 3 ) {
			green_grid.subLight( row, col );
			row++;
		}
		else if ( input_direction == 2 && col != 0 ) {
			green_grid.subLight( row, col );
			col--;
		}
		else if ( input_direction == 3 && col != 3 ) {
			green_grid.subLight( row, col );
			col++;
		}
		if ( input_direction == 4 ) {
			ship_locations[row][col] = true;
			break;
		}
		green_grid.addLight( row, col );
		green_grid.flicker();
	}
}
void maze_generator_kruskal_private::allocate_locations_table()
{
	maze_data->size_x = size_x;
	maze_data->size_y = size_y;

	unsigned int edge_count = 2 * size_x*size_y - size_y - size_x;
	locations_id_mask = get_bits_size(edge_count);

	maze_data->m_vvMapa.resize(size_x);
	for (unsigned int index = 0; index<size_x; index++)
		maze_data->m_vvMapa[index].resize(size_y);
	reset_locations();
	locations_sets.clear();
	for (unsigned int index = 0; index < size_x * size_y; index++)
		locations_sets[index] = index;
}