generated from sigonasr2/CPlusPlusProjectTemplate
	Testing taller/weider shapes
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
		
							parent
							
								
									2dad7fc3a3
								
							
						
					
					
						commit
						9ae5505993
					
				| @ -8,7 +8,11 @@ void BlockClump::addBlock(int col){ | |||||||
|     blocks.push_back(Block({(float)col*12,0})); |     blocks.push_back(Block({(float)col*12,0})); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void BlockClump::addBlock(vi2d offset){ | void BlockClump::addBlock(int col,int row){ | ||||||
|  |     blocks.push_back(Block({(float)col*12,(float)row*12})); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void BlockClump::addBlock(vf2d offset){ | ||||||
|     blocks.push_back(Block(offset)); |     blocks.push_back(Block(offset)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -13,7 +13,8 @@ class BlockClump{ | |||||||
|     BlockClump(){} |     BlockClump(){} | ||||||
|     std::vector<Block>&getBlocks(); |     std::vector<Block>&getBlocks(); | ||||||
|     void addBlock(int col); |     void addBlock(int col); | ||||||
|     void addBlock(vi2d offset); |     void addBlock(int col,int row); | ||||||
|  |     void addBlock(vf2d offset); | ||||||
|     //Get a block's position relative to this block clump.
 |     //Get a block's position relative to this block clump.
 | ||||||
|     vf2d getBlockPosition(Block&b); |     vf2d getBlockPosition(Block&b); | ||||||
| }; | }; | ||||||
|  | |||||||
							
								
								
									
										20
									
								
								Board.cpp
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								Board.cpp
									
									
									
									
									
								
							| @ -14,14 +14,23 @@ Board::Board(vi2d boardSize,float gravity,float spawnRate) | |||||||
| void Board::spawnBlock(int col){ | void Board::spawnBlock(int col){ | ||||||
|     BlockClump c=BlockClump(); |     BlockClump c=BlockClump(); | ||||||
|     c.addBlock(col); |     c.addBlock(col); | ||||||
|  |     for(int counter=1;game->coinFlip(game->gen)==0;counter++) { | ||||||
|  |         c.addBlock(col,-counter); | ||||||
|  |     } | ||||||
|     if (game->coinFlip(game->gen)==0) { |     if (game->coinFlip(game->gen)==0) { | ||||||
|         if (col>0) { |         if (col>0) { | ||||||
|             c.addBlock(col-1); |             c.addBlock(col-1); | ||||||
|  |             for(int counter=1;game->coinFlip(game->gen)==0;counter++) { | ||||||
|  |                 c.addBlock(col-1,-counter); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     if (game->coinFlip(game->gen)==0) { |     if (game->coinFlip(game->gen)==0) { | ||||||
|         if (col<boardSize.x-1) { |         if (col<boardSize.x-1) { | ||||||
|             c.addBlock(col+1); |             c.addBlock(col+1); | ||||||
|  |             for(int counter=1;game->coinFlip(game->gen)==0;counter++) { | ||||||
|  |                 c.addBlock(col+1,-counter); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     clumps.push_back(c); |     clumps.push_back(c); | ||||||
| @ -39,31 +48,30 @@ void Board::removeClump(int ind){ | |||||||
|     BlockClump&c=clumps[ind]; |     BlockClump&c=clumps[ind]; | ||||||
|     for (Block&b:c.getBlocks()){ |     for (Block&b:c.getBlocks()){ | ||||||
|         if (b.markedForDeletion) continue; |         if (b.markedForDeletion) continue; | ||||||
|         vf2d relativePos=b.pos; |  | ||||||
|         b.pos=c.getBlockPosition(b); |  | ||||||
|         bool emptyAirBelow=true; |         bool emptyAirBelow=true; | ||||||
|         for (int i=0;i<cols[b.pos.x/12].size();i++) { |         for (int i=0;i<cols[b.pos.x/12].size();i++) { | ||||||
|             Block&b2=cols[b.pos.x/12][i]; |             Block&b2=cols[b.pos.x/12][i]; | ||||||
|             if (b.pos.y+12>=b2.pos.y&&b.pos.y<=b2.pos.y+12) { |             if (c.getBlockPosition(b).y+12>=b2.pos.y&&c.getBlockPosition(b).y<=b2.pos.y+12) { | ||||||
|                 emptyAirBelow=false; |                 emptyAirBelow=false; | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         if (b.pos.y>=yBottom) { |         if (c.getBlockPosition(b).y>=yBottom) { | ||||||
|             emptyAirBelow=false; |             emptyAirBelow=false; | ||||||
|         } |         } | ||||||
|         if (emptyAirBelow) { |         if (emptyAirBelow) { | ||||||
|             BlockClump c2; |             BlockClump c2; | ||||||
|             for (int i=0;i<c.getBlocks().size();i++) { |             for (int i=0;i<c.getBlocks().size();i++) { | ||||||
|                 Block&b2=c.getBlocks()[i]; |                 Block&b2=c.getBlocks()[i]; | ||||||
|                 if (b.pos.x==b2.pos.x) { |                 if (c.getBlockPosition(b).x==b2.pos.x) { | ||||||
|                     b2.markedForDeletion=true; |                     b2.markedForDeletion=true; | ||||||
|                     c2.addBlock(relativePos); |                     c2.addBlock(b2.pos); | ||||||
|                 } |                 } | ||||||
|                 c2.y=c.y; |                 c2.y=c.y; | ||||||
|             } |             } | ||||||
|             clumps.push_back(c2); |             clumps.push_back(c2); | ||||||
|         } else { |         } else { | ||||||
|  |             b.pos=c.getBlockPosition(b); | ||||||
|             cols[b.pos.x/12].push_back(b); |             cols[b.pos.x/12].push_back(b); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user