Пример #1
0
part_ui::RESULT part_ui::show()
{
	if(p_.music().empty() != true) {
		sound::play_music_repeatedly(p_.music());
	}

	if(p_.sound().empty() != true) {
		sound::play_sound(p_.sound());
	}

	render_background();

	if(p_.show_title()) {
		render_title_box();
	}

	if(!imgs_.empty()) {
		if(!render_floating_images()) {
			return ret_;
		}
	}

	try {
		render_story_box();
	}
	catch(utf8::invalid_utf8_exception const&) {
		ERR_NG << "invalid UTF-8 sequence in story text, skipping part..." << std::endl;
	}

	return ret_;
}
Пример #2
0
void render_game(GameData* data, DrawConfig* config){
    /*
     * Clear the window prior to any rendering
     */
    render_clear(config); 

    /*
     * Draw all componenets of the came
     */
    render_background(data,config);
    render_all_pipes(data,config);
    render_score(data,config);
    render_bird(data,config);

    /*
     * Render GameOver message if the user has lost
     */
    if(is_gameover(data)){
        render_gameover_message(data,config);
    }

    /*
     * Update the users view to reflect changes 
     */
    SDL_RenderPresent(config->renderer);
}
Пример #3
0
void MENUS::render_loading(float percent)
{
	static int64 last_load_render = 0;

	// make sure that we don't render for each little thing we load
	// because that will slow down loading if we have vsync
	if(time_get()-last_load_render < time_freq()/60)
		return;
		
	last_load_render = time_get();
	
	// need up date this here to get correct
	vec3 rgb = hsl_to_rgb(vec3(config.ui_color_hue/255.0f, config.ui_color_sat/255.0f, config.ui_color_lht/255.0f));
	gui_color = vec4(rgb.r, rgb.g, rgb.b, config.ui_color_alpha/255.0f);
	
    RECT screen = *ui_screen();
	gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);
	
	render_background();

	float tw;

	float w = 700;
	float h = 200;
	float x = screen.w/2-w/2;
	float y = screen.h/2-h/2;

	gfx_blend_normal();

	gfx_texture_set(-1);
	gfx_quads_begin();
	gfx_setcolor(0,0,0,0.50f);
	draw_round_rect(x, y, w, h, 40.0f);
	gfx_quads_end();


	const char *caption = localize("Loading");

	tw = gfx_text_width(0, 48.0f, caption, -1);
	RECT r;
	r.x = x;
	r.y = y+20;
	r.w = w;
	r.h = h;
	ui_do_label(&r, caption, 48.0f, 0, -1);

	gfx_texture_set(-1);
	gfx_quads_begin();
	gfx_setcolor(1,1,1,0.75f);
	draw_round_rect(x+40, y+h-75, (w-80)*percent, 25, 5.0f);
	gfx_quads_end();

	gfx_swap();
}
Пример #4
0
void render_slide(slide *sl)
{
	/* Returns a specially allocated surface only if the "except"
		subimage != NULL; otherwise uses the slide's built-in render surface. */
	
	style *st = sl->st;
	displaylinevector *repr = sl->repr;
	displayline *out;
	DrawMode *dm;
	SDL_Surface *surface;

	if(export_html == 1)
		printf("Rendering %s\n", sl->content->line);	
	if(sl->image_file != NULL)
		return;
	
	if(sl->render != NULL)
		SDL_FreeSurface(sl->render);
	sl->render = alloc_surface(sl->des_w, sl->des_h);
	
	reallocate_surfaces(sl);
	surface = sl->render;
		
	render_background(sl, surface);
	
	// Render the text lines:	
	dm = new DrawMode;
	dm->ttmode = dm->boldmode = dm->italicmode = 0;
	dm->current_text_colour_index = st->textcolour;
	dm->lastshift = 0;
	for(int i = 0; i < repr->count(); i++)
	{
		out = repr->item(i);
		render_line(sl, out, dm, surface);
	}
	delete dm;
	
	draw_logos(sl, st, surface);

	// Draw embedded images:
	subimage *img;
	for(int i = 0; i < sl->visible_images->count(); i++)
	{
		img = sl->visible_images->item(i);
		if(img->surface == NULL)
			load_subimage(img);
		draw_subimage(surface, img);
	}
	if(sl->deck_size > 1)
		render_decorations(sl);

	scale(sl);
}
Пример #5
0
int main(int argc, char *argv[]) {
	
	qw_screen(960, 680, 0, "King Arthur's Gold - Map Editor");
	
	qw_image background = qw_loadimage("res/img/background_trees.png");

	while (qw_running()) {
		render_background(&background);

		qw_redraw();
	}

	qw_quit();

	return 0;
}
Пример #6
0
int MENUS::render()
{
    RECT screen = *ui_screen();
	gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);

	static bool first = true;
	if(first)
	{
		if(config.ui_page == PAGE_INTERNET)
			client_serverbrowse_refresh(0);
		else if(config.ui_page == PAGE_LAN)
			client_serverbrowse_refresh(1);
		first = false;
	}
	
	if(client_state() == CLIENTSTATE_ONLINE)
	{
		color_tabbar_inactive = color_tabbar_inactive_ingame;
		color_tabbar_active = color_tabbar_active_ingame;
	}
	else
	{
		render_background();
		color_tabbar_inactive = color_tabbar_inactive_outgame;
		color_tabbar_active = color_tabbar_active_outgame;
	}
	
	RECT tab_bar;
	RECT main_view;

	// some margin around the screen
	ui_margin(&screen, 10.0f, &screen);
	
	if(popup == POPUP_NONE)
	{
		// do tab bar
		ui_hsplit_t(&screen, 24.0f, &tab_bar, &main_view);
		ui_vmargin(&tab_bar, 20.0f, &tab_bar);
		render_menubar(tab_bar);
		
		// news is not implemented yet
		if(config.ui_page <= PAGE_NEWS || config.ui_page > PAGE_SETTINGS || (client_state() == CLIENTSTATE_OFFLINE && config.ui_page >= PAGE_GAME && config.ui_page <= PAGE_CALLVOTE))
		{
			client_serverbrowse_refresh(BROWSETYPE_INTERNET);
			config.ui_page = PAGE_INTERNET;
		}
		
		// render current page
		if(client_state() != CLIENTSTATE_OFFLINE)
		{
			if(game_page == PAGE_GAME)
				render_game(main_view);
			else if(game_page == PAGE_SERVER_INFO)
				render_serverinfo(main_view);
			else if(game_page == PAGE_CALLVOTE)
				render_servercontrol(main_view);
			else if(game_page == PAGE_SETTINGS)
				render_settings(main_view);
		}
		else if(config.ui_page == PAGE_NEWS)
			render_news(main_view);
		else if(config.ui_page == PAGE_INTERNET)
			render_serverbrowser(main_view);
		else if(config.ui_page == PAGE_LAN)
			render_serverbrowser(main_view);
		else if(config.ui_page == PAGE_DEMOS)
			render_demolist(main_view);
		else if(config.ui_page == PAGE_FAVORITES)
			render_serverbrowser(main_view);
		else if(config.ui_page == PAGE_SETTINGS)
			render_settings(main_view);
//		else if(config.ui_page == PAGE_TEE-NG)
//			renger_settings(main_teeng);
	}
	else
	{
		// make sure that other windows doesn't do anything funnay!
		//ui_set_hot_item(0);
		//ui_set_active_item(0);
		char buf[128];
		const char *title = "";
		const char *extra_text = "";
		const char *button_text = "";
		int extra_align = 0;
		
		if(popup == POPUP_MESSAGE)
		{
			title = message_topic;
			extra_text = message_body;
			button_text = message_button;
		}
		else if(popup == POPUP_CONNECTING)
		{
			title = localize("Connecting to");
			extra_text = config.ui_server_address;  // TODO: query the client about the address
			button_text = localize("Abort");
			if(client_mapdownload_totalsize() > 0)
			{
				title = localize("Downloading map");
				str_format(buf, sizeof(buf), "%d/%d KiB", client_mapdownload_amount()/1024, client_mapdownload_totalsize()/1024);
				extra_text = buf;
			}
		}
		else if(popup == POPUP_DISCONNECTED)
		{

			title = localize("Disconnected");
			extra_text = client_error_string();
			button_text = localize("Ok");
			extra_align = -1;
		}
		else if(popup == POPUP_PURE)
		{
			title = localize("Disconnected");
			extra_text = localize("The server is running a non-standard tuning on a pure game type.");
			button_text = localize("Ok");
			extra_align = -1;
		}
		else if(popup == POPUP_PASSWORD)
		{
			title = localize("Password Incorrect");
			extra_text = client_error_string();
			button_text = localize("Try again");
		}
		else if(popup == POPUP_QUIT)
		{
			title = localize("Quit");
			extra_text = localize("Are you sure that you want to quit?");
		}
		else if(popup == POPUP_FIRST_LAUNCH)
		{
			title = localize("Welcome to Teeworlds");
			extra_text = localize("As this is the first time you launch the game, please enter your nick name below. It's recommended that you check the settings to adjust them to your liking before joining a server.");
			button_text = localize("Ok");
			extra_align = -1;
		}
		
		RECT box, part;
		box = screen;
		ui_vmargin(&box, 150.0f, &box);
		ui_hmargin(&box, 150.0f, &box);
		
		// render the box
		ui_draw_rect(&box, vec4(0,0,0,0.5f), CORNER_ALL, 15.0f);
		 
		ui_hsplit_t(&box, 20.f, &part, &box);
		ui_hsplit_t(&box, 24.f, &part, &box);
		ui_do_label(&part, title, 24.f, 0);
		ui_hsplit_t(&box, 20.f, &part, &box);
		ui_hsplit_t(&box, 24.f, &part, &box);
		ui_vmargin(&part, 20.f, &part);
		
		if(extra_align == -1)
			ui_do_label(&part, extra_text, 20.f, -1, (int)part.w);
		else
			ui_do_label(&part, extra_text, 20.f, 0, -1);

		if(popup == POPUP_QUIT)
		{
			RECT yes, no;
			ui_hsplit_b(&box, 20.f, &box, &part);
			ui_hsplit_b(&box, 24.f, &box, &part);
			ui_vmargin(&part, 80.0f, &part);
			
			ui_vsplit_mid(&part, &no, &yes);
			
			ui_vmargin(&yes, 20.0f, &yes);
			ui_vmargin(&no, 20.0f, &no);

			static int button_abort = 0;
			if(ui_do_button(&button_abort, localize("No"), 0, &no, ui_draw_menu_button, 0) || escape_pressed)
				popup = POPUP_NONE;

			static int button_tryagain = 0;
			if(ui_do_button(&button_tryagain, localize("Yes"), 0, &yes, ui_draw_menu_button, 0) || enter_pressed)
				client_quit();
		}
		else if(popup == POPUP_PASSWORD)
		{
			RECT label, textbox, tryagain, abort;
			
			ui_hsplit_b(&box, 20.f, &box, &part);
			ui_hsplit_b(&box, 24.f, &box, &part);
			ui_vmargin(&part, 80.0f, &part);
			
			ui_vsplit_mid(&part, &abort, &tryagain);
			
			ui_vmargin(&tryagain, 20.0f, &tryagain);
			ui_vmargin(&abort, 20.0f, &abort);
			
			static int button_abort = 0;
			if(ui_do_button(&button_abort, localize("Abort"), 0, &abort, ui_draw_menu_button, 0) || escape_pressed)
			{
				if(config.cl_autoconnect)
				config.cl_autoconnect == 0;
				else
				popup = POPUP_NONE;
			}

			static int button_tryagain = 0;
			if(ui_do_button(&button_tryagain, localize("Try again"), 0, &tryagain, ui_draw_menu_button, 0) || enter_pressed)
			{
				client_connect(config.ui_server_address);
			}
			
			ui_hsplit_b(&box, 60.f, &box, &part);
			ui_hsplit_b(&box, 24.f, &box, &part);
			
			ui_vsplit_l(&part, 60.0f, 0, &label);
			ui_vsplit_l(&label, 100.0f, 0, &textbox);
			ui_vsplit_l(&textbox, 20.0f, 0, &textbox);
			ui_vsplit_r(&textbox, 60.0f, &textbox, 0);
			ui_do_label(&label, localize("Password"), 20, -1);
			ui_do_edit_box(&config.password, &textbox, config.password, sizeof(config.password), 14.0f, true);
		}
		else if(popup == POPUP_FIRST_LAUNCH)
		{
			RECT label, textbox;
			
			ui_hsplit_b(&box, 20.f, &box, &part);
			ui_hsplit_b(&box, 24.f, &box, &part);
			ui_vmargin(&part, 80.0f, &part);
			
			static int enter_button = 0;
			if(ui_do_button(&enter_button, localize("Enter"), 0, &part, ui_draw_menu_button, 0) || enter_pressed)
				popup = POPUP_NONE;
			
			ui_hsplit_b(&box, 40.f, &box, &part);
			ui_hsplit_b(&box, 24.f, &box, &part);
			
			ui_vsplit_l(&part, 60.0f, 0, &label);
			ui_vsplit_l(&label, 100.0f, 0, &textbox);
			ui_vsplit_l(&textbox, 20.0f, 0, &textbox);
			ui_vsplit_r(&textbox, 60.0f, &textbox, 0);
			ui_do_label(&label, localize("Nickname"), 20, -1);
			ui_do_edit_box(&config.player_name, &textbox, config.player_name, sizeof(config.player_name), 14.0f);
		}
		else
		{
			ui_hsplit_b(&box, 20.f, &box, &part);
			ui_hsplit_b(&box, 24.f, &box, &part);
			ui_vmargin(&part, 120.0f, &part);

			static int button = 0;
			if(ui_do_button(&button, button_text, 0, &part, ui_draw_menu_button, 0) || escape_pressed || enter_pressed)
			{
				if(popup == POPUP_CONNECTING)
					client_disconnect();
				popup = POPUP_NONE;
			}
		}
	}
	
	return 0;
}
Пример #7
0
void part_ui::render_story_box()
{
#ifdef SDL_GPU
	LOG_NG << "ENTER part_ui()::render_story_box()\n";

	const std::string& storytxt = p_.text();
	if(storytxt.empty()) {
		video_.flip();
		wait_for_input();
		return;
	}

	const part::BLOCK_LOCATION tbl = p_.story_text_location();
	const int max_width = buttons_x_ - storybox_padding - text_x_;
	const int max_height = screen_area().h - storybox_padding;

	skip_ = false;
	last_key_ = true;

	font::ttext t;
	if(!t.set_text(p_.text(), true)) {
		ERR_NG << "Text: Invalid markup in '"
				<< p_.text() << "' rendered as is.\n";
		t.set_text(p_.text(), false);
	}
	t.set_font_style(font::ttext::STYLE_NORMAL)
		 .set_font_size(storybox_font_size)
		 .set_foreground_color(storybox_font_color)
		 .set_maximum_width(max_width)
		 .set_maximum_height(max_height, true);
	sdl::timage txttxt = t.render_as_texture();

	if(txttxt.null()) {
		ERR_NG << "storyscreen text area rendering resulted in a null texture" << std::endl;
		return;
	}

	int fix_text_y = text_y_;
	if(fix_text_y + 2*(storybox_padding+1) + txttxt.height() > screen_area().h && tbl != part::BLOCK_TOP) {
		fix_text_y =
			(screen_area().h > txttxt.height() + 1) ?
			(std::max(0, screen_area().h - txttxt.height() - 2*(storybox_padding+1))) :
			(0);
	}
	int fix_text_h;
	switch(tbl) {
	case part::BLOCK_TOP:
		fix_text_h = std::max(txttxt.height() + 2*storybox_padding, screen_area().h/4);
		break;
	case part::BLOCK_MIDDLE:
		fix_text_h = std::max(txttxt.height() + 2*storybox_padding, screen_area().h/3);
		break;
	default:
		fix_text_h = screen_area().h - fix_text_y;
		break;
	}

	SDL_Rect update_area = sdl::create_rect(0
			, fix_text_y
			, screen_area().w
			, fix_text_h);

	/* do */ {
		// this should kill the tiniest flickering caused
		// by the buttons being hidden and unhidden in this scope.
		update_locker locker(video_);

		next_button_.hide();
		back_button_.hide();
		play_button_.hide();

		//TODO: blurring

		const SDL_Rect box = sdl::create_rect(0, fix_text_y, screen_area().w,
											  fix_text_h);

		sdl::fill_rect(video_, box, storyshadow_r, storyshadow_g,
					   storyshadow_b, storyshadow_a);

		render_story_box_borders(update_area); // no-op if LOW_MEM is defined

		next_button_.hide(false);
		back_button_.hide(false);
		play_button_.hide(false);
	}

	// Time to do some f*****g visual effect.
	const int scan_height = 1, scan_width = txttxt.width();
	SDL_Rect scan = sdl::create_rect(0, 0, scan_width, scan_height);
	SDL_Rect dstrect = sdl::create_rect(text_x_, 0, scan_width, scan_height);
	bool scan_finished = false;
	while(true) {
		scan_finished = scan.y >= txttxt.base_height();
		if (!scan_finished)
		{
			dstrect.y = fix_text_y + scan.y + storybox_padding;
			txttxt.set_clip(scan);
			video_.draw_texture(txttxt, dstrect.x, dstrect.y);
			video_.flip();
			++scan.y;
		}
		else skip_ = true;

		if (handle_interface()) break;

		if (!skip_ || scan_finished) {
			CVideo::delay(20);
		}
	}

	const SDL_Rect rect = sdl::create_rect(0, 0, video_.getx(), video_.gety());
	sdl::fill_rect(video_, rect, 0, 0, 0, SDL_ALPHA_OPAQUE);
#else

	LOG_NG<< "ENTER part_ui()::render_story_box()\n";
	bool first = true;

	render_background();

	if(p_.show_title()) {
		render_title_box();
	}

	if(!imgs_.empty()) {
		if(!render_floating_images()) {
			return;
		}
	}


	const std::string& storytxt = p_.text();
	if(storytxt.empty()) {
		wait_for_input();
		return;
	}

	skip_ = false;
	last_key_ = true;
	font::ttext t;
	bool scan_finished = false;
	SDL_Rect scan;
	SDL_Rect dstrect;


	while(true) {

		if (dirty_) {

			render_background();

			if(p_.show_title()) {
				render_title_box();
			}

			if(!imgs_.empty()) {
				if(!render_floating_images()) {
					return;
				}
			}
		}

		part::BLOCK_LOCATION tbl = p_.story_text_location();
		int max_width = buttons_x_ - storybox_padding - text_x_;
		int max_height = screen_area().h - storybox_padding;

		if(!t.set_text(p_.text(), true)) {
			ERR_NG << "Text: Invalid markup in '"
					<< p_.text() << "' rendered as is.\n";
			t.set_text(p_.text(), false);
		}
		t.set_font_style(font::ttext::STYLE_NORMAL)
				.set_font_size(storybox_font_size)
				.set_foreground_color(storybox_font_color)
				.set_maximum_width(max_width)
				.set_maximum_height(max_height, true);

		surface txtsurf = t.render();

		if(txtsurf.null()) {
			ERR_NG << "storyscreen text area rendering resulted in a null surface" << std::endl;
			return;
		}

		int fix_text_y = text_y_;
		if(fix_text_y + 2*(storybox_padding+1) + txtsurf->h > screen_area().h && tbl != part::BLOCK_TOP) {
			fix_text_y =
			(screen_area().h > txtsurf->h + 1) ?
			(std::max(0, screen_area().h - txtsurf->h - 2*(storybox_padding+1))) :
			(0);
		}
		int fix_text_h;
		switch(tbl) {
			case part::BLOCK_TOP:
			fix_text_h = std::max(txtsurf->h + 2*storybox_padding, screen_area().h/4);
			break;
			case part::BLOCK_MIDDLE:
			fix_text_h = std::max(txtsurf->h + 2*storybox_padding, screen_area().h/3);
			break;
			default:
			fix_text_h = screen_area().h - fix_text_y;
			break;
		}

		SDL_Rect update_area = sdl::create_rect(0
				, fix_text_y
				, screen_area().w
				, fix_text_h);

		/* do */{
			// this should kill the tiniest flickering caused
			// by the buttons being hidden and unhidden in this scope.
			update_locker locker(video_);

			next_button_.hide();
			back_button_.hide();
			play_button_.hide();

#ifndef LOW_MEM
			if (dirty_ || first) {
				blur_area(video_, fix_text_y, fix_text_h);
			}
#endif
			if (dirty_ || first) {
				sdl::draw_solid_tinted_rectangle(
						0, fix_text_y, screen_area().w, fix_text_h,
						storyshadow_r, storyshadow_g, storyshadow_b,
						storyshadow_opacity,
						video_.getSurface()
				);
			}

			render_story_box_borders(update_area); // no-op if LOW_MEM is defined

			next_button_.hide(false);
			back_button_.hide(false);
			play_button_.hide(false);
		}

		if (dirty_ || first) {
			if(!imgs_.empty() && update_area.h > 0) {
				update_rect(update_area);
			}
		}

		// Time to do some visual effecta.
		if (dirty_ || first) {
			const int scan_height = 1, scan_width = txtsurf->w;
			scan = sdl::create_rect(0, 0, scan_width, scan_height);
			dstrect = sdl::create_rect(text_x_, 0, scan_width, scan_height);
		}

		/* This needs to happen before poll for events */
		dirty_ = false;
		first = false;

		scan_finished = scan.y >= txtsurf->h;
		if (!scan_finished)
		{
			//dstrect.x = text_x_;
			dstrect.y = fix_text_y + scan.y + storybox_padding;
			// NOTE: ::blit_surface() screws up with antialiasing and hinting when
			//       on backgroundless (e.g. black) screens; ttext::draw()
			//       uses it nonetheless, no idea why...
			//       Here we'll use CVideo::blit_surface() instead.
			video_.blit_surface(dstrect.x, dstrect.y, txtsurf, &scan);
			update_rect(dstrect);
			++scan.y;
		}
		else {
			skip_ = true;
		}

		if (handle_interface()) break;

		if (!skip_ || scan_finished) {
			CVideo::delay(20);
		}

	}

	sdl::draw_solid_tinted_rectangle(
			0, 0, video_.getx(), video_.gety(), 0, 0, 0,
			1.0, video_.getSurface()
	);
#endif
}
Пример #8
0
bool part_ui::render_floating_images()
{
#ifdef SDL_GPU
	skip_ = false;
	last_key_ = true;

	size_t fi_n = 0;
	BOOST_FOREACH(floating_image::render_input& ri, imgs_) {
		const floating_image& fi = p_.get_floating_images()[fi_n];

		if(!ri.image.null()) {
			ri.image.draw(video_, ri.rect.x, ri.rect.y);
			video_.flip();
		}

		if (!skip_)
		{
			int delay = fi.display_delay(), delay_step = 20;
			for (int i = 0; i != (delay + delay_step - 1) / delay_step; ++i)
			{
				if (handle_interface()) return false;
				if (skip_) break;
				CVideo::delay(std::min<int>(delay_step, delay - i * delay_step));
			}
		}

		++fi_n;
	}

	return true;
#else
	events::raise_draw_event();

	skip_ = false;
	last_key_ = true;

	size_t fi_n = 0;
	BOOST_FOREACH(floating_image::render_input& ri, imgs_) {
		const floating_image& fi = p_.get_floating_images()[fi_n];

		if(!ri.image.null()) {
			render_background();
			for (size_t i = 0; i <= fi_n; i++)
			{
				floating_image::render_input& old_ri = imgs_[i];
				sdl_blit(old_ri.image, NULL, video_.getSurface(), &old_ri.rect);
				update_rect(old_ri.rect);
			}
		}

		if (!skip_)
		{
			int delay = fi.display_delay(), delay_step = 20;
			for (int i = 0; i != (delay + delay_step - 1) / delay_step; ++i)
			{
				if (handle_interface()) return false;
				if (skip_) break;
				CVideo::delay(std::min<int>(delay_step, delay - i * delay_step));
			}
		}

		++fi_n;
	}

	return true;
#endif
}
Пример #9
0
void render_world(void) {
    // posicion absoluta en el mundo de la izquierda de la pantalla
    t_pos left_absolute_x=world_get_left_absolute_x();
    t_pos block_width=500.0;
    
    int iblock=(int)(left_absolute_x/block_width);
    int i;
//    int ibackblock=(int)((left_absolute_x/2.0)/(block_width*2.0));
	
    //background
    
    render_background();
    
    t_pos tile_x;
    
    float slow_factor=1/10.0;  // 1 = foreground speed  0 = static background
    float level_factor=10.0;  // 1 = foreground speed  n = 1 background por cada n de foreground
    
    t_pos back_tile_x;
    t_pos back_tile_w=assets_tiles[4].out_bounds.w;
    back_tile_x= back_tile_w*(int)(world.player.x*slow_factor/back_tile_w) - world.player.x*slow_factor +(world.cam_x+200)*slow_factor -world.cam_x;

    back_tile_x= (int)((world.player.x+world.cam_x)/(back_tile_w*level_factor)) + (world.player.x+world.cam_x)/level_factor -world.player.x - world.cam_x;

    back_tile_x= back_tile_w*(int)((world.player.x+world.cam_x)/(back_tile_w*level_factor)) + (world.player.x+world.cam_x)*(1.0-1.0/level_factor) -world.player.x - world.cam_x;

    int back_i;
    back_i=(int)((world.player.x+world.cam_x)/(back_tile_w*level_factor));
    
    back_tile_x=round(back_tile_x);
//    back_tile_x+=400;
    
//    glBlendColor(0.8,0.8,0.8,0.6);
//    glBlendFunc(GL_CONSTANT_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_FOG);
    glPushMatrix();
    glTranslatef(0, 0, 0.4);
    
    int fondo_id_ant,fondo_id,fondo_id_sig,fondo_id_sigsig;
    fondo_id=((back_i/3)%2)==0?AST_TILE_FONDO:AST_TILE_FONDO2;
    fondo_id_ant=(((back_i-1)/3)%2)==0?AST_TILE_FONDO:AST_TILE_FONDO2;
    fondo_id_sig=(((back_i+1)/3)%2)==0?AST_TILE_FONDO:AST_TILE_FONDO2;
    fondo_id_sigsig=(((back_i+2)/3)%2)==0?AST_TILE_FONDO:AST_TILE_FONDO2;
    
    render_tile_num(back_tile_x-back_tile_w, c_floor_level-20.0, fondo_id_ant);
    render_tile_num(back_tile_x, c_floor_level-20.0, fondo_id);
    render_tile_num(back_tile_x+back_tile_w, c_floor_level-20.0, fondo_id_sig);
    if (fondo_id_ant==AST_TILE_FONDO && fondo_id==AST_TILE_FONDO2) {
        render_tile_num(back_tile_x-145, c_floor_level-20.0 -1 , AST_TILE_FONDO_TRANS12);
    } else if (fondo_id_ant==AST_TILE_FONDO2 && fondo_id==AST_TILE_FONDO) {
        render_tile_num(back_tile_x-134, c_floor_level-30.0 +9 , AST_TILE_FONDO_TRANS21);
    }
    if (fondo_id==AST_TILE_FONDO && fondo_id_sig==AST_TILE_FONDO2) {
        render_tile_num(back_tile_x+back_tile_w-145, c_floor_level-20.0 -1 , AST_TILE_FONDO_TRANS12);
    } else if (fondo_id==AST_TILE_FONDO2 && fondo_id_sig==AST_TILE_FONDO) {
//        glColor3f(1,1,1);
//        render_box(back_tile_x+back_tile_w-134+134-340 +340/2, c_floor_level-30.0 +9 +100 +390/2,340/2,390/2);
        render_tile_num(back_tile_x+back_tile_w-134, c_floor_level-30.0 +9 , AST_TILE_FONDO_TRANS21);
    }
    if (fondo_id_sig==AST_TILE_FONDO && fondo_id_sigsig==AST_TILE_FONDO2) {
        render_tile_num(back_tile_x+2*back_tile_w-145, c_floor_level-20.0 -1 , AST_TILE_FONDO_TRANS12);
    } else if (fondo_id_sig==AST_TILE_FONDO2 && fondo_id_sigsig==AST_TILE_FONDO) {
        //        glColor3f(1,1,1);
        //        render_box(back_tile_x+back_tile_w-134+134-340 +340/2, c_floor_level-30.0 +9 +100 +390/2,340/2,390/2);
        render_tile_num(back_tile_x+2*back_tile_w-134, c_floor_level-30.0 +9 , AST_TILE_FONDO_TRANS21);
    }
    glPopMatrix();
    glDisable(GL_FOG);
//    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

    
    // solo provisional por ver tres planos
//    slow_factor=0.6;
//    back_tile_w=assets_tiles[1].out_bounds.w+100;
//    back_tile_x=-left_absolute_x*slow_factor+back_tile_w*(int)(left_absolute_x*slow_factor/back_tile_w);
//    render_tile_num(back_tile_x, c_floor_level, AST_TILE_CASAS1);
//    render_tile_num(back_tile_x+back_tile_w, c_floor_level, AST_TILE_CASAS1);

    
    glColor4f(1,0,0,1);
    render_back_zone(1,0);
    glColor4f(0,1,0,1);
    render_back_zone(1,1);
    glColor4f(0,0,1,1);
    render_back_zone(1,2);    
    
    glColor4f(1,0,0,1);
    render_back_zone(0,0);
    glColor4f(0,1,0,1);
    render_back_zone(0,1);
    glColor4f(0,0,1,1);
    render_back_zone(0,2);
    
    
//    for (i=0;i<2;i++) {
//        tile_x=(ibackblock+i)*block_width*2.0-(world.player.x+world.cam_x)/2.0;
//        glColor4f(0,.3,0,1);
//        render_mountain(tile_x,c_floor_level+50,470,150);
//    }
		
//    for (i=0;i<3;i++) {
//        tile_x=(iblock+i)*block_width-world.player.x-world.cam_x - 100.0;
//     //   render_tile_num(tile_x, c_floor_level-70, AST_TILE_SUELO);
//     //   glColor4f(.5,.3,.3,1);
//     //   render_tile(tile_x,c_floor_level-30,block_width-10,40);
//     //   glColor4f(.3,.3,.3,1);
//        //        render_tile(tile_x+110,c_floor_level,100,100);
//        //        render_tile_num(tile_x+110,c_floor_level,AST_TILE_ARBOL2);
//    }	
	
	
    // items
    t_item_iterator iter_i;
    item_iterate_init(&iter_i);
    t_itemPtr item;
    while ( NULL != (item=item_iterate_next(&world, &iter_i)) ) {
        render_item(item);
    }

    // cansados
    t_sprite_iterator iter;
    world_iterate_sprites(&iter);
    t_spritePtr sprite;
    while ( NULL != (sprite=world_iterate_next(&iter)) ) {
        if (sprite->sprite_class->id==SPRCLS_ID_CANSADO) {
            render_sprite(sprite);
        }
    }
    
    // walkers pero no bicis
    world_iterate_sprites(&iter);
    while ( NULL != (sprite=world_iterate_next(&iter)) ) {
        if (sprite->sprite_class->id==SPRCLS_ID_PEREGRINO || sprite->sprite_class->id==SPRCLS_ID_BORDONERO) {
            render_sprite(sprite);
        }
    }
    
    
    //player
    render_sprite(&world.player);

	
    // bicis aparte
    world_iterate_sprites(&iter);
    while ( NULL != (sprite=world_iterate_next(&iter)) ) {
        if (sprite->sprite_class->id==SPRCLS_ID_BICI) {
            render_sprite(sprite);
        }
    }

    
    
    for (i=0;i<3;i++) {
        tile_x=(iblock+i)*block_width-world.player.x-world.cam_x;
        glColor4f(0,1,0,1);
        //        render_tile(tile_x,c_floor_level-40,block_width-10,40);
        render_tile_num(tile_x, c_floor_level-100.0, AST_TILE_SUELO);
        glColor4f(.3,.3,.3,1);
        //        render_tile(tile_x+110,c_floor_level,100,100);
        //        render_tile_num(tile_x+110,c_floor_level,AST_TILE_ARBOL2);
    }
    
    
    render_bocina();
    
    int pading=30, hpading=10;
    render_tile_num(pading,pading-hpading*game_salto_pressed,AST_TILE_BTN_SALTAR);
    render_tile_num(160+pading,pading-hpading*game_esquivar_pressed,AST_TILE_BTN_ESQUIVAR);
    render_tile_num(810+pading,pading-hpading*game_hit_pressed,AST_TILE_BTN_PEGAR);
    render_tile_num(660+pading,pading-hpading*game_stop_pressed,AST_TILE_BTN_ANDAR);
    
    render_tile_num(860, 535, AST_TILE_BTN_PAUSE);
    
    if ( world.player.anim_state_id==STID_PLAYER_TIRED ) {
        //render_label_num(250, 300, 15);
        //render_tile(300, 300, &text_gameover_tile);
        render_tile_num(180,300,AST_TILE_GAMEOVER);
    }
    
    if (world.t<2.8) {
        render_tile_num(305,300,AST_TILE_READY);
    } else if (world.t<3.6) {
        render_tile_num(390/*-world.player.x+500.0*/,300,AST_TILE_GO);        
    }

}