Example #1
0
float MapMode::GetScreenXCoordinate(float tile_position_x) const
{
    tile_position_x = (tile_position_x - _map_frame.screen_edges.left)
        * VIDEO_STANDARD_RES_WIDTH / SCREEN_GRID_X_LENGTH;
    tile_position_x = FloorToFloatMultiple(tile_position_x, GetMapPixelXLength());
    return tile_position_x;
}
Example #2
0
float MapMode::GetScreenYCoordinate(float tile_position_y) const
{
    tile_position_y = (tile_position_y - _map_frame.screen_edges.top)
        * VIDEO_STANDARD_RES_HEIGHT / SCREEN_GRID_Y_LENGTH;
    tile_position_y = FloorToFloatMultiple(tile_position_y, GetMapPixelYLength());

    return tile_position_y;
}
Example #3
0
bool MapZone::_ShouldDraw(const ZoneSection& section) {
	MapMode *map = MapMode::CurrentInstance();
	// If the context is not in one of the active context, don't display it.
	if (!(_active_contexts & map->GetCurrentContext()))
		return false;

	MapRectangle rect;
	rect.top = section.top_row;
	rect.bottom = section.bottom_row;
	rect.left = section.left_col;
	rect.right = section.right_col;

	// Determine if the sprite is off-screen and if so, don't draw it.
	if (!MapRectangle::CheckIntersection(rect, map->GetMapFrame().screen_edges))
		return false;

	// Determine the center position coordinates for the camera
	float x_pos, y_pos; // Holds the final X, Y coordinates of the camera
	float x_pixel_length, y_pixel_length; // The X and Y length values that coorespond to a single pixel in the current coodinate system
	float rounded_x_offset, rounded_y_offset; // The X and Y position offsets of the object, rounded to perfectly align on a pixel boundary


	// TODO: the call to GetPixelSize() will return the same result every time so long as the coordinate system did not change. If we never
	// change the coordinate system in map mode, then this should be done only once and the calculated values should be saved for re-use.
	// However, we've discussed the possiblity of adding a zoom feature to maps, in which case we need to continually re-calculate the pixel size
	x_pos = rect.left + (rect.right - rect.left) / 2;
	y_pos = rect.top + (rect.bottom - rect.top);
	hoa_video::VideoManager->GetPixelSize(x_pixel_length, y_pixel_length);
	rounded_x_offset = FloorToFloatMultiple(GetFloatFraction(x_pos), x_pixel_length);
	rounded_y_offset = FloorToFloatMultiple(GetFloatFraction(y_pos), y_pixel_length);
	x_pos = static_cast<float>(GetFloatInteger(x_pos)) + rounded_x_offset;
	y_pos = static_cast<float>(GetFloatInteger(y_pos)) + rounded_y_offset;

	// Move the drawing cursor to the appropriate coordinates for this sprite
	hoa_video::VideoManager->Move(x_pos - map->GetMapFrame().screen_edges.left,
							y_pos - map->GetMapFrame().screen_edges.top);
	return true;
}