/[enigma]/enigma/actors.cc
ViewVC logotype

Diff of /enigma/actors.cc

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

revision 1.16 by dheck, Sun Dec 22 20:59:05 2002 UTC revision 1.17 by dheck, Wed Jan 1 20:48:28 2003 UTC
# Line 31  using namespace world; Line 31  using namespace world;
31  // ACTORS  // ACTORS
32  //======================================================================  //======================================================================
33  Actor::Actor(const char *kind, const px::V3 &p)  Actor::Actor(const char *kind, const px::V3 &p)
34      : Object(kind), actorinfo(p, V3())      : Object(kind), actorinfo(p, V3()),
35          startingpos(p), respawnpos(), use_respawnpos(false)
36  {  {
37      set_attrib("mouseforce", 0.0);      set_attrib("mouseforce", 0.0);
38      sprite_id = 0;      sprite_id = 0;
39  }  }
40    
41    void
42    Actor::respawn()
43    {
44        V3 p =(use_respawnpos) ? respawnpos : startingpos;
45        warp (p);
46    //    move();
47        on_respawn(p);
48    }
49    
50  void  void
51  Actor::init()  Actor::init()
52  {  {
# Line 52  Actor::set_attrib(const string &key, con Line 62  Actor::set_attrib(const string &key, con
62  void  void
63  Actor::on_creation(const px::V3 &p)  Actor::on_creation(const px::V3 &p)
64  {  {
65        startingpos = p;
66      set_model(get_kind(), p);      set_model(get_kind(), p);
67      move();      move();
68  }  }
69    
70    void
71    Actor::on_respawn (const px::V3 &pos)
72    {
73    }
74    
75    
76  enigma::GridPos get_field(px::V3 p)  enigma::GridPos get_field(px::V3 p)
77  {  {
78      return enigma::GridPos(static_cast<int>(p[0]), static_cast<int>(p[1]));      return enigma::GridPos(static_cast<int>(p[0]), static_cast<int>(p[1]));
# Line 65  void Line 82  void
82  Actor::warp(const px::V3 &newpos)  Actor::warp(const px::V3 &newpos)
83  {  {
84      actorinfo.pos = newpos;      actorinfo.pos = newpos;
85        actorinfo.vel = V3();
86      display::MoveSprite(sprite_id, actorinfo.pos);      display::MoveSprite(sprite_id, actorinfo.pos);
87      on_motion(actorinfo.pos);      move(); //on_motion(actorinfo.pos);
88  }  }
89    
90  void  void
# Line 180  namespace Line 198  namespace
198              Actor::on_creation(p);              Actor::on_creation(p);
199              change_state(APPEARING);              change_state(APPEARING);
200          }          }
201            void on_respawn (const px::V3 &pos)
202            {
203                change_state(APPEARING);
204            }
205                    
206          bool is_dead() { return state == DEAD; }          bool is_dead() { return state == DEAD; }
207          bool is_flying() { return state == JUMPING; }          bool is_flying() { return state == JUMPING; }
# Line 260  BasicBall::change_state(State newstate) Line 282  BasicBall::change_state(State newstate)
282      string kind=get_kind();      string kind=get_kind();
283    
284      switch (newstate) {      switch (newstate) {
285      case NORMAL: break;      case NORMAL:
286            world::ReleaseActor(this);
287            break;
288      case SHATTERING:      case SHATTERING:
289          sound::PlaySound("shatter");          sound::PlaySound("shatter");
290          world::GrabActor(this);          world::GrabActor(this);
# Line 272  BasicBall::change_state(State newstate) Line 296  BasicBall::change_state(State newstate)
296          set_model_cb("ring-anim");          set_model_cb("ring-anim");
297          break;          break;
298      case FALLING:      case FALLING:
         set_attrib("mouseforce", Value(0.0));  
299          world::GrabActor(this);          world::GrabActor(this);
300          set_model_cb(kind+"-fall");          set_model_cb(kind+"-fall");
301          break;          break;
# Line 283  BasicBall::change_state(State newstate) Line 306  BasicBall::change_state(State newstate)
306          break;          break;
307      case APPEARING:      case APPEARING:
308          set_model_cb(kind+"-appear");          set_model_cb(kind+"-appear");
309            world::GrabActor(this);
310          break;          break;
311      case DISAPPEARING:      case DISAPPEARING:
312          world::GrabActor(this);          world::GrabActor(this);

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

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