void BreakoutLevelGenerator::generate_level(Breakout* bo) { qsrand(seed); if (seed == 0) { for (int i = 8;i > 0;i--) { for (int j = 1;j < ((bo->width() - TILE_W)/60) ;j++) { Tile* t = new Tile(j,i,6-i/2, bo); bo->tiles() += t; bo->addItem(t); } } return; } QList< QList<int> > grid; for (int x = 0;x < ((bo->width() - TILE_W*2)/60); x++) { grid.append(QList<int>()); for (int y = 0;y < 20 ;y++) { grid[x].append(0); } } for (int i = 5; i; --i) { switch (qrand()%3) { case 0: add_sine(grid); break; case 1: if (qrand() % 2) add_rand(grid); break; case 2: add_bleed(grid); break; } } int x = 0; foreach (QList<int> col , grid) { int y = 0; foreach (int i , col) { if (i) { Tile* t = new Tile(x+1, y+1 , i , bo); bo->tiles() += t; bo->addItem(t); } y++; } x++; }
int choice_direction(int ***tab, int c) { int i; i = 0; if (c == 2) i = down(tab); else if (c == 3) i = up(tab); else if (c == 5) i = left(tab); else if (c == 4) i = right(tab); else return (0); if (i != 0) add_rand(tab, count_void_case(*tab)); return (i); }