void update_builder(Lixxie& l, const UpdateArgs& ua) { switch (l.get_frame()) { // Bau-Frame case 7: // don't glitch up through steel, but still get killed by top of // screen: first see whether trapped, then make brick. For the magic // number 13, see walker.cpp, it's because they can ascend 12 pixels. l.set_special_y(l.solid_wall_height(2) >= 13); l.set_special_x(l.get_special_x() - 1); l.draw_brick (-2, 0, 9, 1); if (l.get_special_x() < 3 && l.get_queue() <= 0) l.play_sound_if_trlo(ua, Sound::BRICK); l.move_up(); break; // Zwei Fortbewegungs-Frames case 11: // Kollision mit Landschaft? Dann umdrehen! // Kopf und Fuß werden geprüft hierfür. // +6|-18 statt +2|-16: Die Lix soll wissen, wo's hin geht. // +6|-1 ist die Koordinate über dem Stein, nicht -2, da sonst // in seltenen Fällen (Lix in dünner Horizontalen) nicht // bis zu dieser Ebene hochgebaut wird. // Die zweite Abfrage in der Und-Klammer dient dazu, Treppen // auch auf anderen Treppen bauen zu können. // Last line is Horus bug prevention. // Note that the lix has already moved up and the image has its // feet below the regular position, inside the newly placed brick. // // XX - the effective coordinate of the checking Lixxie. She has // already moved up from inside the brick, but not yet walked // forward. // 11 - numbers denote the checks in the corresp. code line below // // // // 33 22 11 // // XX // 44 44 34 24 11 // ()()()()()()()()()()()() // ()()()()()()()()()()()() // [][][][][][][][][][][][] // [][][][][][][][][][][][] // // lines 1, 2, 3, don't build through walls if ((l.is_solid(6, 1) && l.is_solid(6, -2)) || (l.is_solid(4, 1) && l.is_solid(4, -2)) || (l.is_solid(2, 1) && l.is_solid(2, -2)) // line 4, don't allow building through long, 2px-thin horiz. beams || (l.is_solid(4, 1) && l.is_solid(2, 1) && l.is_solid(0, 1) && l.is_solid(-2, 1)) // hit head || l.is_solid(6, -16) || l.is_solid(4, -16) ) { // Ueberfluessige Faehigkeitsbenutzngen an den Spieler // zurueckgeben, passiert nur bei Option "multiple Builders". // Wird von l.assign() erledigt. // See top comment for the check of special_y. l.turn(); if (l.get_special_y() == 1) l.move_down(); l.become(LixEn::WALKER); } break; case 12: case 13: l.move_ahead(); break; // Klötze zählen und ggf. zum Shrugger werden. case 15: if (l.get_special_x() <= 0) { if (l.get_queue() <= 0) l.become(LixEn::SHRUGGER); else { l.set_queue (l.get_queue() - 1); l.set_special_x(l.get_special_x() + 12); } } break; } if (l.get_ac() == LixEn::BUILDER) l.next_frame(); }
void update_platformer(Lixxie& l, const UpdateArgs& ua) { // Der Platformer hat zwei Zyklen. Im ersten Zyklus baut der den // Stein oberhalb der Laufhoehe, im allen nachfolgenden Zyklen weiter // unten. switch (l.get_frame()) { // Bauen case 1: case 17: l.set_special_x(l.get_special_x() - 1); if (l.get_frame() == 1) l.draw_brick(0, 0, 7, 1); else l.draw_brick(4, 2, 9, 3); if (l.get_special_x() < 3 && l.get_queue() <= 0) l.play_sound_if_trlo(ua, Sound::BRICK); break; case 4: // Sinnvolle Steinverlegung wie bei Frame 25 pruefen: // Kompletten naechsen Stein vorausplanen, bei Kollision NICHT drehen. if (platformer_is_solid(l, 6, -1) && platformer_is_solid(l, 8, -1) && platformer_is_solid(l, 10, -1)) { l.become(LixEn::WALKER); } break; case 6: if (! l.is_solid(0, -2)) l.move_up(); else { l.become(LixEn::SHRUGGER2); l.set_frame(platformer_standing_up_frame); } // faellt durch case 7: case 21: case 22: case 23: // 2, 1 statt 2, 0, weil wir direkt ueber dem Boden pruefen wollen, // ob da ein Pixel ist. Sonst laufen die Walker durch. if (! platformer_is_solid(l, 2, 1)) l.move_ahead(); else { l.become(LixEn::SHRUGGER2); l.set_frame(platformer_standing_up_frame); } break; case 25: // durchaus auch das letzte Frame // Kann noch ein Stein verlegt werden? if (l.get_special_x() <= 0) { if (l.get_queue() <= 0) { l.become(LixEn::SHRUGGER2); l.set_special_y(2); // Bei Klick 2 tiefer anfng. = weiterbauen } else { l.set_queue (l.get_queue() - 1); l.set_special_x(l.get_special_x() + 12); } } else if (platformer_is_solid(l, 2, 1) && platformer_is_solid(l, 4, 1) && platformer_is_solid(l, 6, 1)) { l.become(LixEn::SHRUGGER2); l.set_frame(platformer_standing_up_frame); } break; } if (l.get_ac() == LixEn::PLATFORMER) { if (l.is_last_frame()) l.set_frame(10); else l.next_frame(); } }