Permalink
Browse files

loop edge mode from my mod (also works with stickmen)

  • Loading branch information...
jacob1 committed Oct 24, 2014
1 parent 6463d04 commit 12f00db2409cf325bff2da2e01366ac0a81f894e
@@ -44,9 +44,9 @@ void OptionsController::SetAirMode(int airMode)
model->SetAirMode(airMode);
}
void OptionsController::SetEdgeMode(int airMode)
void OptionsController::SetEdgeMode(int edgeMode)
{
model->SetEdgeMode(airMode);
model->SetEdgeMode(edgeMode);
}
void OptionsController::SetFullscreen(bool fullscreen)
@@ -23,7 +23,7 @@ class OptionsController {
void SetWaterEqualisation(bool state);
void SetGravityMode(int gravityMode);
void SetAirMode(int airMode);
void SetEdgeMode(int airMode);
void SetEdgeMode(int edgeMode);
void SetFullscreen(bool fullscreen);
void SetScale(bool scale);
void SetFastQuit(bool fastquit);
@@ -132,6 +132,7 @@ OptionsView::OptionsView():
AddComponent(edgeMode);
edgeMode->AddOption(std::pair<std::string, int>("Void", 0));
edgeMode->AddOption(std::pair<std::string, int>("Solid", 1));
edgeMode->AddOption(std::pair<std::string, int>("Loop", 2));
edgeMode->SetActionCallback(new EdgeModeChanged(this));
tempLabel = new ui::Label(ui::Point(8, 186), ui::Point(Size.X-96, 16), "Edge Mode");
@@ -716,6 +716,7 @@ void Simulation::SetEdgeMode(int newEdgeMode)
switch(edgeMode)
{
case 0:
case 2:
for(int i = 0; i<(XRES/CELL); i++)
{
bmap[0][i] = 0;
@@ -2385,6 +2386,30 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
int Simulation::do_move(int i, int x, int y, float nxf, float nyf)
{
int nx = (int)(nxf+0.5f), ny = (int)(nyf+0.5f), result;
if (edgeMode == 2)
{
float diffx = 0.0f, diffy = 0.0f;
if (nx < CELL)
diffx = XRES-CELL*2;
if (nx >= XRES-CELL)
diffx = -(XRES-CELL*2);
if (ny < CELL)
diffy = YRES-CELL*2;
if (ny >= YRES-CELL)
diffy = -(YRES-CELL*2);
if (diffx || diffy)
{
nxf += diffx;
nyf += diffy;
nx = (int)(nxf+0.5f);
ny = (int)(nyf+0.5f);
//make sure there isn't something blocking it on the other side
//only needed if this if statement is moved after the try_move (like my mod)
//if (!eval_move(t, nx, ny, NULL) || (t == PT_PHOT && pmap[ny][nx]))
// return -1;
}
}
if (parts[i].type == PT_NONE)
return 0;
result = try_move(i, x, y, nx, ny);
@@ -4228,6 +4253,19 @@ void Simulation::update_particles_i(int start, int inc)
fin_yf += dy;
fin_x = (int)(fin_xf+0.5f);
fin_y = (int)(fin_yf+0.5f);
if (edgeMode == 2)
{
if (fin_x < CELL)
fin_xf += XRES-CELL*2;
if (fin_x >= XRES-CELL)
fin_xf -= XRES-CELL*2;
if (fin_y < CELL)
fin_yf += YRES-CELL*2;
if (fin_y >= YRES-CELL)
fin_yf -= YRES-CELL*2;
fin_x = (int)(fin_xf+0.5f);
fin_y = (int)(fin_yf+0.5f);
}
if (mv <= 0.0f)
{
// nothing found
@@ -4260,12 +4298,47 @@ void Simulation::update_particles_i(int start, int inc)
if (t==PT_STKM || t==PT_STKM2 || t==PT_FIGH)
{
int nx, ny;
//head movement, let head pass through anything
parts[i].x += parts[i].vx;
parts[i].y += parts[i].vy;
nx = (int)((float)parts[i].x+0.5f);
ny = (int)((float)parts[i].y+0.5f);
int nx = (int)((float)parts[i].x+0.5f);
int ny = (int)((float)parts[i].y+0.5f);
if (edgeMode == 2)
{
int diffx = 0, diffy = 0;
if (nx < CELL)
diffx = XRES-CELL*2;
if (nx >= XRES-CELL)
diffx = -(XRES-CELL*2);
if (ny < CELL)
diffy = YRES-CELL*2;
if (ny >= YRES-CELL)
diffy = -(YRES-CELL*2);
if (diffx || diffy) //when moving from left to right stickmen might be able to fall through solid things, fix with "eval_move(t, nx+diffx, ny+diffy, NULL)" but then they die instead
{
parts[i].x += diffx;
parts[i].y += diffy;
nx += diffx;
ny += diffy;
//adjust stickmen legs
playerst* stickman = NULL;
int t = parts[i].type;
if (t == PT_STKM)
stickman = &player;
else if (t == PT_STKM2)
stickman = &player2;
else if (t == PT_FIGH && parts[i].tmp >= 0 && parts[i].tmp < 256)
stickman = &fighters[parts[i].tmp];
if (stickman)
for (int i = 0; i < 16; i+=2)
{
stickman->legs[i] += diffx;
stickman->legs[i+1] += diffy;
}
}
}
if (ny!=y || nx!=x)
{
if ((pmap[y][x]>>8)==i) pmap[y][x] = 0;

0 comments on commit 12f00db

Please sign in to comment.