static void RemoveMovingField_MM(int, int);
static void InitMovingField_MM(int, int, int);
static void ContinueMoving_MM(int, int);
-static void Moving2Blocked_MM(int, int, int *, int *);
static void AddLaserEdge(int, int);
static void ScanLaser(void);
Pixel pixel_drawto = (mode == DL_LASER_ENABLED ? pen_ray : pen_bg);
Pixel pixel_buffer = (mode == DL_LASER_ENABLED ? WHITE_PIXEL : BLACK_PIXEL);
- DrawLines(drawto, points, num_points, pixel_drawto);
+ DrawLines(drawto_mm, points, num_points, pixel_drawto);
BEGIN_NO_HEADLESS
{
game_mm.laser_green = native_mm_level.df_laser_green;
game_mm.laser_blue = native_mm_level.df_laser_blue;
}
+
+ game_mm.has_mcduffin = (IS_MCDUFFIN(element));
}
break;
BEGIN_NO_HEADLESS
{
// initialize laser bitmap to current playfield (screen) size
- ReCreateBitmap(&laser_bitmap, drawto->width, drawto->height);
- ClearRectangle(laser_bitmap, 0, 0, drawto->width, drawto->height);
+ ReCreateBitmap(&laser_bitmap, drawto_mm->width, drawto_mm->height);
+ ClearRectangle(laser_bitmap, 0, 0, drawto_mm->width, drawto_mm->height);
}
END_NO_HEADLESS
game_mm.laser_red = FALSE;
game_mm.laser_green = FALSE;
game_mm.laser_blue = TRUE;
+ game_mm.has_mcduffin = TRUE;
game_mm.level_solved = FALSE;
game_mm.game_over = FALSE;
game_mm.game_over_cause = 0;
+ game_mm.game_over_message = NULL;
game_mm.laser_overload_value = 0;
game_mm.laser_enabled = FALSE;
DrawLevel_MM();
- BackToFront();
+ BackToFront_MM();
#ifdef DEBUG
if (setup.quick_doors)
DrawLaser(0, DL_LASER_ENABLED);
- BackToFront();
+ BackToFront_MM();
Delay_WithScreenUpdates(50);
}
static void GameOver_MM(int game_over_cause)
{
- // do not handle game over if request dialog is already active
- if (game.request_active)
- return;
-
game_mm.game_over = TRUE;
game_mm.game_over_cause = game_over_cause;
-
- if (setup.ask_on_game_over)
- game.restart_game_message = (game_over_cause == GAME_OVER_BOMB ?
- "Bomb killed Mc Duffin! Play it again?" :
- game_over_cause == GAME_OVER_NO_ENERGY ?
- "Out of magic energy! Play it again?" :
- game_over_cause == GAME_OVER_OVERLOADED ?
- "Magic spell hit Mc Duffin! Play it again?" :
- NULL);
+ game_mm.game_over_message = (game_mm.has_mcduffin ?
+ (game_over_cause == GAME_OVER_BOMB ?
+ "Bomb killed Mc Duffin!" :
+ game_over_cause == GAME_OVER_NO_ENERGY ?
+ "Out of magic energy!" :
+ game_over_cause == GAME_OVER_OVERLOADED ?
+ "Magic spell hit Mc Duffin!" :
+ NULL) :
+ (game_over_cause == GAME_OVER_BOMB ?
+ "Bomb destroyed laser cannon!" :
+ game_over_cause == GAME_OVER_NO_ENERGY ?
+ "Out of laser energy!" :
+ game_over_cause == GAME_OVER_OVERLOADED ?
+ "Laser beam hit laser cannon!" :
+ NULL));
SetTileCursorActive(FALSE);
}
{
int clx = dSX + lx;
int cly = dSY + ly;
+ int sxsize = MAX(SXSIZE, lev_fieldx * TILEX);
+ int sysize = MAX(SYSIZE, lev_fieldy * TILEY);
- if (clx < -2 || cly < -2 || clx >= SXSIZE + 2 || cly >= SYSIZE + 2)
+ if (clx < -2 || cly < -2 || clx >= sxsize + 2 || cly >= sysize + 2)
{
Warn("AddLaserEdge: out of bounds: %d, %d", lx, ly);
}
#endif
+ // check if laser scan has crossed element boundaries (not just mini tiles)
+ boolean cross_x = (LX / TILEX != (LX + 2) / TILEX);
+ boolean cross_y = (LY / TILEY != (LY + 2) / TILEY);
+
+ if (cross_x && cross_y)
+ {
+ int elx1 = (LX - XS) / TILEX;
+ int ely1 = (LY + YS) / TILEY;
+ int elx2 = (LX + XS) / TILEX;
+ int ely2 = (LY - YS) / TILEY;
+
+ // add element corners left and right from the laser beam to damage list
+
+ if (IN_LEV_FIELD(elx1, ely1) && Tile[elx1][ely1] != EL_EMPTY)
+ AddDamagedField(elx1, ely1);
+
+ if (IN_LEV_FIELD(elx2, ely2) && Tile[elx2][ely2] != EL_EMPTY)
+ AddDamagedField(elx2, ely2);
+ }
+
for (i = 0; i < 4; i++)
{
int px = LX + (i % 2) * 2;
#endif
// hit something -- check out what it was
- ELX = (LX + XS) / TILEX;
- ELY = (LY + YS) / TILEY;
+ ELX = (LX + XS + TILEX) / TILEX - 1; // ...+TILEX...-1 to get correct
+ ELY = (LY + YS + TILEY) / TILEY - 1; // negative values!
#if 0
Debug("game:mm:ScanLaser", "hit_mask (1) == '%x' (%d, %d) (%d, %d)",
hit_mask, LX, LY, ELX, ELY);
#endif
- if (!IN_LEV_FIELD(ELX, ELY) || !IN_PIX_FIELD(LX, LY))
+ if (!IN_LEV_FIELD(ELX, ELY))
{
element = EL_EMPTY;
laser.dest_element = element;
}
else if (IS_GRID_STEEL(element))
{
+ // may be required if graphics for steel grid redefined
+ AddDamagedField(ELX, ELY);
+
return HitReflectingWalls(element, hit_mask);
}
else // IS_GRID_WOOD
{
+ // may be required if graphics for wooden grid redefined
+ AddDamagedField(ELX, ELY);
+
return HitAbsorbingWalls(element, hit_mask);
}
DrawWalls_MM(x, y, Store[x][y]);
// copy wall tile to spare bitmap for "melting" animation
- BlitBitmap(drawto, bitmap_db_field, cSX + x * TILEX, cSY + y * TILEY,
+ BlitBitmap(drawto_mm, bitmap_db_field, cSX + x * TILEX, cSY + y * TILEY,
TILEX, TILEY, x * TILEX, y * TILEY);
DrawElement_MM(x, y, EL_GRAY_BALL);
getGraphicSource(graphic, 0, &bitmap, &gx, &gy);
}
- BlitBitmap(bitmap, drawto, gx + dx, gy + dy, 6, 6,
+ BlitBitmap(bitmap, drawto_mm, gx + dx, gy + dy, 6, 6,
cSX + x * TILEX + dx, cSY + y * TILEY + dy);
laser.redraw = TRUE;
ScanLaser();
- ShowEnvelope_MM(nr);
+ ShowEnvelope(nr);
}
}
}
Bang_MM(laser.start_edge.x, laser.start_edge.y);
- GameOver_MM(GAME_OVER_DELAYED);
-
laser.overloaded = FALSE;
}
- else if (IS_MCDUFFIN(center_element))
+ else if (IS_MCDUFFIN(center_element) || IS_LASER(center_element))
{
GameOver_MM(GAME_OVER_BOMB);
}
int x, y;
} move_xy[] =
{
- { 0, 0 },
- {-1, 0 },
- {+1, 0 },
- { 0, 0 },
- { 0, -1 },
- { 0, 0 }, { 0, 0 }, { 0, 0 },
- { 0, +1 }
+ { 0, 0 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, 0 },
+ { 0, -1 },
+ { 0, 0 }, { 0, 0 }, { 0, 0 },
+ { 0, +1 }
};
static struct
{
int left, right, back;
} turn[] =
{
- { 0, 0, 0 },
+ { 0, 0, 0 },
{ MV_DOWN, MV_UP, MV_RIGHT },
- { MV_UP, MV_DOWN, MV_LEFT },
- { 0, 0, 0 },
- { MV_LEFT, MV_RIGHT, MV_DOWN },
- { 0,0,0 }, { 0,0,0 }, { 0,0,0 },
- { MV_RIGHT, MV_LEFT, MV_UP }
+ { MV_UP, MV_DOWN, MV_LEFT },
+ { 0, 0, 0 },
+ { MV_LEFT, MV_RIGHT, MV_DOWN },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { MV_RIGHT, MV_LEFT, MV_UP }
};
int element = Tile[x][y];
// now make next step
- Moving2Blocked_MM(x, y, &newx, &newy); // get next screen position
+ Moving2Blocked(x, y, &newx, &newy); // get next screen position
if (element == EL_PACMAN &&
IN_LEV_FIELD(newx, newy) && IS_EATABLE4PACMAN(Tile[newx][newy]) &&
}
else if (IS_MCDUFFIN(element))
{
- if (!laser.fuse_off)
- {
- DrawLaser(0, DL_LASER_DISABLED);
+ boolean has_laser = (x == laser.start_edge.x && y == laser.start_edge.y);
- /*
- BackToFront();
- */
- }
+ if (has_laser && !laser.fuse_off)
+ DrawLaser(0, DL_LASER_DISABLED);
element = get_rotated_element(element, BUTTON_ROTATION(button));
- laser.start_angle = get_element_angle(element);
-
- InitLaser();
Tile[x][y] = element;
DrawField_MM(x, y);
- /*
- BackToFront();
- */
+ if (has_laser)
+ {
+ laser.start_angle = get_element_angle(element);
- if (!laser.fuse_off)
- ScanLaser();
+ InitLaser();
+
+ if (!laser.fuse_off)
+ ScanLaser();
+ }
element_clicked = TRUE;
}
IS_GRID_WOOD_AUTO(element) ||
IS_GRID_STEEL_AUTO(element) ||
element == EL_REFRACTOR)
+ {
RotateMirror(x, y, MB_RIGHTBUTTON);
+
+ laser.redraw = TRUE;
+ }
}
}
}
UpdateAndDisplayGameControlValues();
- BackToFront();
+ BackToFront_MM();
}
Tile[ELX][ELY] = laser.dest_element = EL_FUEL_EMPTY;
}
DrawField_MM(nx, ny);
- BackToFront();
+ BackToFront_MM();
if (!laser.fuse_off)
{
Tile[newx][newy] = EL_BLOCKED;
}
-static void Moving2Blocked_MM(int x, int y, int *goes_to_x, int *goes_to_y)
-{
- int direction = MovDir[x][y];
- int newx = x + (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0);
- int newy = y + (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0);
-
- *goes_to_x = newx;
- *goes_to_y = newy;
-}
-
-static void Blocked2Moving_MM(int x, int y,
- int *comes_from_x, int *comes_from_y)
-{
- int oldx = x, oldy = y;
- int direction = MovDir[x][y];
-
- if (direction == MV_LEFT)
- oldx++;
- else if (direction == MV_RIGHT)
- oldx--;
- else if (direction == MV_UP)
- oldy++;
- else if (direction == MV_DOWN)
- oldy--;
-
- *comes_from_x = oldx;
- *comes_from_y = oldy;
-}
-
static int MovingOrBlocked2Element_MM(int x, int y)
{
int element = Tile[x][y];
{
int oldx, oldy;
- Blocked2Moving_MM(x, y, &oldx, &oldy);
+ Blocked2Moving(x, y, &oldx, &oldy);
return Tile[oldx][oldy];
}
if (IS_MOVING(x, y))
{
- Moving2Blocked_MM(x, y, &newx, &newy);
+ Moving2Blocked(x, y, &newx, &newy);
if (Tile[newx][newy] != EL_BLOCKED)
return;
}
else if (Tile[x][y] == EL_BLOCKED)
{
- Blocked2Moving_MM(x, y, &oldx, &oldy);
+ Blocked2Moving(x, y, &oldx, &oldy);
if (!IS_MOVING(oldx, oldy))
return;
}