[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Enigma-devel] Another addition - Light passenger stone
From: |
FilE/TaRôM |
Subject: |
Re: [Enigma-devel] Another addition - Light passenger stone |
Date: |
Sun, 2 Oct 2005 16:46:08 +0200 |
User-agent: |
KMail/1.6.1 |
changed it a little bit, so it can only push one other stone, but this stone
may also be another light passenger.
-------------- CODE BEGIN ---------------------
namespace
{
class LightPassengerStone : public PhotoStone, public TimeHandler {
CLONEOBJ(LightPassengerStone);
public:
LightPassengerStone(const char *kind) : PhotoStone(kind)
{isSkating=false;}
bool lpmove(Direction d){
move_stone(d);
}
private:
void on_creation(GridPos p)
{
PhotoStone::on_creation(p);
photo_activate();
}
void on_removal(GridPos p)
{
photo_deactivate();
PhotoStone::on_removal(p);
}
Direction skateDir;
bool isSkating;
void notify_laseroff(){
if (isSkating) GameTimer.remove_alarm(this);
isSkating = false;
}
void notify_laseron(){
if (!isSkating) GameTimer.set_alarm(this, 0.03, true);
isSkating = true;
}
void on_laserhit(Direction dir){
skateDir=dir;
//notify_laseron();
}
void message (const string &msg, const Value &) {
}
void on_move() {
}
void alarm() {
if(isSkating) {
GridPos p = get_pos();
GridPos newPos = move(p,skateDir);
/*while (GetStone(lastPos)){
if(IsLevelBorder(lastPos)) break;
lastPos = move(lastPos, skateDir);
}
lastPos = move(lastPos,reverse(skateDir));
GridPos delta = lastPos;
while (GetStone(delta)!=this){
send_impulse(delta, skateDir);
delta = move(delta,reverse(skateDir));
}*/
if(Stone *n = GetStone(newPos)){
const string &k = n->get_kind();
if(k=="st-lightpassenger"){
LightPassengerStone *pass = (LightPassengerStone*)n;
pass->lpmove(skateDir);
}
else send_impulse(newPos, skateDir);
}
move_stone(skateDir);
}
}
void on_floor_change() {
}
bool is_movable () const { return false; }
};
class LightPassStone : public Stone {
public:
LightPassStone() : Stone("st-lightpassenger") {}
private:
Stone *clone() {
return new LightPassengerStone ("st-lightpassenger");
}
void dispose() {delete this;}
};
}
-------------- CODE END------------------
greets t.p.f.k.a.f.
___________________________________________________________
Was denken Sie über E-Mail? Wir hören auf Ihre Meinung:
http://surveylink.yahoo.com/wix/p0379378.aspx