/[enigma]/enigma/src/stones_complex.cc
ViewVC logotype

Diff of /enigma/src/stones_complex.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22 by reallysoft, Wed Jun 25 19:35:16 2003 UTC revision 1.23 by reallysoft, Thu Jun 26 10:49:29 2003 UTC
# Line 46  namespace Line 46  namespace
46  {  {
47      class RotatorStone : public Stone, public TimeHandler {      class RotatorStone : public Stone, public TimeHandler {
48      public:      public:
49          RotatorStone(bool clockwise)          RotatorStone(bool clockwise_, bool movable_)
50          : Stone(clockwise ? "st-rotator-right" : "st-rotator-left"),              : Stone("st-rotator"), clockwise(clockwise_), movable(movable_)
           m_clockwise(clockwise)  
51          {}          {}
52    
53      private:      private:
54          static const double RATE          = 1.0;          static const double RATE          = 1.0;
55          static const double IMPULSE_DELAY = 0.1;          static const double IMPULSE_DELAY = 0.1;
56    
57          bool m_clockwise;          bool clockwise;
58            bool movable;
59    
60          Stone *clone() { return new RotatorStone(m_clockwise); }          Stone *clone() { return new RotatorStone(clockwise, movable); }
61          void dispose() { delete this; }          void dispose() { delete this; }
62    
63          void on_creation() {          void on_creation() {
# Line 71  namespace Line 72  namespace
72          void alarm() {          void alarm() {
73              GridPos p = get_pos();              GridPos p = get_pos();
74    
75              if (m_clockwise) {              if (clockwise) {
76                  send_impulse (move(p, NORTH), EAST, IMPULSE_DELAY);                  send_impulse (move(p, NORTH), EAST, IMPULSE_DELAY);
77                  send_impulse (move(p, EAST), SOUTH, IMPULSE_DELAY);                  send_impulse (move(p, EAST), SOUTH, IMPULSE_DELAY);
78                  send_impulse (move(p, SOUTH), WEST, IMPULSE_DELAY);                  send_impulse (move(p, SOUTH), WEST, IMPULSE_DELAY);
# Line 84  namespace Line 85  namespace
85              }              }
86          }          }
87    
88          void actor_hit (const StoneContact &/*sc*/) {          void init_model() {
89                set_anim(clockwise ? "st-rotator-right" : "st-rotator-left");
90            }
91    
92            void actor_hit (const StoneContact &sc) {
93                if (wielded_item_is(sc.actor, "it-wrench")) {
94                    clockwise = !clockwise;
95                    init_model();
96                }
97    
98                if (movable)
99                    maybe_push_stone(sc);
100            }
101    
102            void on_impulse(const Impulse& impulse) {
103                if (movable)
104                    move_stone(impulse.dir);
105          }          }
106      };      };
107  }  }
# Line 567  namespace Line 583  namespace
583              if (state == FALLING)              if (state == FALLING)
584                  return;                  return;
585    
586              if (impulse.sender && 0 == strncmp(impulse.sender->get_kind(), "st-rotator-", 11)) {  //             if (impulse.sender && 0 == strncmp(impulse.sender->get_kind(), "st-rotator-", 11)) {
587                if (impulse.sender && impulse.sender->is_kind("st-rotator")) {
588                  set_dir(impulse.dir);                  set_dir(impulse.dir);
589              }              }
590              init_model();              init_model();
# Line 2798  void stones::Init_complex() Line 2815  void stones::Init_complex()
2815      Register("st-bigbrick-esw", new BigBrick(8));      Register("st-bigbrick-esw", new BigBrick(8));
2816      Register("st-bigbrick-nesw", new BigBrick(16));      Register("st-bigbrick-nesw", new BigBrick(16));
2817    
2818      Register (new RotatorStone (true));      Register ("st-rotator-right", new RotatorStone(true, false));
2819      Register (new RotatorStone (false));      Register ("st-rotator-left", new RotatorStone(false, false));
2820        Register ("st-rotator_move-right", new RotatorStone(true, true));
2821        Register ("st-rotator_move-left", new RotatorStone(false, true));
2822    
2823      Register(new ShogunStone);      Register(new ShogunStone);
2824      Register("st-shogun-s", new ShogunStone(1));      Register("st-shogun-s", new ShogunStone(1));

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26