diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-06-12 17:54:03 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-06-12 17:54:03 (GMT) |
| commit | 0e8d055d8bf7a6bb6c125b1ae1c0ca69042ffbd6 (patch) | |
| tree | 90ca44d9e8ed4a23119f08301b08701e24ddf1fc /src/simulation/elements/STKM.cpp | |
| parent | 583bf2a091c5856a39d9c11dd9f0fdbe582efa7f (diff) | |
| download | powder-0e8d055d8bf7a6bb6c125b1ae1c0ca69042ffbd6.zip powder-0e8d055d8bf7a6bb6c125b1ae1c0ca69042ffbd6.tar.gz | |
TPT: Fix the bug with stickman standing on the screen edge. d0a1b14409
Diffstat (limited to 'src/simulation/elements/STKM.cpp')
| -rw-r--r-- | src/simulation/elements/STKM.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/simulation/elements/STKM.cpp b/src/simulation/elements/STKM.cpp index 772a3e5..0a8560a 100644 --- a/src/simulation/elements/STKM.cpp +++ b/src/simulation/elements/STKM.cpp @@ -74,6 +74,8 @@ int Element_STKM::graphics(GRAPHICS_FUNC_ARGS) return 1; } +#define INBOND(x, y) ((x)>=0 && (y)>=0 && (x)<XRES && (y)<YRES) + //#TPT-Directive ElementHeader Element_STKM static int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { int r, rx, ry; @@ -383,27 +385,27 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { playerp->legs[8] += (playerp->legs[8]-parts[i].x)*d; playerp->legs[9] += (playerp->legs[9]-parts[i].y)*d; - if (!sim->eval_move(PT_DUST, playerp->legs[4], playerp->legs[5], NULL)) + if (INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(PT_DUST, playerp->legs[4], playerp->legs[5], NULL)) { playerp->legs[4] = playerp->legs[6]; playerp->legs[5] = playerp->legs[7]; } - if (!sim->eval_move(PT_DUST, playerp->legs[12], playerp->legs[13], NULL)) + if (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(PT_DUST, playerp->legs[12], playerp->legs[13], NULL)) { playerp->legs[12] = playerp->legs[14]; playerp->legs[13] = playerp->legs[15]; } //This makes stick man "pop" from obstacles - if (!sim->eval_move(PT_DUST, playerp->legs[4], playerp->legs[5], NULL)) + if (INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(PT_DUST, playerp->legs[4], playerp->legs[5], NULL)) { float t; t = playerp->legs[4]; playerp->legs[4] = playerp->legs[6]; playerp->legs[6] = t; t = playerp->legs[5]; playerp->legs[5] = playerp->legs[7]; playerp->legs[7] = t; } - if (!sim->eval_move(PT_DUST, playerp->legs[12], playerp->legs[13], NULL)) + if (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(PT_DUST, playerp->legs[12], playerp->legs[13], NULL)) { float t; t = playerp->legs[12]; playerp->legs[12] = playerp->legs[14]; playerp->legs[14] = t; @@ -540,4 +542,4 @@ void Element_STKM::STKM_init_legs(Simulation * sim, playerst* playerp, int i) } -Element_STKM::~Element_STKM() {}
\ No newline at end of file +Element_STKM::~Element_STKM() {} |
