/[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.22 by sfennig, Sun Feb 23 16:39:54 2003 UTC revision 1.23 by sfennig, Tue Feb 25 22:48:13 2003 UTC
# Line 491  Other stones: Line 491  Other stones:
491  - \ref st-bolder  - \ref st-bolder
492  - \ref st-puzzle  - \ref st-puzzle
493  - \ref st-stone_break  - \ref st-stone_break
494    - \ref st-window
495  - \ref st-break_acwhite  - \ref st-break_acwhite
496  - \ref st-break_acblack  - \ref st-break_acblack
497  - \ref st-oneway  - \ref st-oneway
# Line 980  namespace Line 981  namespace
981  };  };
982    
983  //----------------------------------------  //----------------------------------------
984    // Window
985    //----------------------------------------
986    
987    /** \page st-window Breakable Stone
988    
989    This stone can be destroyed by an actor
990    
991    \subsection window Example
992    \verbatim
993    set_stone("st-window", 10,10)
994    \endverbatim
995    
996    \image html st-window.png
997    */
998    
999    namespace {
1000        class Window : public Stone {
1001            CLONEOBJ(Window);
1002            const char *collision_sound() {return "ballcollision";}
1003        public:
1004            Window() : Stone("st-window"), state(IDLE) {}
1005        private:
1006            enum State { IDLE, BREAK };
1007            State state;
1008            void actor_hit(const StoneContact &sc)
1009            {
1010              if( state == IDLE)
1011            {
1012              Actor *a = sc.actor;
1013                 if (a->get_vel() * sc.normal < -25 ) {
1014                    play_sound("shatter");
1015                    state = BREAK;
1016                    set_anim("st-window-anim");
1017                 }
1018              }
1019          {
1020              Actor *a = sc.actor;
1021                 if (a->get_vel() * sc.normal < -28 ) {
1022                    play_sound("shatter");
1023                    state = BREAK;
1024                    set_anim("st-window-anim");
1025                    SendMessage(a, "shatter");
1026               }
1027            }
1028         }
1029            void animcb() {
1030                if (state == BREAK) {
1031                KillStone(get_pos());
1032             }
1033          }
1034       };
1035    }
1036    
1037    //----------------------------------------
1038  // Stone_break  // Stone_break
1039  //----------------------------------------  //----------------------------------------
1040    
# Line 3560  ObjectRepos::ObjectRepos() Line 3615  ObjectRepos::ObjectRepos()
3615      add_templ(new YinYangStone2);      add_templ(new YinYangStone2);
3616    
3617      add_templ(new BlockStone);      add_templ(new BlockStone);
3618        add_templ(new Window);
3619      add_templ(new Stone_break);      add_templ(new Stone_break);
3620      add_templ(new Greenbrown_hole);      add_templ(new Greenbrown_hole);
3621      add_templ(new Greenbrown_move);      add_templ(new Greenbrown_move);

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