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

Diff of /enigma/src/objects.cc

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

revision 1.80 by sfennig, Fri May 16 15:33:46 2003 UTC revision 1.81 by sfennig, Sat May 17 23:07:36 2003 UTC
# Line 2565  namespace Line 2565  namespace
2565  }  }
2566    
2567  //----------------------------------------  //----------------------------------------
2568    // Timeswitch
2569    //
2570    // Attributes:
2571    //
2572    // :on              1 or 0
2573    // :target,action   as usual
2574    //----------------------------------------
2575    
2576    /** \page st-switch Switch Stone
2577    
2578    On actor hit this stone can trigger actions
2579    
2580    \image html st-switch1.png
2581    */
2582    namespace
2583    {
2584        class TimeSwitch : public OnOffStone {
2585            CLONEOBJ(TimeSwitch);
2586        public:
2587            TimeSwitch() : OnOffStone("st-timeswitch"), state(IDLE) {}
2588        private:
2589            enum State {IDLE, ON, OFF };
2590            State state;
2591            void change_state (State newstate)
2592           {
2593                if (newstate == IDLE) {
2594                    state = IDLE;
2595                }
2596            }
2597    
2598            void actor_hit(const StoneContact &sc)
2599            {
2600            
2601            if ( state == IDLE) {
2602                if (sc.actor)
2603                    state = ON;
2604                    set_on(!is_on());
2605                    PerformAction(this, is_on());
2606                    play_sound("st-switch");
2607                    set_anim("st-time1switch");
2608                }
2609            }
2610            
2611            void animcb() {
2612                if (state == ON) {
2613                set_on(!is_on());
2614                PerformAction(this, is_on());
2615                play_sound("st-switch");
2616                change_state (IDLE);
2617            }
2618         }
2619            const char *collision_sound() { return "st-metal"; }
2620       };
2621    }
2622    //----------------------------------------
2623  // FourSwitch  // FourSwitch
2624  //  //
2625  // Attributes:  // Attributes:
# Line 4522  ObjectRepos::ObjectRepos() Line 4577  ObjectRepos::ObjectRepos()
4577      add_templ(new SwitchStone);      add_templ(new SwitchStone);
4578      add_templ(new Switch_black);      add_templ(new Switch_black);
4579      add_templ(new Switch_white);      add_templ(new Switch_white);
4580        add_templ(new TimeSwitch);
4581      add_templ(new FourSwitch);      add_templ(new FourSwitch);
4582      add_templ(new LaserSwitch);      add_templ(new LaserSwitch);
4583      add_templ(new ScissorsStone);      add_templ(new ScissorsStone);

Legend:
Removed from v.1.80  
changed lines
  Added in v.1.81

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