public void add_moisture() { for (int x = 0; x < 1; x++) { for (int y = 0; y < 1; y++) { if (rnd.Next(0, 2) == 1) { continue; } Led l = leds.led_by_address(x, y, 3); if (leds.led_by_address(x, y, 2).blue > 0) { l.blue = 0; } else { l.blue = l.blue + 50; if (l.blue > 255) { l.blue = 255; } } l.color_has_changed = true; } } push_to_hardware(false); }
// constructor for LedCube Object public LedCube() { all_leds = new Led(); all_leds.x = 4; target_led = new Led(); target_led.set_address(2, 2, 2); target_led.set_colour("blue"); }
public bool move_to(int x, int y, int z) { if (led_by_address(x, y, z) == null) { return(false); } current_led = led_by_address(x, y, z); return(true); }
public void rain_drop() { for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { Led l = leds.led_by_address(x, y, 3); if (l.blue == 0) { l.blue = 250; } l.color_has_changed = true; push_to_hardware(false); } } while (leds.led_by_address(0, 0, 3).blue > 0) { for (int y = 0; y < 4; y++) { for (int x = 0; x < 4; x++) { // while (leds.led_by_address(x, y, 2).blue < 255) // { if (leds.led_by_address(x, y, 3).add_colour(0, 0, -50)) { leds.led_by_address(x, y, 2).add_colour(0, 0, 50); } //push_to_hardware(false); // } // while (leds.led_by_address(x, y, 1).blue < 255) // { if (leds.led_by_address(x, y, 2).add_colour(0, 0, -50)) { leds.led_by_address(x, y, 1).add_colour(0, 0, 50); } //push_to_hardware(false); //} //while (leds.led_by_address(x, y, 0).blue < 255) // { if (leds.led_by_address(x, y, 1).add_colour(0, 0, -50)) { leds.led_by_address(x, y, 0).add_colour(0, 0, 50); } //push_to_hardware(false); //} leds.led_by_address(x, y, 0).add_colour(0, 0, -50); //leds.led_by_address(x, y, 0).turn_off(); } push_to_hardware(false); Thread.Sleep(100); } } }
public void moisture_falls_at_value(int _falling_value) { // search on the ground and make dissapear int source_blue = 0; for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { Led l = leds.led_by_address(x, y, 0); if (l.blue >= _falling_value) { l.turn_off(); } } } for (int z = 1; z < 4; z++) { for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { Led l = leds.led_by_address(x, y, z); if (z == 3) { if (l.blue < _falling_value) { continue; } } source_blue = l.blue; source_blue = source_blue - 50; if (source_blue < 0) { source_blue = l.blue; } l.blue = l.blue - source_blue; Led l2 = leds.led_by_address(x, y, z - 1); l2.blue = l2.blue + source_blue; if (l2.blue > 255) { l2.blue = 255; } l.color_has_changed = true; l2.color_has_changed = true; } } } push_to_hardware(false); }
public bool move_back(int jump_size) { int y = current_led.y + jump_size; if (y > 3) { return(false); } if (y < 0) { return(false); } current_led = led_by_address(current_led.x, y, current_led.z); return(true); }
public bool move_right(int jump_size) { int x = current_led.x + jump_size; if (x > 3) { return(false); } if (x < 0) { return(false); } current_led = led_by_address(x, current_led.y, current_led.z); return(true); }
public bool move_up(int jump_size) { int z = current_led.z + jump_size; if (z > 3) { return(false); } if (z < 0) { return(false); } current_led = led_by_address(current_led.x, current_led.y, z); return(true); }
public LedList() // constructor for LedCube Object { for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { for (int z = 0; z < 4; z++) { Led led = new Led(); led.set_address(x, y, z); leds.Add(led); } } } current_led = led_by_address(0, 0, 0); current_color = new ColourRGB(); }
// constructor for LedCube Object public LedList() { for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { for (int z = 0; z < 4; z++) { Led led = new Led(); led.set_address(x, y, z); leds.Add(led); } } } current_led = led_by_address(0, 0, 0); current_color = new ColourRGB(); }
public LedCube() { all_leds = new Led(); all_leds.x = ALL_LEDS_X; }
public bool move_up(int jump_size) { int z = current_led.z + jump_size; if (z > 3) return false; if (z < 0) return false; current_led = led_by_address(current_led.x, current_led.y, z); return true; }
public bool move_to(int x, int y, int z) { if (led_by_address(x, y, z) == null) return false; current_led = led_by_address(x, y, z); return true; }
public bool move_right(int jump_size) { int x = current_led.x + jump_size; if (x > 3) return false; if (x < 0) return false; current_led = led_by_address(x, current_led.y, current_led.z); return true; }
public bool move_back(int jump_size) { int y = current_led.y + jump_size; if (y > 3) return false; if (y < 0) return false; current_led = led_by_address(current_led.x, y, current_led.z); return true; }