void CApp::OnMouseMove(int mX, int mY, int relX, int relY, bool Left,bool Right,bool Middle)
{
    if (Left)
    {
        if(!(mX < TileWindow.Width && mY < TileWindow.Height))
        {
            if(InBounds(mX, mY))
            {
                GetTile( mX, mY);
                Map->SetTile(tile, newTileID, newTypeID);
            }
        }
    }
    if (Right)
    {
        if(!(mX < TileWindow.Width && mY < TileWindow.Height))
        {
            if(InBounds(mX, mY))
            {
                if( ((mX - CCamera::CameraControl.GetX()) < MAP_WIDTH*TILE_SIZE*CArea::AreaControl.areaWidth) &&
                        ((mY - CCamera::CameraControl.GetY()) < MAP_HEIGHT*TILE_SIZE*CArea::AreaControl.areaHeight) &&
                        ((mYold - CCamera::CameraControl.GetY()) < MAP_HEIGHT*TILE_SIZE*CArea::AreaControl.areaHeight) &&
                        ((mXold - CCamera::CameraControl.GetX()) < MAP_WIDTH*TILE_SIZE*CArea::AreaControl.areaWidth))
                {
                    // draws tiles but doesn't erase when you go too far
                    GetTile( mX, mYold);
                    Map->SetTile(tile, newTileID, newTypeID);
                    GetTile(mXold, mY);
                    Map->SetTile(tile, newTileID, newTypeID);
                }
            }
        }
    }
}
    void PathNode::DebugDraw(Label* aLabel, Rect* aRect)
    {
#if DEBUG
        //Draw the rect, the color represent which list the path node is in
        aRect->SetLocalPosition(GetTile()->GetCenter(false));
        aRect->SetSize(GetTile()->GetSize(), GetTile()->GetSize());
        aRect->Draw();

        //Draw the F score
        stringstream ss;
        ss << GetScoreF();
        aLabel->SetText(ss.str());
        aLabel->SetAnchorPoint(0.0f, 1.0f);
        aLabel->SetLocalPosition(vec2(GetTile()->GetLocalX(), GetTile()->GetLocalY() + GetTile()->GetSize()));
        aLabel->Draw();
        
        //Draw the S score
        ss.str("");
        ss << GetScoreG();
        aLabel->SetText(ss.str());
        aLabel->SetAnchorPoint(0.0f, 0.0f);
        aLabel->SetLocalPosition(vec2(GetTile()->GetLocalX(), GetTile()->GetLocalY()));
        aLabel->Draw();
        
        //Draw the H score
        ss.str("");
        ss << GetScoreH();
        aLabel->SetText(ss.str());
        aLabel->SetAnchorPoint(1.0f, 0.0f);
        aLabel->SetLocalPosition(vec2(GetTile()->GetLocalX() + GetTile()->GetSize(), GetTile()->GetLocalY()));
        aLabel->Draw();
#endif
    }
Beispiel #3
0
int CCollision::IntersectAir(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision)
{
	float d = distance(Pos0, Pos1);
	vec2 Last = Pos0;

	for(float f = 0; f < d; f++)
	{
		float a = f/d;
		vec2 Pos = mix(Pos0, Pos1, a);
		if(IsSolid(round_to_int(Pos.x), round_to_int(Pos.y)) || (!GetTile(round_to_int(Pos.x), round_to_int(Pos.y)) && !GetFTile(round_to_int(Pos.x), round_to_int(Pos.y))))
		{
			if(pOutCollision)
				*pOutCollision = Pos;
			if(pOutBeforeCollision)
				*pOutBeforeCollision = Last;
			if(!GetTile(round_to_int(Pos.x), round_to_int(Pos.y)) && !GetFTile(round_to_int(Pos.x), round_to_int(Pos.y)))
				return -1;
			else
				if (!GetTile(round_to_int(Pos.x), round_to_int(Pos.y))) return GetTile(round_to_int(Pos.x), round_to_int(Pos.y));
				else return GetFTile(round_to_int(Pos.x), round_to_int(Pos.y));
		}
		Last = Pos;
	}
	if(pOutCollision)
		*pOutCollision = Pos1;
	if(pOutBeforeCollision)
		*pOutBeforeCollision = Pos1;
	return 0;
}
Beispiel #4
0
/*	Generate a tile type for the specific tile based on surrounding tiles height. */
TerrainTest::tiletype TerrainTest::GetTileType(int x, int y)
{
	tile* t = GetTile(x, y);
	if (!t) return TILE_INVALID;

	//Get height values of surrounding tiles
	int n = -1, s = -1, e = -1, w = -1, se = -1, sw = -1, ne = -1, nw = -1;
	int c = t->height;
	
	tile* t2;
	t2 = GetTile(x, y-1); if (t2) n = t2->height;
	t2 = GetTile(x, y+1); if (t2) s = t2->height;
	t2 = GetTile(x-1, y); if (t2) w = t2->height;
	t2 = GetTile(x+1, y); if (t2) e = t2->height;
	t2 = GetTile(x-1, y-1); if (t2) nw = t2->height;
	t2 = GetTile(x+1, y-1); if (t2) ne = t2->height;
	t2 = GetTile(x-1, y+1); if (t2) sw = t2->height;
	t2 = GetTile(x+1, y+1); if (t2) se = t2->height;
	
	//Use surrounding heights to determine our own type
	if (e == c && w == c && n >= c && s < c && s != -1)
		return TILE_SOUTHEDGE;
	
	if (w >= c && e < c && e != -1 && n == c && s == c)
		return TILE_EASTEDGE;
		
	if (e >= c && w < c && w != -1 && n == c && s == c)
		return TILE_WESTEDGE;
	
	if (e == c && w == c && s >= c && n < c && n != -1)
		return TILE_NORTHEDGE;

	if (e < c && n < c && e != -1 && n != -1 && s >= c && w >= c)
		return TILE_NEEDGE;
	
	if (w < c && n < c && w != -1 && n != -1 && s >= c && e >= c)
		return TILE_NWEDGE;
	
	if (e < c && s < c && e != -1 && s != -1 && n >= c && w >= c)
		return TILE_SEEDGE;
	
	if (w < c && s < c && w != -1 && s != -1 && n >= c && e >= c)
		return TILE_SWEDGE;
	
	//Fix diagonals
	if (n == c && e == c && ne < c && ne != -1)
		return TILE_SWBEND;
		
	if (n == c && w == c && nw < c && nw != -1)
		return TILE_SEBEND;
	
	if (s == c && e == c && se < c && se != -1)
		return TILE_NWBEND;
		
	if (s == c && w == c && sw < c && sw != -1)
		return TILE_NEBEND;

	return TILE_INVALID;
}
Beispiel #5
0
int checkMapCollision(int x, int y, int testX, int testY){
	testY -= 1;
	if(GetTile(30,((x+testX)/8), ((y+testY)/8)) == 0){
		return 1;
	}
	if(GetTile(30, ((x+testX)/8), ((y+testY)/8)) >= 21 
	&& GetTile(30, ((x+testX)/8), ((y+testY)/8)) <= 25){
		return 1;
	}
	if(GetTile(30, ((x+testX)/8), ((y+testY)/8)) >= 16 
	&& GetTile(30, ((x+testX)/8), ((y+testY)/8)) <= 20){
		return 2;
	}
	return 0;
}
Beispiel #6
0
void Map::ShipOccupy(int x, int y, Direction dir, Ship* ship)
{
	int deltaX = 0;
	int deltaY = 0;
	switch (dir)
	{
	case DIR_UP:
		deltaY = 1;
		break;
	case DIR_DOWN:
		deltaY = -1;
		break;
	case DIR_LEFT:
		deltaX = -1;
		break;
	case DIR_RIGHT:
		deltaX = 1;
		break;
	}

	for (int i = 0; i < ship->GetSize(); ++i)
	{
		Tile* tile = GetTile(x, y);
		_ASSERT(tile != nullptr);
		tile->SetOccupiedShip(ship);
		x += deltaX;
		y += deltaY;
	}
}
Beispiel #7
0
// Create a whole 'frame' from VP8 (+ alpha) or lossless.
static int SynthesizeFrame(const WebPDemuxer* const dmux,
                           const Frame* const first_frame,
                           int tile_num, WebPIterator* const iter) {
  const uint8_t* const mem_buf = dmux->mem_.buf_;
  int num_tiles;
  size_t payload_size = 0;
  const Frame* const tile = GetTile(first_frame, tile_num, &num_tiles);
  const uint8_t* const payload = GetFramePayload(mem_buf, tile, &payload_size);
  if (payload == NULL) return 0;

  iter->frame_num_   = first_frame->frame_num_;
  iter->num_frames_  = dmux->num_frames_;
  iter->tile_num_    = tile_num;
  iter->num_tiles_   = num_tiles;
  iter->x_offset_    = tile->x_offset_;
  iter->y_offset_    = tile->y_offset_;
  iter->width_       = tile->width_;
  iter->height_      = tile->height_;
  iter->duration_    = tile->duration_;
  iter->complete_    = tile->complete_;
  iter->tile_.bytes_ = payload;
  iter->tile_.size_  = payload_size;
  // TODO(jzern): adjust offsets for 'TILE's embedded in 'FRM 's
  return 1;
}
Beispiel #8
0
void TERRAIN::CalculateAlphaMaps()
{
	Progress("Creating Alpha Map", 0.0f);

	//Clear old alpha maps
	if(m_pAlphaMap != NULL)
		m_pAlphaMap->Release();

	//Create new alpha map
	D3DXCreateTexture(m_pDevice, 128, 128, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pAlphaMap);

	//Lock the texture
	D3DLOCKED_RECT sRect;
	m_pAlphaMap->LockRect(0, &sRect, NULL, NULL);
	BYTE *bytes = (BYTE*)sRect.pBits;
	memset(bytes, 0, 128*sRect.Pitch);		//Clear texture to black

	for(int i=0;i<(int)m_diffuseMaps.size();i++)
		for(int y=0;y<sRect.Pitch / 4;y++)
			for(int x=0;x<sRect.Pitch / 4;x++)
			{
				int terrain_x = (int)(m_size.x * (x / (float)(sRect.Pitch / 4.0f)));
				int terrain_y = (int)(m_size.y * (y / (float)(sRect.Pitch / 4.0f)));
				MAPTILE *tile = GetTile(terrain_x, terrain_y);

				if(tile != NULL && tile->m_type == i)
					bytes[y * sRect.Pitch + x * 4 + i] = 255;
			}

	//Unlock the texture
	m_pAlphaMap->UnlockRect(0);
	
	//D3DXSaveTextureToFile("alpha.bmp", D3DXIFF_BMP, m_pAlphaMap, NULL);
}
Beispiel #9
0
void TileGroup::SetValue(type::Value &value, oid_t tuple_id,
                         oid_t column_id) {
  PL_ASSERT(tuple_id < GetNextTupleSlot());
  oid_t tile_column_id, tile_offset;
  LocateTileAndColumn(column_id, tile_offset, tile_column_id);
  GetTile(tile_offset)->SetValue(value, tuple_id, tile_column_id);
}
Beispiel #10
0
peloton::VarlenPool *TileGroup::GetTilePool(const oid_t tile_id) const {
  Tile *tile = GetTile(tile_id);

  if (tile != nullptr) return tile->GetPool();

  return nullptr;
}
Beispiel #11
0
bool Layer::DrawTileToVertexArrays(VertexVector* vertices, unsigned int x, unsigned int y) const {
	int tileX = x, tileY = y;
	if (IsWidthTiled) { //this stuff can probably be optimized a bit by checking at some higher level?
		if (tileX >= RealWidth)
			tileX %= RealWidth;
		else while (tileX < 0)
			tileX += RealWidth;
	}
	else if (tileX < 0 || tileX >= RealWidth)
		return false;
	if (IsHeightTiled) {
		if (tileY >= Height)
			tileY %= Height;
		else while (tileY < 0)
			tileY += Height;
	}
	else if (tileY < 0 || tileY >= Height)
		return false;
	const Tile tile = GetTile(tileX, tileY);
	if (tile.ID == 0)
		return false;
	quad tileQuad(LevelPtr->QuadsPerTile, tile);
	tileQuad.positionPositionAt(x * TILEWIDTH, y * TILEHEIGHT);
	tileQuad.appendTo(vertices[tileQuad.TextureID]);
	return tile.ID >= LevelPtr->AnimOffset;
}
Beispiel #12
0
/**
 * Grab next slot (thread-safe) and fill in the tuple
 *
 * Returns slot where inserted (INVALID_ID if not inserted)
 */
void TileGroup::CopyTuple(const Tuple *tuple, const oid_t &tuple_slot_id) {
    LOG_TRACE("Tile Group Id :: %u status :: %u out of %u slots ", tile_group_id,
              tuple_slot_id, num_tuple_slots);

    oid_t tile_column_count;
    oid_t column_itr = 0;

    for (oid_t tile_itr = 0; tile_itr < tile_count; tile_itr++) {
        const catalog::Schema &schema = tile_schemas[tile_itr];
        tile_column_count = schema.GetColumnCount();

        storage::Tile *tile = GetTile(tile_itr);
        PL_ASSERT(tile);
        char *tile_tuple_location = tile->GetTupleLocation(tuple_slot_id);
        PL_ASSERT(tile_tuple_location);

        // NOTE:: Only a tuple wrapper
        storage::Tuple tile_tuple(&schema, tile_tuple_location);

        for (oid_t tile_column_itr = 0; tile_column_itr < tile_column_count;
                tile_column_itr++) {
            tile_tuple.SetValue(tile_column_itr, tuple->GetValue(column_itr),
                                tile->GetPool());
            column_itr++;
        }
    }
}
 /// \brief
 ///  Accesses tile by height sample indices inside this sector. Indices must be in valid range
 inline VSectorTile *GetTileAtSampleIndices(int x,int y) const
 {
   x/=m_Config.m_iHeightSamplesPerTile[0];
   y/=m_Config.m_iHeightSamplesPerTile[1];
   // the height samples must be in range, but clamp at max edge because of extra overlapping values
   return GetTile(hkvMath::Min(x,m_Config.m_iTilesPerSector[0]-1),hkvMath::Min(y,m_Config.m_iTilesPerSector[1]-1));
 }
Beispiel #14
0
	cTile* cTileMapLineIt::Next()
	{
		GetTile();

      	mbUpdated = false;
		return mpTile;
	}
Beispiel #15
0
/*
void TerrainTest::_recalculateType(int x, int y)
{
	tile* t = GetTile(x, y);
	tile* t2;
	if (t)
		t->type = type;
	
	if (t->type == TILE_NORTHEDGE)
	{
		
	}
}
*/
void TerrainTest::Repair()
{
	tiletype type;
	tile* t;
	
	//fix invalid types
	for (int y = 0; y < height; y++)
	{
		for (int x = 0; x < width; x++)
		{	
			_repairTile(x, y);	
		}	
	}
	
	//set types
	for (int y = 0; y < height; y++)
	{
		for (int x = 0; x < width; x++)
		{	
			t = GetTile(x, y);
			type = GetTileType(x, y);
			if (t)
				t->type = type;
		}		
	}
	
	//after all types are set, go again and reload
/*	for (int y = 0; y < height; y++)
	{
		for (int x = 0; x < width; x++)
		{	
			_recalculateType(x, y);
		}		
	}*/
}
Beispiel #16
0
void Map::Draw(Gdiplus::Graphics* g)
{
	Vector3i northWestTile = mMapViewport->GetNorthWestTileCoordinate();
	Vector3i southEastTile = mMapViewport->GetSouthEastTileCoordinate();
	Vector2i origin = mMapViewport->GetTileOrigin(northWestTile);
	int xTileCount = southEastTile.GetX() - northWestTile.GetX() + 1;
	int yTileCount = southEastTile.GetY() - northWestTile.GetY() + 1;
	int tileCount = xTileCount*yTileCount;

	for(int i = 0; i<xTileCount; i++)
	{
		for(int j = 0; j<yTileCount; j++)
		{
			Vector3i coord(northWestTile.GetX() + i, northWestTile.GetY() + j, mMapViewport->GetZoom());
			Tile* tile = GetTile(coord);
			if(!tile->IsLoaded())
			{
				tile->SignalReady += [this](Tile* tile) {
					std::lock_guard<std::mutex> lock(signal_mutex);
					SignalNewTile.emit();
				};
				continue;
			}
			Gdiplus::Image* im = tile->GetImage();
			if(im)
				g->DrawImage(im, origin.GetX() + i*mMapSource->GetTileSize(), origin.GetY() + j*mMapSource->GetTileSize());
		}
	}
}
Beispiel #17
0
void SetupForegroundLayer()
{
    s16 tilepositionx = PIXEL_TO_TILE(-scrollData.scrollx_vdp) - 1; // divide by 8
    s16 tilepositiony = PIXEL_TO_TILE(scrollData.scrolly_vdp) - 1; // 

    // compute start and end tiles
    s16 starttilex = tilepositionx;
    s16 endtilex = (tilepositionx + TILE_UPDATE_AREA_WIDTH);
    s16 starttiley = tilepositiony;
    s16 endtiley = (tilepositiony + TILE_UPDATE_AREA_HEIGHT);

    s16 loop = 0;
    s16 innerLoop = 0;
    u16 tileNumber = 0;
    u16 arrayStart = 0;

	const u16 tileBaseValue = TILE_ATTR_FULL(PAL3, 0, 0, 0, 0) + foregroundLoadedTileInfo.startIndex;

    for (loop = starttiley; loop <= endtiley; loop++)
    {
        arrayStart = loop * levelData.foreground->width;
        for (innerLoop = starttilex; innerLoop <= endtilex; innerLoop++)
        {
            tileNumber = ARRAY_ITEM_VALUE(levelData.foreground->tilemap, arrayStart + innerLoop);
			tileNumber = GetTile(tileNumber, tileBaseValue);
            VDP_setTileMapXY(APLAN, tileNumber, innerLoop & 63, loop & 63);
        }
    }
}
Beispiel #18
0
std::pair<int,int> Level::GetSpawnPoint ( const std::string& entrance_tag )
{
	int startx, starty;
	int entrance_exists = FindTileWithTag (entrance_tag, startx, starty);
	if ( entrance_exists )
	{
		return std::make_pair ( startx, starty );
	}
	// If we get this far, it's probably the town (but it could be a malcreated dungeon with no entrance).
	// Find a clear spot, anywhere will do.
	for ( int x = 1; x < sizex; x++ )
	{
		for ( int y = 1; y < sizey; y++ )
		{
			LevelTile& tile = GetTile ( x, y );
			if ( tile.tile->HasOneFlag ( FLAG_BLOCKS_MOVEMENT ) )
				continue;
			Mobile* mob = GetFirstMobileAt ( x, y );
			if ( mob )
				continue;
			return std::make_pair ( x, y );
		}
	}
	std::cerr << "Unable to find a player spawn point\n";
	exit ( 1 );
}
Beispiel #19
0
bool CCollision::IsTileSolid(int x, int y) const
{
	int Col = GetTile(x, y);

	if(Col&COLFLAG_SOLID)
		return true;

	if(!(Col&COLFLAG_TL3)) 
	{
		if(Col&COLFLAG_RED && Col&COLFLAG_BLUE)
		{
			if(Col&COLFLAG_APPEAR)
				return (Techlevel[0] >= 2 || Techlevel[1] >= 2);
			else
				return (Techlevel[0] < 2 && Techlevel[1] < 2);
		}
	} 
	else 
	{
		if(Col&COLFLAG_RED && Col&COLFLAG_BLUE)
		{
			if(Col&COLFLAG_APPEAR)
				return (Techlevel[0] == 3 || Techlevel[1] == 3);
			else
				return (Techlevel[0] < 3 && Techlevel[1] < 3);
		}
	}
		
	if(Col & COLFLAG_APPEAR)
		return (Col&COLFLAG_RED && !(Col&COLFLAG_TL3) && Techlevel[0] >= 2) || (Col&COLFLAG_RED && Col&COLFLAG_TL3 && Techlevel[0] == 3) || (Col&COLFLAG_BLUE && !(Col&COLFLAG_TL3) && Techlevel[1] >= 2) || (Col&COLFLAG_BLUE && Col&COLFLAG_TL3 && Techlevel[1] == 3);
	else	
		return (Col&COLFLAG_RED && !(Col&COLFLAG_TL3) && Techlevel[0] < 2) || (Col&COLFLAG_RED && Col&COLFLAG_TL3 && Techlevel[0] < 3) || (Col&COLFLAG_BLUE && !(Col&COLFLAG_TL3) && Techlevel[1] < 2) || (Col&COLFLAG_BLUE && Col&COLFLAG_TL3 && Techlevel[1] < 3);
}
Beispiel #20
0
void TiledGroundMap::SetTile(int x, int y, const std::string& texture, int rotate, bool mirror)
{
	Tile* tile = GetTile(x, y);
	tile->texture = texture;
	tile->rotate = rotate;
	tile->mirror = mirror;
}
Beispiel #21
0
/**
 * Apply the column delta on the rollback segment to the given tuple
 */
void TileGroup::ApplyRollbackSegment(char *rb_seg, const oid_t &tuple_slot_id) {
    auto seg_col_count = storage::RollbackSegmentPool::GetColCount(rb_seg);
    auto table_schema = GetAbstractTable()->GetSchema();

    for (size_t idx = 0; idx < seg_col_count; ++idx) {
        auto col_id =
            storage::RollbackSegmentPool::GetIdOffsetPair(rb_seg, idx)->col_id;
        Value col_value =
            storage::RollbackSegmentPool::GetValue(rb_seg, table_schema, idx);

        // Get target tile
        auto tile_id = GetTileIdFromColumnId(col_id);
        PL_ASSERT(tile_id < GetTileCount());
        storage::Tile *tile = GetTile(tile_id);
        PL_ASSERT(tile);

        // Get tile schema
        auto &tile_schema = tile_schemas[tile_id];

        // Get a tuple wrapper
        char *tile_tuple_location = tile->GetTupleLocation(tuple_slot_id);
        PL_ASSERT(tile_tuple_location);
        storage::Tuple tile_tuple(&tile_schema, tile_tuple_location);

        // Write the value to tuple
        auto tile_col_idx = GetTileColumnId(col_id);
        tile_tuple.SetValue(tile_col_idx, col_value, tile->GetPool());
    }
}
Beispiel #22
0
void cShoot::CanShoot(int *map, cBicho &Player) {
	int x,y;
	GetTile(&x,&y);
	if(map[x+(y*SCENE_WIDTH)] != 0) active = false;
	else active = true;
	if(active) {
		if(GetState() == STATE_SHOOT_LEFT || GetState() == STATE_LOOKLEFT || GetState() == STATE_WALKLEFT ) {
			active = !(Player.CollidesMapWall(map,false));
			if(map[(x+1)+y*SCENE_WIDTH] != 0) active = false;
			if(map[(x+2)+y*SCENE_WIDTH] != 0) active = false;
		}
		else if(GetState() == STATE_LOOKDOWN||GetState() == STATE_WALKDOWN) {
			active = !(Player.CollidesTopBot(map,false));
			if(map[x+((y+1)*SCENE_WIDTH)] != 0) active = false;
		}
		else if(GetState() == STATE_LOOKUP||GetState() == STATE_LOOKUP) {
			active = !(Player.CollidesTopBot(map,true));
		}
		else if(GetState() == STATE_SHOOT_RIGHT || GetState() == STATE_LOOKRIGHT || GetState() == STATE_WALKRIGHT ) {
			active = !(Player.CollidesMapWall(map,true));
			if(map[(x+1)+y*SCENE_WIDTH] != 0) active = false;
		}
		else if(GetState() == STATE_DUPLEFT) {
			active = !(Player.CollidesWall(map,false));
		}
	}

}
Beispiel #23
0
TerrainTile* TerrainHolder::GetTile(float x, float y)
{
	int32 tx = (int32)(32 - (x / TERRAIN_TILE_SIZE));
	int32 ty = (int32)(32 - (y / TERRAIN_TILE_SIZE));

	return GetTile(tx, ty);
}
void UTerrainManager::DiscoverCave(int32 x, int32 y) {
	if (IsOutOfBounds(x, y))
		return;

	ATile* t = GetTile(x, y);
	if (!t->IsVisible)
	{
		t->IsVisible = true;
		DiscoverCave(x - 1, y);
		DiscoverCave(x + 1, y);
		DiscoverCave(x, y - 1);
		DiscoverCave(x, y + 1);
		DiscoverCave(x - 1, y + 1);
		DiscoverCave(x + 1, y + 1);
		DiscoverCave(x + 1, y - 1);
		DiscoverCave(x - 1, y - 1);
	}
	if (t->IsWall()) {
		if (UpdateWallAtTile(t))
			CollapseTile(t);
	}
	else {
		t->GetStaticMeshComponent()->SetStaticMesh(t->GroundMesh);
		t->GetStaticMeshComponent()->SetMaterial(0, this->BiomeMaterials[t->TextureIndex()]);
	}
}
Beispiel #25
0
bool CCollision::IsTileSolid(int x, int y, bool nocoll)
{
    //H-Client
    if (nocoll && m_pMineTeeTiles)
    {
        if (((GetMineTeeBlockAt(x,y) >= BLOCK_UNDEF48 && GetMineTeeBlockAt(x,y) <= BLOCK_BED) ||
         GetMineTeeBlockAt(x,y) == BLOCK_RSETA || GetMineTeeBlockAt(x,y) == BLOCK_BSETA) ||
         GetMineTeeBlockAt(x,y) == BLOCK_TARTA1 || GetMineTeeBlockAt(x,y) == BLOCK_TARTA2)
        {
            int Nx = clamp(x/32, 0, m_Width-1);
            int Ny = clamp(y/32, 0, m_Height-1);
            Nx *= 32; Ny *= 32;

            if (y >= Ny+16.0f)
                return 1;

            return 0;
        }
        else if (m_pMineTeeTiles && (GetMineTeeBlockAt(x,y) == BLOCK_AZUCAR ||
                                     GetMineTeeBlockAt(x,y) == BLOCK_ROSAR || GetMineTeeBlockAt(x,y) == BLOCK_ROSAY ||
                                     (GetMineTeeBlockAt(x,y) >= BLOCK_SEED1 && GetMineTeeBlockAt(x,y) <= BLOCK_SEED8) ||
                                     GetMineTeeBlockAt(x,y) == BLOCK_SETAR1 || GetMineTeeBlockAt(x,y) == BLOCK_SETAR2))
            return 0;
    }

	return GetTile(x, y)&COLFLAG_SOLID;
}
Beispiel #26
0
void SeedBag::Use() {
   auto currentLandmark = GameState::Get().GetCurrentLandmark();
   auto positionX = Player::Get().GetPositionX();
   auto positionY = Player::Get().GetPositionY();

   auto tile = currentLandmark->GetTile(positionX, positionY);
   if (tile.TileType != TileType::Tilled) {
      GameState::Get().AddLogMessage("The ground here is not tilled!");
      return;
   }

   auto prop = currentLandmark->GetProp(positionX, positionY);
   if (prop != nullptr) {
      GameState::Get().AddLogMessage("There is already something here.");
      return;
   }
   if (this->NumberOfSeeds <= 0) {
      GameState::Get().AddLogMessage("There are no more seeds in this bag.");
      return;
   }
   this->NumberOfSeeds--;

   auto crop = PlantedCrop::Construct(Crop::FromCropType(this->CropType), CropGrowthType::Seedling);
   currentLandmark->AddProp(positionX, positionY, crop);
   auto cropName = Crop::FromCropType(this->CropType).Name;
   bool startsWithVowel = cropName.find_first_of("aAeEiIoOuU") == 0;
   GameState::Get().AddLogMessageFmt("You plant %s %s.", startsWithVowel ? "an" : "a", cropName.c_str());
}
void Plantable::Plant(ItemPtr sourceItem)
{
    auto x = Player::Get().GetPositionX();
    auto y = Player::Get().GetPositionY();
    auto currentLandmark = GameState::Get().GetCurrentLandmark();
    auto currentTile = currentLandmark->GetTile(x, y);

    if (currentTile.TileType != TileType::Tilled) {
        GameState::Get().AddLogMessage("You can only plant on tilled land!");
        return;
    }

    auto item = currentLandmark->GetItem(x, y);
    if (item != nullptr) {
        GameState::Get().AddLogMessageFmt("Cannot plant, %s is on the ground here.", item->GetName().c_str());
        return;
    }

    auto crop = GameState::Get().GetItemFromItemDatabase(this->Crop);
    crop->SetCount(1);
    currentLandmark->AddItem(x, y, crop);

    auto growableInterface = crop->GetInterface<Growable>(ItemInterfaceType::Growable);
    if (growableInterface != nullptr) {
        growableInterface->StartGrowing(crop);
    }

    sourceItem->RemoveOne();

}
Beispiel #28
0
	void Display()
	{
		SDL_Rect t_pos;
		t_pos.w = TILE_SIZE;
		t_pos.h = TILE_SIZE;
		for(t_pos.x = 0; t_pos.x < w*TILE_SIZE; t_pos.x+=TILE_SIZE)
		{
			for(t_pos.y = 0; t_pos.y < h*TILE_SIZE; t_pos.y+=TILE_SIZE)
			{
				if(GetTile(t_pos.x/TILE_SIZE,t_pos.y/TILE_SIZE).wall)
				{
					SDL_BlitSurface(i_wall,NULL,screen,&t_pos);
				}
				else
				{
					SDL_BlitSurface(i_grass,NULL,screen,&t_pos);
				}
			}
		}

		//display players
		for(int i = 0; i < players.size(); i++)
		{
			SDL_BlitSurface(i_player,NULL,screen,&players[i]->GetScreenPos());
		}

		SDL_Flip(screen);
	}
Beispiel #29
0
CStr8 CTerrain::GetMovementClass(ssize_t i, ssize_t j) const
{
	CMiniPatch* tile = GetTile(i, j);
	if (tile && tile->GetTextureEntry())
		return tile->GetTextureEntry()->GetProperties().GetMovementClass();

	return "default";
}
Beispiel #30
0
type::AbstractPool *TileGroup::GetTilePool(const oid_t tile_id) const {
  Tile *tile = GetTile(tile_id);

  if (tile != nullptr) {
    return tile->GetPool();
  }

  return nullptr;
}