Пример #1
0
void j1Map::Draw()
{
	if(map_loaded == false)
		return;

	p2List_item<MapLayer*>* item = data.layers.start;

	for(; item != NULL; item = item->next)
	{
		MapLayer* layer = item->data;

		if(layer->properties.Get("Nodraw") != 0)
			continue;

		for(int y = 0; y < data.height; ++y)
		{
			for(int x = 0; x < data.width; ++x)
			{
				int tile_id = layer->Get(x, y);
				if(tile_id > 0)
				{
					TileSet* tileset = GetTilesetFromTileId(tile_id);

					SDL_Rect r = tileset->GetTileRect(tile_id);
					iPoint pos = MapToWorld(x, y);

					App->render->Blit(tileset->texture, pos.x, pos.y, &r);
				}
			}
		}
	}
}
Пример #2
0
void j1Map::Draw()
{
	if(map_loaded == false)
		return;
	//STL CHANGE
	list<MapLayer*>::iterator item = data.layers.begin();

	for(; item != data.layers.end(); ++item)
	{
		MapLayer* layer = *item;

		if(layer->properties.Get("Nodraw") != 0)
			continue;

		for(int y = 0; y < data.height; ++y)
		{
			for(int x = 0; x < data.width; ++x)
			{
				int tile_id = layer->Get(x, y);
				if(tile_id > 0)
				{
					TileSet* tileset = GetTilesetFromTileId(tile_id);

					SDL_Rect r = tileset->GetTileRect(tile_id);
					iPoint pos = MapToWorld(x, y);

					App->render->Blit(tileset->texture, pos.x, pos.y, &r);
				}
			}
		}
	}
}
Пример #3
0
void j1Map::Draw()
{
	if(map_loaded == false)
		return;

	// TODO 5: Prepare the loop to draw all tilesets + Blit
	MapLayer* layer = data.layers.start->data;

	for(int y = 0; y < data.height; ++y)
	{
		for(int x = 0; x < data.width; ++x)
		{
			int tile_id = layer->Get(x, y);
			if(tile_id > 0)
			{
				// TODO 10(old): Complete the draw function
				TileSet* tileset = data.tilesets.start->data;

				SDL_Rect r = tileset->GetTileRect(tile_id);
				iPoint pos = MapToWorld(x, y);

				App->render->Blit(tileset->texture, pos.x, pos.y, &r);
			}
		}
	}
}
Пример #4
0
void j1Map::Draw()
{
	if(map_loaded == false)
		return;
	//STL CHANGE
	//NOTE: well
	//Camera Culling
	//----------------------
	SDL_Rect cam = App->render->camera;
	//----------------------

	list<MapLayer*>::iterator item = data.layers.begin();

	for(; item != data.layers.end(); ++item)
	{
		MapLayer* layer = *item;


		//NOTE: when drawing navigation map, framerate drops to the half
		if (!App->debug)
			if(layer->properties.Get("Nodraw") != 0)
				continue;

		for(int y = 0; y < data.height; ++y)
		{
			for(int x = 0; x < data.width; ++x)
			{
				int tile_id = layer->Get(x, y);
				if(tile_id > 0)
				{
					TileSet* tileset = GetTilesetFromTileId(tile_id);

					SDL_Rect r = tileset->GetTileRect(tile_id);
					iPoint pos = MapToWorld(x, y);

					//NOTE: Maybe this has to be implemented on Render.cpp
					//NOTE: changing the offset of the tiles because Ric cheated with the original, think about make it general for any map
					//NOTE: because of test sake
					//----------------------

						if (layer->name == "Background")
							App->render->Blit(tileset->texture, pos.x - data.tile_width / 2 + tileset->offset_x, pos.y, &r);
						else if (layer->name == "Navigation")
							App->render->Blit(tileset->texture, pos.x - data.tile_width / 2 , pos.y, &r);
						
					
					//----------------------
				}
			}
		}
	}
	
}
Пример #5
0
void j1Map::Draw()
{
	if(map_loaded == false)
		return;

	// TODO 4: Make sure we draw all the layers and not just the first one
	p2List_item<MapLayer*>* layer = data.layers.start;

	while (layer)
	{	
		//This makes appear the Navigation Layer
		if (layer->data->name == "Meta" && App->input->GetKey(SDL_SCANCODE_I) == KEY_DOWN)
		{
			if (layer->data->properties.GetPropertyValue("Draw") == 0)
				layer->data->properties.SetPropertyValue("Draw", 1);
			else
				layer->data->properties.SetPropertyValue("Draw", 0);
		}
		//------------------------------------
		if (layer->data->properties.GetPropertyValue("Draw"))
		{
			for (int y = 0; y < data.height; ++y)
			{
				for (int x = 0; x < data.width; ++x)
				{
					int tile_id = layer->data->Get(x, y);
					if (tile_id > 0)
					{
						TileSet* tileset = GetTilesetFromTileId(tile_id);

						if (tileset != NULL)
						{
							SDL_Rect r = tileset->GetTileRect(tile_id);
							iPoint pos = MapToWorld(x, y);

							App->render->Blit(tileset->texture, pos.x + tileset->offset_x, pos.y + tileset->offset_y, &r);
						}
					}
				}
			}
		}
		layer = layer->next;
	}
}