~colbyhub/pocket_dust

560ef83d7eb308a8e3228c83424ad6107221319e — colbyhub 4 months ago d13891b
Reduce water escapism
1 files changed, 17 insertions(+), 12 deletions(-)

M src/main.c
M src/main.c => src/main.c +17 -12
@@ 365,35 365,40 @@ particle_t* update_water(uint8_t x, uint8_t y) {
        y < CANVAS_HEIGHT - 1
        ) {
      // set_particle_color(particle, 1);
      if ((rand() % 100) > 50) {
      if (((rand() % 100) > 50) && x > 0) {
        new_position.x = x - 1;
      } else if (x < CANVAS_WIDTH - 1) {
        new_position.x = x + 1;
      }
      new_position.y = y + 1;
    } else if (get_particle_material_id(get_particle(x - 1, y + 1)) == MATERIAL_AIR_ID
      && y < CANVAS_HEIGHT - 1
    } else if (get_particle_material_id(get_particle(x - 1, y + 1)) == MATERIAL_AIR_ID &&
        x > 0 &&
        y < CANVAS_HEIGHT - 1
       ) {
      new_position.x = x - 1;
      new_position.y = y + 1;
    } else if (get_particle_material_id(get_particle(x + 1, y + 1)) == MATERIAL_AIR_ID
        && y < CANVAS_HEIGHT - 1
    } else if (get_particle_material_id(get_particle(x + 1, y + 1)) == MATERIAL_AIR_ID &&
        x < CANVAS_WIDTH - 1 &&
        y < CANVAS_HEIGHT - 1
        ) {
      new_position.x = x + 1;
      new_position.y = y + 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) {
      if ((rand() % 100) > 50) {
      if (((rand() % 100) > 50) && x > 0) {
        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) {
    } else if (get_particle_material_id(get_particle(x - 1, y)) == MATERIAL_AIR_ID &&
        x > 0
        ) {
      new_position.x = x - 1;
    } else if (get_particle_material_id(get_particle(x + 1, y)) == MATERIAL_AIR_ID && x < CANVAS_WIDTH - 1) {
    } 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);

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


@@ 494,14 499,14 @@ void update(void) {
  static int primary_material_id = 1;
  static int secondary_material_id = 2;

  for (int x = CANVAS_WIDTH - 1; x >= 0; x--) {
  for (int x = CANVAS_WIDTH; x >= 0; x--) {
    for (int y = CANVAS_HEIGHT - 1; y >= 0; y--) {
      set_particle_updated(get_particle(x, y), false);
    }
  }

  for (int x = 0; x < CANVAS_WIDTH; x++) {
    for (int y = CANVAS_HEIGHT - 1; y > 0; y--) {
  for (int x = 0; x <= CANVAS_WIDTH; x++) {
    for (int y = CANVAS_HEIGHT - 1; y >= 0; y--) {
      particle_t *particle = get_particle(x, y);

      switch (get_particle_material_id(particle)) {