Пример #1
0
void j1Map::Draw()
{
	if(map_loaded == false)
		return;
	
	//this is because we may need it in the future
	p2List_item<TileSet*>* tileset = data.tilesets.start;
	p2List_item<MapLayer*>* layer = data.layers.start;

	//for now we just paint all layers
	while (tileset && layer)
	{
		for (int y = 0; y < data.height; y++)
		{
			for (int x = 0; x < data.width; x++)
			{
				uint tileID = layer->data->Get(x, y);
				if (tileID != 0 && layer->data->visible != 0)
				{
					SDL_Rect tile = tileset->data->GetTileRect(tileID);
					iPoint pos = MapToWorld(x, y);

					App->render->Blit(tileset->data->texture, pos.x, pos.y, &tile);
				}
			}
		}
		layer = layer->next;
	}
}
Пример #2
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);
				}
			}
		}
	}
}
Пример #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
	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);
				}
			}
		}
	}
}
Пример #5
0
//Gives the blit position of a tile from the map coordinates of the tile
iPoint j1Map::GetTileBlit(int x, int y)const
{
	iPoint ret(x, y);

	ret = MapToWorld(ret.x, ret.y);
	ret.x -= data.tile_width / 2;
	return ret;

}
Пример #6
0
//Gets the World coordinate of the center of the tile from the Map coordinate of that tile
iPoint j1Map::GetTileCenter(int x, int y) const
{
	iPoint ret(x, y);

	ret = MapToWorld(ret.x, ret.y);
	
	ret.y += data.tile_height/2;

	return ret;
}
Пример #7
0
//Translates any screen position to the tile position (in world coordinates) that it belongs
iPoint j1Map::GetTileWorld(int x, int y) const
{
	// NOTE : this maybe can be better applied anywhere else
	iPoint ret(x, y);

	ret = WorldToMap(ret.x, ret.y);
	ret = MapToWorld(ret.x, ret.y);

	return ret;
}
Пример #8
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);
						
					
					//----------------------
				}
			}
		}
	}
	
}
Пример #9
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;
	}
}