258 |
virtual void init_model(); |
virtual void init_model(); |
259 |
|
|
260 |
// Floor interface |
// Floor interface |
261 |
virtual px::V3 get_force(Actor *a); |
virtual px::V2 get_force(Actor *a); |
262 |
}; |
}; |
263 |
} |
} |
264 |
|
|
285 |
set_model(mname); |
set_model(mname); |
286 |
} |
} |
287 |
|
|
288 |
px::V3 |
px::V2 |
289 |
Gradient::get_force(Actor *a) |
Gradient::get_force(Actor *a) |
290 |
{ |
{ |
291 |
V3 force; |
V2 force; |
292 |
int t = get_type(); |
int t = get_type(); |
293 |
|
|
294 |
static int xforce[MAXTYPE-MINTYPE+1] = { |
static int xforce[MAXTYPE-MINTYPE+1] = { |
307 |
-1, -1, 1, 1, |
-1, -1, 1, 1, |
308 |
1, -1, 0, 0 |
1, -1, 0, 0 |
309 |
}; |
}; |
310 |
force = V3(xforce[t-MINTYPE], yforce[t-MINTYPE], 0); |
force = V2(xforce[t-MINTYPE], yforce[t-MINTYPE]); |
311 |
force.normalize(); |
force.normalize(); |
312 |
return 25*force; |
return 25*force; |
313 |
} |
} |
430 |
|
|
431 |
class WhiteTile : public Floor { |
class WhiteTile : public Floor { |
432 |
public: |
public: |
433 |
V3 get_force(Actor *a, V3 mouseforce) { |
V2 get_force(Actor *a, V2 mouseforce) { |
434 |
if (a->get_attrib("blackball")) |
if (a->get_attrib("blackball")) |
435 |
return Floor::get_force(a, 0); |
return Floor::get_force(a, 0); |
436 |
else |
else |
440 |
|
|
441 |
class BlackTile : public Floor { |
class BlackTile : public Floor { |
442 |
public: |
public: |
443 |
V3 get_force(Actor *a, V3 mouseforce) { |
V2 get_force(Actor *a, V2 mouseforce) { |
444 |
if (a->get_attrib("whiteball")) |
if (a->get_attrib("whiteball")) |
445 |
return Floor::get_force(a, 0); |
return Floor::get_force(a, 0); |
446 |
else |
else |
505 |
: TGridObject<GRID_STONES>(kind) |
: TGridObject<GRID_STONES>(kind) |
506 |
{} |
{} |
507 |
|
|
508 |
px::V3 |
px::V2 |
509 |
Stone::actor_impulse(const StoneContact &sc) |
Stone::actor_impulse(const StoneContact &sc) |
510 |
{ |
{ |
511 |
V3 normal = normalize(sc.normal); |
V2 normal = normalize(sc.normal); |
512 |
const V3 &v = sc.actor->get_vel(); |
const V2 &v = sc.actor->get_vel(); |
513 |
return -2*(v*normal)*normal; |
return -2*(v*normal)*normal; |
514 |
} |
} |
515 |
|
|
883 |
public: |
public: |
884 |
BlockStone() : MovableStone("st-block") {} |
BlockStone() : MovableStone("st-block") {} |
885 |
private: |
private: |
886 |
V3 get_center() const { |
V2 get_center() const { |
887 |
GridPos p = get_pos(); |
GridPos p = get_pos(); |
888 |
return V3(p.x+0.5, p.y+0.5,0); |
return V2(p.x+0.5, p.y+0.5); |
889 |
} |
} |
890 |
|
|
891 |
void on_move(){ |
void on_move(){ |
1027 |
private: |
private: |
1028 |
enum State { IDLE, FRAGILE, BREAK }; |
enum State { IDLE, FRAGILE, BREAK }; |
1029 |
State state; |
State state; |
1030 |
void change_state(State newstate) { |
void change_state (State newstate) { |
1031 |
if (newstate == BREAK) { |
if (newstate == BREAK) { |
1032 |
state = BREAK; |
state = BREAK; |
1033 |
play_sound("explosion1"); |
play_sound("explosion1"); |
1041 |
if (sc.actor->get_attrib("whiteball")) |
if (sc.actor->get_attrib("whiteball")) |
1042 |
state = FRAGILE; |
state = FRAGILE; |
1043 |
} |
} |
1044 |
if( state == FRAGILE) { |
if (state == FRAGILE) { |
1045 |
if (wielded_item_is(sc.actor, "it-hammer")) |
if (wielded_item_is(sc.actor, "it-hammer")) |
1046 |
change_state(BREAK); |
change_state(BREAK); |
1047 |
} |
} |