[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Enigma-cvs] enigma/src actors.cc,1.51,1.52
From: |
Daniel Heck <address@hidden> |
Subject: |
[Enigma-cvs] enigma/src actors.cc,1.51,1.52 |
Date: |
Thu, 20 Nov 2003 20:18:07 +0000 |
Update of /cvsroot/enigma/enigma/src
In directory subversions:/tmp/cvs-serv26091/src
Modified Files:
actors.cc
Log Message:
- Removed unused position argument to Actor::Actor.
- Added Actor::set_anim().
- Continued implementation of CannonBall (still rebounds from
stones and does not destroy them).
- Replaced set_model_cb() by set_anim().
Index: actors.cc
===================================================================
RCS file: /cvsroot/enigma/enigma/src/actors.cc,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** actors.cc 12 Nov 2003 09:33:48 -0000 1.51
--- actors.cc 20 Nov 2003 20:18:04 -0000 1.52
***************
*** 33,45 ****
using px::V2;
using namespace world;
! //----------------------------------------
! // Actor implementation
! //----------------------------------------
! Actor::Actor(const char *kind, const px::V2 &p)
! : Object(kind), actorinfo(p, V2()),
m_sprite(),
! startingpos(p), respawnpos(), use_respawnpos(false),
spikes(false)
{
--- 33,46 ----
using px::V2;
using namespace world;
+ using namespace actors;
!
! /* -------------------- Actor -------------------- */
! Actor::Actor(const char *kind)
! : Object(kind), actorinfo(V2(), V2()),
m_sprite(),
! startingpos(),
! respawnpos(), use_respawnpos(false),
spikes(false)
{
***************
*** 281,287 ****
}
! void
! Actor::find_respawnpos()
! {
V2& what_pos = use_respawnpos ? respawnpos : startingpos;
FreeRespawnLocationFinder unblocked(what_pos, *this);
--- 282,286 ----
}
! void Actor::find_respawnpos() {
V2& what_pos = use_respawnpos ? respawnpos : startingpos;
FreeRespawnLocationFinder unblocked(what_pos, *this);
***************
*** 289,295 ****
}
! const V2&
! Actor::get_respawnpos() const
! {
return use_respawnpos ? respawnpos : startingpos;
}
--- 288,292 ----
}
! const V2& Actor::get_respawnpos() const {
return use_respawnpos ? respawnpos : startingpos;
}
***************
*** 413,416 ****
--- 410,423 ----
}
+ void Actor::animcb () {
+ }
+
+
+ void Actor::set_anim (const string &modelname) {
+ set_model(modelname.c_str());
+ get_sprite().set_callback (this);
+ }
+
+
/* -------------------- Rotor -------------------- */
***************
*** 435,439 ****
Rotor::Rotor(const char *name, double radius)
! : Actor(name, V2())
{
world::ActorInfo *ai = get_actorinfo();
--- 442,446 ----
Rotor::Rotor(const char *name, double radius)
! : Actor(name)
{
world::ActorInfo *ai = get_actorinfo();
***************
*** 475,487 ****
! //----------------------------------------
! // Bug
! //----------------------------------------
namespace
{
class Bug : public Actor {
CLONEACTOR(Bug);
public:
! Bug() : Actor("ac-bug", V2()) {
world::ActorInfo *ai = get_actorinfo();
ai->radius = 12/64.0;
--- 482,504 ----
! /* -------------------- Bug -------------------- */
!
namespace
{
+ struct ActorTraits {
+ const char *name;
+ ActorID id;
+ float radius;
+ float mass;
+ };
+
+
+
class Bug : public Actor {
CLONEACTOR(Bug);
+
+ static ActorTraits traits;
public:
! Bug() : Actor("ac-bug") {
world::ActorInfo *ai = get_actorinfo();
ai->radius = 12/64.0;
***************
*** 495,502 ****
}
! //----------------------------------------
! // Horse
! //----------------------------------------
namespace
{
--- 512,526 ----
}
+ ActorTraits Bug::traits = {
+ "ac-bug", // name
+ ACTOR_BUG, // id
+ 12.0/64, // radius
+ 0.7 // mass
+ };
+
+
! /* -------------------- Horse -------------------- */
!
namespace
{
***************
*** 504,508 ****
CLONEACTOR(Horse);
public:
! Horse() : Actor("ac-horse", V2()) {
world::ActorInfo *ai = get_actorinfo();
ai->radius = 24/64.0;
--- 528,532 ----
CLONEACTOR(Horse);
public:
! Horse() : Actor("ac-horse") {
world::ActorInfo *ai = get_actorinfo();
ai->radius = 24/64.0;
***************
*** 517,523 ****
! //----------------------------------------
! // CannonBall
! //----------------------------------------
namespace
{
--- 541,546 ----
! /* -------------------- CannonBall -------------------- */
!
namespace
{
***************
*** 525,532 ****
CLONEACTOR(CannonBall);
public:
! CannonBall() : Actor ("ac-cannonball", V2()) {
}
bool is_flying() const { return true; }
bool is_dead() const { return false; }
};
}
--- 548,579 ----
CLONEACTOR(CannonBall);
public:
! CannonBall() : Actor ("ac-cannonball") {
}
bool is_flying() const { return true; }
bool is_dead() const { return false; }
+ bool is_on_floor() const { return false; }
+
+ // ModelCallback interface.
+ void animcb() {
+ GridPos p (get_pos());
+
+ if (Stone *st = GetStone (p)) {
+ SendMessage (st, "explode");
+ }
+ else if (Floor *fl = GetFloor(p)) {
+ if (fl->is_destroyable())
+ SetItem (p, MakeItem ("it-explosion3"));
+ }
+ KillActor (this);
+ }
+
+ void on_creation(const px::V2 &p) {
+ Actor::on_creation(p);
+
+ display::SpriteHandle &sprite = get_sprite();
+ sprite.kill();
+ sprite = display::AddEffect(p, "ac-cannonball");
+ sprite.set_callback(this);
+ }
};
}
***************
*** 538,542 ****
namespace
{
! class BasicBall : public Actor, public display::ModelCallback
{
protected:
--- 585,589 ----
namespace
{
! class BasicBall : public Actor
{
protected:
***************
*** 571,579 ****
- void set_model_cb(const string &m) {
- set_model(m.c_str());
- get_sprite().set_callback (this);
- }
-
void think (double dtime);
--- 618,621 ----
***************
*** 583,593 ****
void set_shine_model (bool shinep);
-
// ModelCallback interface.
void animcb();
! /*
! ** Actor interface.
! */
void on_creation(const px::V2 &p) {
Actor::on_creation(p);
--- 625,633 ----
void set_shine_model (bool shinep);
// ModelCallback interface.
void animcb();
! /* ---------- Actor interface ---------- */
!
void on_creation(const px::V2 &p) {
Actor::on_creation(p);
***************
*** 612,619 ****
void message(const string &m, const Value &);
- /*
- * Variables.
- */
State state; // The marble's current state
--- 652,657 ----
void message(const string &m, const Value &);
+ /* ---------- Variables ---------- */
State state; // The marble's current state
***************
*** 641,645 ****
BasicBall::BasicBall(const char *kind, double radius, double mass)
! : Actor(kind, V2()), state(NO_STATE),
m_shield_rest_time(0),
m_halostate(NOHALO),
--- 679,683 ----
BasicBall::BasicBall(const char *kind, double radius, double mass)
! : Actor(kind), state(NO_STATE),
m_shield_rest_time(0),
m_halostate(NOHALO),
***************
*** 873,879 ****
}
! void
! BasicBall::change_state(State newstate)
! {
if (newstate == state)
return;
--- 911,915 ----
}
! void BasicBall::change_state(State newstate) {
if (newstate == state)
return;
***************
*** 897,901 ****
sound::PlaySound("shatter");
world::GrabActor(this);
! set_model_cb(kind+"-shatter");
break;
case SINKING:
--- 933,937 ----
sound::PlaySound("shatter");
world::GrabActor(this);
! set_anim (kind+"-shatter");
break;
case SINKING:
***************
*** 912,936 ****
// sound::PlaySound("drown");
sound::PlaySound("dropinwater");
! // set_model_cb("ring-anim");
! set_model_cb("ac-drowned");
break;
case BUBBLING:
world::GrabActor(this);
// sound::PlaySound("drown");
! set_model_cb("ac-drowned");
break;
case FALLING:
case FALLING_VORTEX:
world::GrabActor(this);
! set_model_cb(kind+"-fall");
break;
case DEAD: break;
case JUMPING:
sound::PlaySound("boink");
! set_model_cb(kind+"-jump");
break;
case APPEARING:
case RISING_VORTEX:
! set_model_cb(kind+"-appear");
world::GrabActor(this);
break;
--- 948,972 ----
// sound::PlaySound("drown");
sound::PlaySound("dropinwater");
! // set_anim ("ring-anim");
! set_anim ("ac-drowned");
break;
case BUBBLING:
world::GrabActor(this);
// sound::PlaySound("drown");
! set_anim ("ac-drowned");
break;
case FALLING:
case FALLING_VORTEX:
world::GrabActor(this);
! set_anim(kind+"-fall");
break;
case DEAD: break;
case JUMPING:
sound::PlaySound("boink");
! set_anim(kind+"-jump");
break;
case APPEARING:
case RISING_VORTEX:
! set_anim(kind+"-appear");
world::GrabActor(this);
break;
***************
*** 944,948 ****
world::GrabActor(this);
disable_shield();
! set_model_cb(kind+"-disappear");
break;
case RESURRECTED:
--- 980,984 ----
world::GrabActor(this);
disable_shield();
! set_anim(kind+"-disappear");
break;
case RESURRECTED:
***************
*** 965,971 ****
}
! void
! BasicBall::update_halo()
! {
HaloState newstate = m_halostate;
--- 1001,1005 ----
}
! void BasicBall::update_halo() {
HaloState newstate = m_halostate;
***************
*** 1049,1053 ****
public:
! Killerball() : Actor ("ac-killerball", V2()) {
world::ActorInfo *ai = get_actorinfo();
ai->radius = 13/64.0;
--- 1083,1087 ----
public:
! Killerball() : Actor ("ac-killerball") {
world::ActorInfo *ai = get_actorinfo();
ai->radius = 13/64.0;
***************
*** 1079,1081 ****
--- 1113,1116 ----
Register(new WhiteBall_Small);
Register(new Killerball);
+ Register(new CannonBall);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Enigma-cvs] enigma/src actors.cc,1.51,1.52,
Daniel Heck <address@hidden> <=
- Prev by Date:
[Enigma-cvs] enigma/doc TODO,1.58,1.59
- Next by Date:
[Enigma-cvs] enigma/src display.hh,1.25,1.26 display.cc,1.38,1.39
- Previous by thread:
[Enigma-cvs] enigma/doc TODO,1.58,1.59
- Next by thread:
[Enigma-cvs] enigma/src display.hh,1.25,1.26 display.cc,1.38,1.39
- Index(es):