[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Enigma-devel] Another addition - Light passenger stone
From: |
FilE/TaRôM |
Subject: |
[Enigma-devel] Another addition - Light passenger stone |
Date: |
Sun, 2 Oct 2005 11:42:54 +0200 |
User-agent: |
KMail/1.6.1 |
Hi,
Malla from mag-heut.net gave me the idea of implementing a "light passenger"
stone, that means a stone that is pushed by a laser AND can push MULTIPLE
moveable stones. Here is a Quick and Dirty implementation
(insert in stones_simple.cc, anywhere)
-------------- BEGIN CODE ------------------
namespace
{
class LightPassengerStone : public PhotoStone, public TimeHandler {
CLONEOBJ(LightPassengerStone);
public:
LightPassengerStone(const char *kind) : PhotoStone(kind)
{isSkating=false;}
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.05, 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 lastPos = p;
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(GetStone(newPos)) 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;}
};
}
------------------ END CODE -------------------
(insert in stones_simple.cc, void stones::init_simple())
-------------- BEGIN CODE ----------------
Register(new LightPassStone);
--------------- END CODE -----------------
(insert in data/models2d.lua, anywhere)
-------------- BEGIN CODE ----------------
do
def_image("st-lightpassenger")
def_shmodel("st-lightpassenger", "st-lightpassenger", "sh-solid")
end
--------------- END CODE -----------------
anyone able to merge this addition with the subversion repositry ?
Malla has drawn the graphics. they can be downloaded at
http://www.isis.de/members/~reikoe/lightpassenger.zip
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