Ejemplo n.º 1
0
/** Mouse Over Event */
void WorldMapControl::OnMouseOver(unsigned short x, unsigned short y)
{
	WorldMap* worldmap = core->GetWorldMap();
	lastCursor = IE_CURSOR_GRAB;

	if (MouseIsDown) {
		AdjustScrolling(lastMouseX-x, lastMouseY-y);
	}

	lastMouseX = x;
	lastMouseY = y;

	if (Value!=(ieDword) -1) {
		x =(ieWord) (x + ScrollX);
		y =(ieWord) (y + ScrollY);

		WMPAreaEntry *oldArea = Area;
		Area = NULL;

		unsigned int i;
		unsigned int ec = worldmap->GetEntryCount();
		for (i=0;i<ec;i++) {
			WMPAreaEntry *ae = worldmap->GetEntry(i);

			if ( (ae->GetAreaStatus() & WMP_ENTRY_WALKABLE)!=WMP_ENTRY_WALKABLE) {
				continue; //invisible or inaccessible
			}

			Sprite2D *icon=ae->GetMapIcon(worldmap->bam);
			int h=0, w=0, iconx=0, icony=0;
			if (icon) {
				h=icon->Height;
				w=icon->Width;
				iconx = icon->XPos;
				icony = icon->YPos;
				core->GetVideoDriver()->FreeSprite( icon );
			}
			if (ftext && ae->GetCaption()) {
				int tw = ftext->CalcStringWidth( (unsigned char*)ae->GetCaption() ) + 5;
				int th = ftext->maxHeight;
				if(h<th)
					h=th;
				if(w<tw)
					w=tw;
			}
			if (ae->X - iconx > x) continue;
			if (ae->X - iconx + w < x) continue;
			if (ae->Y - icony > y) continue;
			if (ae->Y - icony + h < y) continue;
			lastCursor = IE_CURSOR_NORMAL;
			Area=ae;
			if(oldArea!=ae) {
				RunEventHandler(WorldMapControlOnEnter);
			}
			break;
		}
	}

	Owner->Cursor = lastCursor;
}
Ejemplo n.º 2
0
void WorldMapControl::AdjustScrolling(short x, short y)
{
	WorldMap* worldmap = core->GetWorldMap();
	if (x || y) {
		ScrollX += x;
		ScrollY += y;
	} else {
		//center worldmap on current area
		unsigned entry;

		WMPAreaEntry *m = worldmap->GetArea(currentArea,entry);
		if (m) {
			ScrollX = m->X - Width/2;
			ScrollY = m->Y - Height/2;
		}
	}
	Sprite2D *MapMOS = worldmap->GetMapMOS();
	if (ScrollX > MapMOS->Width - Width)
		ScrollX = MapMOS->Width - Width;
	if (ScrollY > MapMOS->Height - Height)
		ScrollY = MapMOS->Height - Height;
	if (ScrollX < 0)
		ScrollX = 0;
	if (ScrollY < 0)
		ScrollY = 0;
	Changed = true;
	Area = NULL;
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    WorldMap worldmap;
    for(int i = 0; i < DIMENSION; ++i)
    {
        WorldRow row;
        for(int j = 0; j < DIMENSION; ++j)
            row.append(WHITE);
        worldmap.append(row);
    }

    qDebug() << "antling worker";


    Ant antling(EAST, QPoint(DIMENSION/2, DIMENSION/2), worldmap);


    //viewWorldmap(antling.worldMap());
    for(int i = 0; i < 25000; ++i)
    {
        antling.move();
    }
qDebug() << "====================================";
   // viewWorldmap(antling.worldMap());

    ImageGenerator gen(antling.worldMap(), DIMENSION);

    gen.renderImageAndSave("/home/ipek/Downloads/");

    return 0;
}
    static void offsetToPointXY(size_t offset, size_t* point_x, size_t *point_y )
    {
        *point_y = ( offset  /  main_map.getWidth() );

        *point_x = ( offset - ( (*point_y) * main_map.getWidth() ) ) * TILE_WIDTH
                   + (TILE_WIDTH / 2);

        *point_y = (*point_y) * TILE_HEIGHT + (TILE_HEIGHT / 2);
    }
    static void offsetToPointXY( unsigned long offset,
                                 unsigned long *point_x, unsigned long *point_y )
    {
        *point_y = ( offset  /  main_map.getXsize() );

        *point_x = ( offset - ( (*point_y) * main_map.getXsize() ) ) * 32
                   + (32 / 2);

        *point_y = (*point_y) * 32 + (32 / 2);
    }
Ejemplo n.º 6
0
WorldMapControl::WorldMapControl(const char *font, int direction)
{
	ScrollX = 0;
	ScrollY = 0;
	MouseIsDown = false;
	Changed = true;
	Area = NULL;
	Value = direction;
	Game* game = core->GetGame();
	WorldMap* worldmap = core->GetWorldMap();
	CopyResRef(currentArea, game->CurrentArea);
	int entry = core->GetAreaAlias(currentArea);
	if (entry >= 0) {
		WMPAreaEntry *m = worldmap->GetEntry(entry);
		CopyResRef(currentArea, m->AreaResRef);
	}

	//if there is no trivial area, look harder
	if (!worldmap->GetArea(currentArea, (unsigned int &) entry) && 
		core->HasFeature(GF_FLEXIBLE_WMAP) ) {
		WMPAreaEntry *m = worldmap->FindNearestEntry(currentArea, (unsigned int &) entry);
		if (m) {
			CopyResRef(currentArea, m->AreaResRef);
		}
	}

	//this also updates visible locations
	worldmap->CalculateDistances(currentArea, Value);
	
	// alpha bit is unfortunately ignored
	if (font[0]) {
		ftext = core->GetFont(font);
	} else {
		ftext = NULL;
	}

	// initialize label colors
	// NOTE: it would be better to initialize these colors from
	//   some 2da file
	Color normal = { 0xf0, 0xf0, 0xf0, 0xff };
	Color selected = { 0xf0, 0x80, 0x80, 0xff };
	Color notvisited = { 0x80, 0x80, 0xf0, 0xff };
	Color black = { 0x00, 0x00, 0x00, 0x00 };

	pal_normal = core->CreatePalette ( normal, black );
	pal_selected = core->CreatePalette ( selected, black );
	pal_notvisited = core->CreatePalette ( notvisited, black );


	ResetEventHandler( WorldMapControlOnPress );
	ResetEventHandler( WorldMapControlOnEnter );
}
Ejemplo n.º 7
0
int WMPImporter::GetStoredFileSize(WorldMapArray *wmap, unsigned int index)
{
	assert(!index || !wmap->IsSingle());

	int headersize = 16;
	int WorldMapsOffset;

	WorldMapsCount = wmap->GetMapCount();
	if (index>WorldMapsCount || index>1) return 0;

	WorldMapsOffset = headersize;
	if (index) {
		WorldMapsCount2 = 0;
	} else {
		WorldMapsCount1 = 0;
	}

	for (unsigned int i=index;i<WorldMapsCount; i++) {
		if (index) {
			WorldMapsCount2++;
		} else {
			WorldMapsCount1++;
		}

		headersize += 184;
		WorldMap *map = wmap->GetWorldMap(i);

		//Update the links and entries counts now, in case the worldmap has changed
		map->AreaEntriesCount = map->GetEntryCount();
		headersize += map->AreaEntriesCount * 240;

		map->AreaLinksCount = map->GetLinkCount();
		headersize += map->AreaLinksCount * 216;

		//put the first array into the first map
		//the rest into the second map if not single
		if (!wmap->IsSingle() && !index) {
			break;
		}
	}

	if (index) {
		WorldMapsOffset2 = WorldMapsOffset;
	}
	else {
		WorldMapsOffset1 = WorldMapsOffset;
	}
	return headersize;
}
Ejemplo n.º 8
0
void FeatureGenerator::drillSpiral(
  v3d_t top,
  double radius,
  double height,
  double totalRotation,
  int numSteps,
  WorldMap &worldMap)
{
  v3d_t pos;

  double bottom = top.y - height;
  double percent;
  double angle;

  for (int step = 0; step < numSteps; step++) {
    percent = static_cast<double> (step) / static_cast<double>(numSteps - 1);
    angle = percent * totalRotation;

    pos.x = top.x + radius * cos(angle);
    pos.y = lerp(bottom, top.y, percent);
    pos.z = top.z + radius * sin(angle);

    worldMap.clearSphere(pos, 3.0);
  }
}
 static inline void offsetToMapXY( unsigned long offset, iXY *map_loc )
 {
     unsigned short map_x, map_y;
     main_map.offsetToMapXY( offset, &map_x, &map_y );
     map_loc->x = map_x;
     map_loc->y = map_y;
 }
Ejemplo n.º 10
0
void MapSpatialComponent::OnRemove()
{
	Context()->chitBag->RemoveFromBuildingHash(this, bounds.min.x, bounds.min.y);
	
	WorldMap* worldMap = Context()->worldMap;
	LumosChitBag* chitBag = Context()->chitBag;

	super::OnRemove();

	// Since we are removed from the HashTable, this
	// won't be found by UpdateGridLayer()
	Rectangle2I b = bounds;
	b.Outset(1);
	worldMap->UpdateBlock(bounds);
	UpdateGridLayer(worldMap, chitBag, b);
}
Ejemplo n.º 11
0
/** Mouse wheel scroll */
void WorldMapControl::OnMouseWheelScroll(short x, short y)
{
	ScrollX += x;
	ScrollY += y;
	
	WorldMap* worldmap = core->GetWorldMap();
	Sprite2D *MapMOS = worldmap->GetMapMOS();
	if (ScrollX > MapMOS->Width - Width)
		ScrollX = MapMOS->Width - Width;
	if (ScrollY > MapMOS->Height - Height)
		ScrollY = MapMOS->Height - Height;
	if (ScrollX < 0)
		ScrollX = 0;
	if (ScrollY < 0)
		ScrollY = 0;
}
Ejemplo n.º 12
0
void
GameView::drawMap(Surface &window)
{
    TileSet * ts = TileInterface::getTileSet();
    unsigned long world_x;
    unsigned long world_y;
    unsigned short map_x;
    unsigned short map_y;
    
    WorldViewInterface::getMainCamera()->getViewStart(window.getWidth(), window.getHeight(),
                              &world_x, &world_y);
    MapInterface::pointXYtoMapXY( world_x, world_y, &map_x, &map_y );
        
    unsigned short tile_size = ts->getTileXsize();
    
    long partial_y = world_y % tile_size;
    int y = 0;
    if ( partial_y )
    {
        y -= partial_y;
    }
    
    long partial_x = world_x % tile_size;
    int start_x = 0;
    if ( partial_x )
    {
        start_x -= partial_x;
    }
    
    unsigned int tile = 0;
    
    WorldMap * map = MapInterface::getMap();
    
    unsigned short tmx;
    
    for ( ; y < (int)window.getHeight(); y += tile_size )
    {
        tmx = map_x;
        for ( int x = start_x; x < (int)window.getWidth(); x += tile_size )
        {
            tile = map->getValue(tmx++, map_y);
            blitTile(window, tile, x, y);
        }
        map_y ++;
    }
}
Ejemplo n.º 13
0
 static inline void unmarkLocHack( const iXY &loc )
 {
     unsigned short *map_buffer;
     unsigned long offset;
     main_map.getRawMapBuffer( &map_buffer );
     offset = ( loc.y * getMapXsize() ) + loc.x;
     map_buffer[ offset ] = 28;
 }
Ejemplo n.º 14
0
void IMSystemManager::Init(const IMSysManagerParam& p_params)
{
    int worldWidth;
    int worldHeight;
    WorldMap *pMap = nullptr;
    int cellSize;

    if (m_initialized)
    {
        LogError("IMSystemManager already initialized, will do nothing ...");
        return;
    }

    m_params = p_params;

    pMap = g_Game->Map();
    worldWidth = pMap->Size().X;
    worldHeight = pMap->Size().Y;
    
    cellSize = p_params.BuildingDataIMCellSize;
    cellSize = min(cellSize, worldWidth);
    while (worldWidth % cellSize != 0)
        ++cellSize;

    OccupanceDataIM *pBuildingDataIM = new OccupanceDataIM(IM_BuildingData);
    assert(pBuildingDataIM);
    pBuildingDataIM->Init(cellSize, cellSize, worldWidth, worldHeight);
    RegisterIM(pBuildingDataIM, IM_BuildingData);

    cellSize = p_params.GroundControlIMCellSize;
    cellSize = min(cellSize, worldWidth);
    while (worldWidth % cellSize != 0)
        ++cellSize;

    GroundControlIM *pGroundControlIM = new GroundControlIM(IM_GroundControl);
    assert(pGroundControlIM);
    pGroundControlIM->Init(cellSize, cellSize, worldWidth, worldHeight);
    RegisterIM(pGroundControlIM, IM_GroundControl);

    m_initialized = true;
}
Ejemplo n.º 15
0
WorldMap* MapReader::readMap(std::string filename) {
	std::ifstream infile(filename.c_str());
	int cellWidth = 0;
	int cellHeight = 0;
	int nextTileVal = 0;
	std::stringstream lineStream;

	infile >> cellWidth >> cellHeight;
	WorldMap* map = new WorldMap(cellWidth, cellHeight, Terrain::getSize());

	std::cout << "Loading map [" << filename << "]   (" << cellWidth << ", " << cellHeight << ")" << std::endl;

	// Loop through each row of the map
	for (int height = 0; height < cellHeight; ++height) {
		// Loop through each column of the map
		for (int width = 0; width < cellWidth; ++width) {
			infile >> nextTileVal;

			// Special case -- victory condition
			if (nextTileVal == 2) {
				Manager::getInstance()->getTarget()->setLocation(width * Terrain::getSize(), height * Terrain::getSize());
			}
			// All other cases.
			else {
				Terrain * nextTileType = getTileType(nextTileVal);
				if (nextTileType != NULL) {
					map->setCell(width, height, nextTileType);
				}
			}
		}
		lineStream.str("");
	}

	/*
	for (int width = 0; width < cellWidth; ++width) {
		map->setCell(width, cellHeight - 1, getTileType(1));
	}
	*/

	return map;
}
Ejemplo n.º 16
0
WorldMap* WorldMap::createDefaultMap()
{
   WorldMap* m = new WorldMap(12l, 12);

   for(int x=0; x<12; x++)
   {   
      for(int y=0; y<12; y++)
      {
         if (x ==0 || y == 0 || x == 11 || y == 11)
            m->setElement(x, y, TERRAIN_OCEAN);
         else
            m->setElement(x, y, TERRAIN_GRASS);

         m->setStructure(x, y, STRUCTURE_NONE);
      }
   }

   m->setElement(5, 5, TERRAIN_ROCK);

   return m;
}
Ejemplo n.º 17
0
void viewWorldmap(WorldMap map)
{

    for(int i = 0; i < map.size(); ++ i)
    {
        QString row;
        for(int j = 0; j < map[i].size(); ++ j)
            row.append(QString::number(map[i][j]));
        qDebug() << row;
    }

}
int Gui::handle_player_action(const Point2D &at_position, WorldMap &worldmap)
{
    Rect2D actionButton;
    
    actionButton.pos.x = 387.0f;
    actionButton.pos.y = 228.0f;
    actionButton.width = 61.0f;
    actionButton.height = 61.0f;
    
    Point2D tempPoint = at_position;
    
    if (isPointInRect(&tempPoint, &actionButton))
    {
        int i;
        for (i = 0; i < worldmap.getNPCcounter(); i++)
        {
            if (worldmap.getNPC(i).getIfInPlayerFocus())
            {
                //printf("Player interaction with %s\n", worldmap.getNPC(i).getName());
                this->interactedNPC = &worldmap.getNPC(i);
                return ACTION_NPC;
            }
        }
        for (i = 0; i < worldmap.getObjectCounter(); i++)
        {
            if (worldmap.getObject(i).getIfInPlayerFocus()) {            
                //printf("Player interaction with %s\n", worldmap.getObject(i).getName());
                this->interactedObject = &worldmap.getObject(i);
                return ACTION_OBJECT;
            }
        }
    }
    
    return NO_ACTION;
}
Ejemplo n.º 19
0
void NewClientView::readFields(int length, WorldMap &maps) {
    position pos = viewPosition;
    int x_inc = (stripedir == dir_right) ? 1 : -1;
    int tmp_maxtiles = 1;

    for (int i = 0; i < length; ++i) {
        try {
            Field &field = maps.at(pos);

            if (!field.isTransparent() || field.itemCount() > 0) {
                exists = true;
                mapStripe[i] = &field;
                maxtiles = tmp_maxtiles;
            }
        } catch (FieldNotFound &) {
        }

        ++tmp_maxtiles;
        //increase x due to perspective
        pos.x += x_inc;
        //increase y due to perspective
        ++pos.y;
    }
}
Ejemplo n.º 20
0
void PlantScript::DoTick(U32 delta)
{
	// We need process at a steady rate so that
	// the time between ticks is constant.
	// This is performance regressive, so something
	// to keep an eye on.
	static const int MAP2 = MAX_MAP_SIZE*MAX_MAP_SIZE;
	static const int DELTA = 100*1000;	// How frequenty to tick a given plant
	static const int N_PER_MSEC = MAP2 / DELTA;
	static const int GROWTH_CHANCE = 8;
	static const int PRIME = 1553;

	static const float SHADE_EFFECT = 0.7f;

	int n = N_PER_MSEC * delta;
	Weather* weather = Weather::Instance();

	WorldMap* worldMap = context->worldMap;
	Rectangle2I bounds = worldMap->Bounds();
	bounds.Outset(-1);	// edge of map: don't want to tap over the edge.

	const Vector3F& light = context->engine->lighting.direction;
	const float		norm = Max(fabs(light.x), fabs(light.z));
	Vector2I		lightTap = { int(LRintf(light.x / norm)), int(LRintf(light.z / norm)) };
	Census*			census = &context->chitBag->census;

	for (int i = 0; i < n; ++i) {
		index += PRIME;

		int x = IndexToMapX(index);
		int y = IndexToMapY(index);

		const WorldGrid& wg = worldMap->GetWorldGrid(x, y);
		if (!wg.Plant()) continue;

		Vector2I pos2i = { x, y };
		Vector2F pos2f = ToWorld2F(pos2i);

		// --- Light Tap --- //
		const float	height = PlantScript::PlantRes(wg.Plant() - 1, wg.PlantStage())->AABB().SizeY();
		const float	rainBase		= weather->RainFraction(pos2f.x, pos2f.y);
		const float sunBase			= (1.0f - rainBase);
		const float temperatureBase	= weather->Temperature(pos2f.x, pos2f.y);

		float rain			= rainBase;
		float sun			= sunBase;
		float temperature	= temperatureBase;
		float growth		= 1.0f;

		Vector2I tap = pos2i + lightTap;

		// Check for something between us and the light.
		const WorldGrid& wgTap = worldMap->GetWorldGrid(tap);
		float tapHeight = float(wgTap.RockHeight());
		if (wgTap.PlantStage()) {
			tapHeight = PlantScript::PlantRes(wgTap.Plant() - 1, wgTap.PlantStage())->AABB().SizeY();
		}

		if (tapHeight > (height + 0.1f)) {
			// in shade
			sun *= SHADE_EFFECT;
			temperature *= SHADE_EFFECT;
		}

		// ---- Adjacent --- //
		static const int NADJ = 4;
		static const Vector2I check[NADJ] = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };
		int same = 0;
		for (int i = 0; i<NADJ; ++i) {
			tap = pos2i + check[i];
			const WorldGrid& wgAdj = worldMap->GetWorldGrid(tap.x, tap.y);
			if (wgAdj.Plant() == wg.Plant()) {
				++same;
			}

			if (wgAdj.RockHeight()) {
				// Water or rock runoff increase water.
				rain += 0.25f * rainBase;
			}
			if (wgAdj.IsFluid()) {
				rain += 0.25f;	// just a lot of water.
			}
			if (wgAdj.IsWater()) {
				rain += 0.25f;	// more water
				temperature = Mean(0.5f, temperature); // moderate temperature
			}
		}
		// Nutrient depletion? Too packed in?
		if (same == NADJ) {
			growth *= 0.25f;
		}

		// Are we under water?
		float fluidHeight = wg.FluidHeight();
		if (fluidHeight > 0.01f) {
			// Any amount of water goes to rain 100%
			rain = 1.0f;
			// not sure what to do with temp...assume a little cooler?
			temperature *= 0.8f;

			// blocks light...
			float sizeY = PlantScript::PlantRes(wg.Plant() - 1, wg.PlantStage())->AABB().SizeY();
			if (fluidHeight > sizeY)
				sun = 0;
			else if (fluidHeight > sizeY * 0.5f)
				sun = sun * (1.0f - fluidHeight / sizeY);
		}

		rain = Clamp(rain, 0.0f, 1.0f);
		temperature = Clamp(temperature, 0.0f, 1.0f);
		sun = Clamp(sun, 0.0f, 1.0f);

		// ------- calc ------- //
		Vector3F actual = { sun, rain, temperature };
		Vector3F optimal = { 0.5f, 0.5f, 0.5f };

		const GameItem* item = PlantScript::PlantDef(wg.Plant() - 1);
		item->keyValues.Get(ISC::sun, &optimal.x);
		item->keyValues.Get(ISC::rain, &optimal.y);
		item->keyValues.Get(ISC::temp, &optimal.z);

		float distance = (optimal - actual).Length();
		distance = distance / growth;

		const float GROW = Lerp(0.2f, 0.1f, (float)wg.PlantStage() / (float)(MAX_PLANT_STAGES - 1));
		const float DIE = 0.4f;
		float seconds = float(DELTA) / 1000.0f;

		if (distance < GROW) {
			// Heal.
			float hp = HP_PER_SECOND*seconds;
			DamageDesc heal( -hp, 0 );
			worldMap->VoxelHit(pos2i, heal);

			// Grow
			int nStage = wg.IsFlower() ? PLANT_BLOCKING_STAGE : MAX_PLANT_STAGES;

			if (wg.HPFraction() > 0.8f) {
				if (wg.PlantStage() < (nStage - 1)) {
					int hp = wg.HP();
					worldMap->SetPlant(pos2i.x, pos2i.y, wg.Plant(), wg.PlantStage() + 1);
					worldMap->SetWorldGridHP(pos2i.x, pos2i.y, hp);
				}
				if (random.Rand(GROWTH_CHANCE) < wg.PlantStage()) {
					// Number range reflects wind direction.
					int dx = -1 + random.Rand(4);	// [-1,2]
					int dy = -1 + random.Rand(3);	// [-1,1]

					// Remember that create plant will favor creating
					// existing plants, so we don't need to specify
					// what to create.
					Sim* sim = context->chitBag->GetSim();
					GLASSERT(sim);
					sim->CreatePlant(pos2i.x + dx, pos2i.y + dy, -1);
				}
			}
			int stage = wg.PlantStage();	// 0-3
			CoreScript* cs = CoreScript::GetCore(ToSector(pos2i));
			// Totally "what feels right in world gen" constant in the random.Rand()
			if ((census->wildFruit < MAX_WILD_FRUIT) && cs && (!cs->InUse()) && int(random.Rand(200)) < (stage*stage)) {
				context->chitBag->NewWildFruit(pos2i);
			}
		}
		else if (distance > DIE) {
			DamageDesc dd(HP_PER_SECOND * seconds, 0);
			worldMap->VoxelHit(pos2i, dd);
			if (wg.HP() == 0) {
				worldMap->SetPlant(pos2i.x, pos2i.y, 0, 0);
			}
		}
	}
}
Ejemplo n.º 21
0
 static WorldMap::MapElementType MapValue(size_t offset)
 {
     return main_map.getValue(offset);
 }
Ejemplo n.º 22
0
 static size_t getHeight()
 {
     return main_map.getHeight();
 }
Ejemplo n.º 23
0
 static WorldMap::MapElementType MapValue(size_t x, size_t y)
 {
     return main_map.getValue(x, y);
 }
Ejemplo n.º 24
0
 static iXY getSize()
 {
     return iXY(main_map.getWidth(), main_map.getHeight());
 }
Ejemplo n.º 25
0
 static size_t getWidth()
 {
     return main_map.getWidth();
 }
Ejemplo n.º 26
0
 static void getMapPointSize(iXY *map_size)
 {
     map_size->x = main_map.getWidth() * tile_set.getTileXsize();
     map_size->y = main_map.getHeight() * tile_set.getTileYsize();
 }
Ejemplo n.º 27
0
 static bool isMapLoaded()
 {
     return( main_map.isMapLoaded() );
 }
Ejemplo n.º 28
0
 static void unmarkLocHack(const iXY& loc)
 {
     main_map.setMapValue(loc.x, loc.y, 28);
 }
Ejemplo n.º 29
0
 static size_t mapXYtoOffset(const iXY& map_loc)
 {
     return map_loc.y * main_map.getWidth() + map_loc.x;
 }
Ejemplo n.º 30
0
 static void offsetToMapXY(size_t offset, size_t& x, size_t& y)
 {
     y = offset / main_map.getWidth();
     x = offset - y * main_map.getWidth();
 }