for( int y = co[1]-2; y < co[1]+3; y ++ )
for( int x = co[0]-2; x < co[0]+3; x ++ )
{
- struct cell *cell = &world.data[ world.w*y + x ];
+ struct cell *cell = pcell((v2i){x,y});
if( cell && (cell->state & (FLAG_CANAL|FLAG_INPUT|FLAG_OUTPUT)) )
blob |= 0x1 << ((y-(co[1]-2))*5 + x-(co[0]-2));
u8 config = 0x00;
- if( world.data[y*world.w+x].state & FLAG_CANAL )
+ if( pcell((v2i){x,y})->state & FLAG_CANAL )
{
for( int i = 0; i < vg_list_size( dirs ); i ++ )
{
- struct cell *neighbour = &world.data[(y+dirs[i][1])*world.w+x+dirs[i][0]];
+ struct cell *neighbour = pcell((v2i){x+dirs[i][0], y+dirs[i][1]});
if( neighbour->state & (FLAG_CANAL|FLAG_INPUT|FLAG_OUTPUT) )
config |= 0x1 << i;
}
} else config = 0xF;
- world.data[ y*world.w+x ].config = config;
- world.data[ y*world.w+x ].state &= ~(FLAG_DROP_L|FLAG_DROP_R|FLAG_SPLIT|FLAG_MERGER);
+ pcell((v2i){x,y})->config = config;
+ pcell((v2i){x,y})->state &= ~(FLAG_DROP_L|FLAG_DROP_R|FLAG_SPLIT|FLAG_MERGER);
}
}
// R,-,L,U - 1011 (merger, 2 drop created)
- u8 config = world.data[y*world.w+x].config;
+ u8 config = pcell((v2i){x,y})->config;
if( config == 0x7 ) // splitter
{
{
for( int x = 1; x < world.w-1; x ++ )
{
- struct cell *cell = &world.data[y*world.w+x];
+ struct cell *cell = pcell((v2i){x,y});
if( cell->state & FLAG_OUTPUT )
cell->water[ buffer_next ] = 16;
v4f colour;
- struct cell *cell = &world.data[y*world.w+x];
+ struct cell *cell = pcell((v2i){x,y});
if( cell->state & FLAG_WALL ) { v4_copy( (v4f){ 0.2f, 0.2f, 0.2f, 1.0f }, colour ); }
else if( cell->state & FLAG_CANAL ) { v4_copy( (v4f){ 0.6f, 0.6f, 0.6f, 1.0f }, colour ); }