enigma-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Enigma-cvs] enigma/src world.cc,1.78,1.79


From: Ralf Westram <address@hidden>
Subject: [Enigma-cvs] enigma/src world.cc,1.78,1.79
Date: Sun, 09 Nov 2003 11:46:53 +0000

Update of /cvsroot/enigma/enigma/src
In directory subversions:/tmp/cvs-serv30727/src

Modified Files:
        world.cc 
Log Message:
- added FindOtherMarble, ExchangeMarbles (exchanges positions of white and 
black marble)
- added FastRespawnActor, GetActorsInsideField



Index: world.cc
===================================================================
RCS file: /cvsroot/enigma/enigma/src/world.cc,v
retrieving revision 1.78
retrieving revision 1.79
diff -C2 -d -r1.78 -r1.79
*** world.cc    3 Nov 2003 14:10:02 -0000       1.78
--- world.cc    9 Nov 2003 11:46:50 -0000       1.79
***************
*** 1415,1429 ****
  }
  
! void world::WarpActor(Actor *a, double newx, double newy, bool /*fast*/)
  {
      V2 newpos = V2(newx, newy);
!     a->get_actorinfo()->vel = V2();
      a->warp(newpos);
  }
  
  void world::RespawnActor(Actor *a) {
      a->respawn();
  }
  
  void world::GrabActor(Actor *a)
  {
--- 1415,1476 ----
  }
  
! void world::WarpActor(Actor *a, double newx, double newy, bool keep_velocity)
  {
      V2 newpos = V2(newx, newy);
!     if (!keep_velocity)
!         a->get_actorinfo()->vel = V2();
      a->warp(newpos);
  }
  
+ void world::FastRespawnActor(Actor *a, bool keep_velocity) {
+     a->find_respawnpos();
+     const V2& p = a->get_respawnpos();
+     WarpActor(a, p[0], p[1], keep_velocity);
+ }
+ 
+ 
  void world::RespawnActor(Actor *a) {
+     a->find_respawnpos();
      a->respawn();
  }
  
+ Actor *world::FindOtherMarble(Actor *thisMarble) {
+     Actor *other = 0;
+ 
+     if (thisMarble) {
+         const char *wanted_kind = 0;
+ 
+         if (thisMarble->is_kind("ac-blackball")) wanted_kind      = 
"ac-whiteball";
+         else if (thisMarble->is_kind("ac-whiteball")) wanted_kind = 
"ac-blackball";
+ 
+         if (wanted_kind) {
+             ActorList::iterator oi = level->actorlist.begin();
+             while (!other && oi != level->actorlist.end()) {
+                 Actor *a = *oi;
+                 if (a->is_kind(wanted_kind)) {
+                     other = a;
+                 }
+                 ++oi;
+             }
+         }
+     }
+     return other;
+ }
+ 
+ bool world::ExchangeMarbles(Actor *marble1) {
+     Actor *marble2 = FindOtherMarble(marble1);
+     if (marble2) {
+         ActorInfo *info1 = marble1->get_actorinfo();
+         ActorInfo *info2 = marble2->get_actorinfo();
+ 
+         swap(info1->pos, info2->pos);
+         swap(info1->oldpos, info2->oldpos);
+ 
+         return true;
+     }
+     return false;
+ }
+ 
+ 
  void world::GrabActor(Actor *a)
  {
***************
*** 1443,1446 ****
--- 1490,1504 ----
          Actor *a = *i;
          if (length(a->get_pos()-center) < range)
+             actors.push_back(a);
+     }
+     return !actors.empty();
+ }
+ 
+ bool world::GetActorsInsideField (const GridPos& pos, vector<Actor*>& actors)
+ {
+     ActorList &al = level->actorlist;
+     for (ActorList::iterator i=al.begin(); i!=al.end(); ++i) {
+         Actor *a = *i;
+         if (GridPos(a->get_pos()) == pos)
              actors.push_back(a);
      }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]