~colbyhub/pocket_dust

ed505c116208a7904e9e69c2ff2512f8510fa4ff — colbyhub 3 months ago cafb749 better-water
wip
1 files changed, 14 insertions(+), 12 deletions(-)

M src/main.c
M src/main.c => src/main.c +14 -12
@@ 363,23 363,25 @@ particle_t* update_water(uint8_t x, uint8_t y) {
  if (get_particle_updated(particle) == false && y < CANVAS_HEIGHT) {
    if (get_particle_material_id(get_particle(x, y + 1)) == MATERIAL_AIR_ID && y < CANVAS_HEIGHT - 1) {
      new_position.y = y + 1;
      move_particle(x, y, new_position.x, new_position.y);
    } 

    if (get_particle_material_id(get_particle(x, y + 1)) == MATERIAL_WATER_ID){
      // If there is air on both sides, randomly choose a direction to move
    } else if (get_particle_material_id(get_particle(x - 1, y)) == MATERIAL_AIR_ID && 
        get_particle_material_id(get_particle(x + 1, y)) == MATERIAL_AIR_ID && x < CANVAS_WIDTH - 1) {
      if ((rand() % 100) > 50) {
      if (get_particle_material_id(get_particle(x - 1, y)) == MATERIAL_AIR_ID && 
          get_particle_material_id(get_particle(x + 1, y)) == MATERIAL_AIR_ID ) {
        if ((rand() % 100) > 50) {
          new_position.x = x - 1;
        } else if (x < CANVAS_WIDTH - 1) {
          new_position.x = x + 1;
        }
      } else if (get_particle_material_id(get_particle(x - 1, y)) == MATERIAL_AIR_ID &&
          get_particle_material_id(get_particle(x + 1, y)) != MATERIAL_AIR_ID) {
        new_position.x = x - 1;
      } else {
      } else if (get_particle_material_id(get_particle(x + 1, y)) == MATERIAL_AIR_ID && x < CANVAS_WIDTH - 1) {
        new_position.x = x + 1;
      }
      move_particle(x, y, new_position.x, new_position.y);
    } else if (get_particle_material_id(get_particle(x - 1, y)) == MATERIAL_AIR_ID) {
      new_position.x = x - 1;
      move_particle(x, y, new_position.x, new_position.y);
    } else if (get_particle_material_id(get_particle(x + 1, y)) == MATERIAL_AIR_ID && x < CANVAS_WIDTH - 1) {
      new_position.x = x + 1;
      move_particle(x, y, new_position.x, new_position.y);
    }
    move_particle(x, y, new_position.x, new_position.y);

    // Extinguish fire
    if (get_particle_material_id(get_particle(x, y + 1)) == MATERIAL_FIRE_ID) {