bool TGLobject_tank_turret::cycle(VirtualController *k,class TGLmap *map,GLTManager *GLTM,SFXManager *SFXM,int sfx_volume)
{
	if (m_tank->get_hitpoints()<m_hitpoints) m_hitpoints=m_tank->get_hitpoints();
	if (m_tank->get_hitpoints()>m_hitpoints) m_tank->set_hitpoints(m_hitpoints);

	if (m_type==3) {
		m_x=(m_tank->get_x());
		m_y=(m_tank->get_y()-26);
	} else {
		m_x=(m_tank->get_x()+2);
		m_y=(m_tank->get_y()-17);
	} // if 

	m_angle=m_tank->get_angle()/2;

	if (m_hit) {
		Sound_play(SFXM->get(TGL_SFX_FOLDER "/enemyhit"),sfx_volume);
		m_hit=false;
	} // if 

	if (m_hitpoints<=0) {
		Sound_play(SFXM->get(TGL_SFX_FOLDER "/explosion"),sfx_volume);
		map->add_auxiliary_front_object(new TGLobject_FX_explosion2(get_x(),get_y(),128,200));
		return false;
	} // if 


	return true;
} /* TGLobject_tank_turret::cycle */ 
bool TGLobject_cannon_up::cycle(VirtualController *k,class TGLmap *map,GLTManager *GLTM,SFXManager *SFXM,int sfx_volume)
{
	TGLobject *ship;
	m_cycle++;

	switch(m_state) {
	case 0:	ship=map->object_exists("TGLobject_ship",get_x()-16,get_y(),get_x()+48,get_y()+240);
			if (ship!=0) m_state=1;
			break;
	case 1: ship=map->object_exists("TGLobject_ship",get_x()-16,get_y(),get_x()+48,get_y()+240);
			if (ship!=0) {
				// fire
				map->add_object_back(new TGLobject_bullet(get_x()+17,get_y()+30,0,180,2,1,GLTM->get("objects/bullet-grey"),this));
				m_state=128;
				Sound_play(SFXM->get("sfx/shot"),sfx_volume);

				// Smoke:
				{
					int i;
					for(i=0;i<4;i++) {
						map->add_auxiliary_back_object(new TGLobject_FX_particle(get_x()+17,get_y()+30,rand()%60,float((rand()%101)-50)/256.0f,float((rand()%101)-50)/256.0f,1,false,0.25f,0,0.25f,0.75f,50,GLTM->get("objects/smoke")));
					} // for
				}
			} else {
				m_state=0;
			} // if
			break;
	default:
			m_state--;
	} // switch

	if (m_hit) {
		Sound_play(SFXM->get("sfx/enemyhit"),sfx_volume);
		m_hit=false;
	} // if 

	if (m_hitpoints<=0) {
		Sound_play(SFXM->get("sfx/explosion"),sfx_volume);
		map->add_auxiliary_front_object(new TGLobject_FX_explosion2(get_x()+16,get_y()+16,128,200));
		return false;
	} // if 


	return true;
} /* TGLobject_cannon_up::cycle */ 
Beispiel #3
0
int Manipulation_play (Manipulation me, int method) {
	try {
		autoSound sound = Manipulation_to_Sound (me, method);
		Sound_play (sound.get(), nullptr, nullptr);
		return 1;
	} catch (MelderError) {
		Melder_throw (me, U": not played.");
	}
}
bool CSemaphoreObject::cycle(unsigned char *keyboard,unsigned char *old_keyboard)
{
	timmer++;

	if (timmer>=SEMAPHORE_TIME*1) tile=1;
	if (timmer>=SEMAPHORE_TIME*2) tile=0;
	if (timmer>=SEMAPHORE_TIME*3) tile=2;
	if (timmer>=SEMAPHORE_TIME*4) tile=0;
	if (timmer>=SEMAPHORE_TIME*5) tile=3;
	if (timmer>=SEMAPHORE_TIME*6) tile=0;
	if (timmer>=SEMAPHORE_TIME*7) tile=4;

	/* sound: */ 
	if (timmer==SEMAPHORE_TIME*1) if (game->S_redlight!=0) Sound_play(game->S_redlight);
	if (timmer==SEMAPHORE_TIME*3) if (game->S_redlight!=0) Sound_play(game->S_redlight);
	if (timmer==SEMAPHORE_TIME*5) if (game->S_redlight!=0) Sound_play(game->S_redlight);
//	if (timmer==SEMAPHORE_TIME*7) if (game->S_greenlight!=0) Sound_play(game->S_greenlight);

	return true;
} /* CSemaphoreObject::cycle */ 
void Artword_Speaker_Sound_movie (Artword artword, Speaker speaker, Sound sound, Graphics graphics) {
	try {
		static struct playInfo info;   // must be static!!!
		info. artword = artword;
		info. speaker = speaker;
		info. graphics = graphics;
		autoSound mySound = sound ? nullptr : Sound_createSimple (1, artword -> totalTime, 44100);
		Sound_play (sound ? sound : mySound.peek(), playCallback, & info);
	} catch (MelderError) {
		Melder_throw (artword, U" & ", speaker, U": movie not played.");
	}
}
Beispiel #6
0
bool TGL::cycle(List<VirtualController> *lv,GLTManager *GLTM,SFXManager *SFXM,int sfx_volume)
{
	if (m_cycle==0) {
		int sound=rand()%2;

		switch(sound) {
		case 0: Sound_play(SFXM->get("sfx/start"),sfx_volume);
				break;
		case 1: Sound_play(SFXM->get("sfx/start2"),sfx_volume);
				break;
		} // switch 
	} // if 


	if (m_map!=0) {
		m_map->cycle(lv,GLTM,SFXM,sfx_volume);
		m_cycle++;
	} // if 
	
	if (m_map->object_exists(m_ship)) {
		m_focus_x=int(m_ship->get_x());
		m_focus_y=int(m_ship->get_y());		
	} else {
		// player dead
		m_ship=0;
		m_game_result=2;
		return false;
	} // if 

	if (m_map->object_exists(m_ball) && 
		m_ball->get_y()<=0) {
		m_game_result=1;
		return false;
	} // if 

	return true;
} /* TGL::cycle */ 
Beispiel #7
0
void Sound_reloadTrack(void) {
  char *song;
  char *path;
	scripting_GetGlobal("settings", "current_track", NULL);
  scripting_GetStringResult(&song);
  fprintf(stderr, "[sound] loading song %s\n", song);
  path = getPath( PATH_MUSIC, song );
  scripting_StringResult_Free(song);
  if(path == NULL) {
    fprintf(stderr, "[sound] can't find song...exiting\n");
    nebu_assert(0); exit(1); // TODO: handle missing song somewhere else
  }
  Sound_load(path);
  Sound_play();

  free(path);
}
Beispiel #8
0
void Sound_reloadTrack(void) {
  char *song;
  char *path;
	scripting_GetGlobal("settings", "current_track", NULL);
  scripting_GetStringResult(&song);
  // TODO: fix the song loading
  free(song);

  song = "song_revenge_of_cats.it";
  fprintf(stderr, "[sound] loading song %s\n", song);
  path = getPath( PATH_MUSIC, song );
//  free(song);
  if(path == NULL) {
    fprintf(stderr, "[sound] can't find song...exiting\n");
    exit(1); // FIXME: handle missing song somewhere else
  }
  Sound_load(path);
  Sound_play();

  free(path);
}
bool TGLobject_directionalcannon_down::cycle(VirtualController *k,class TGLmap *map,GLTManager *GLTM,SFXManager *SFXM,int sfx_volume)
{
	TGLobject *ship;
	m_cycle++;
	bool in_range=false;

	ship=map->object_exists("TGLobject_ship",get_x()-320,get_y()-240,get_x()+320,get_y()+240);
	if (ship!=0) {
		// compute desired angle:
		float dx=ship->get_x()-get_x(),dy=ship->get_y()-get_y();
		float a=float((180*atan2(float(dx),float(dy)))/M_PI);
		a=90-a;
		while (a>360) a-=360;
		while (a<0) a+=360;

		if (a>=190 && a<=350) {
			// ship in valid range:
			if (m_angle<a) m_angle++;
			if (m_angle>a) m_angle--;

			if (fabs(m_angle-a)<2) in_range=true;
		} // if 
	} // if 


	switch(m_state) {
	case 0:	if (in_range) m_state=1;
			break;
	case 1: if (in_range) {
				// fire
				TGLobject *bullet;
				int a=m_angle;
				while(a<0) a+=360;
				while(a>=360) a-=360;
				bullet=new TGLobject_bullet(float(get_x()+(cos_degree(a)*14)),float(get_y()+(sin_degree(a)*14)),0,m_angle+90,2,1,GLTM->get("graphics/objects/bullet-grey.png"),this);
				map->add_object_back(bullet);
				m_state=128;
				Sound_play(SFXM->get(TGL_SFX_FOLDER "/shot"),sfx_volume);

				// Smoke:
				{
					int i;
					for(i=0;i<4;i++) {
						map->add_auxiliary_back_object(new TGLobject_FX_particle(float(get_x()+(cos_degree(a)*14)),float(get_y()+(sin_degree(a)*14)),rand()%60,float((rand()%101)-50)/256.0f,float((rand()%101)-50)/256.0f,1,false,0.25f,0,0.25f,0.75f,50,GLTM->get("graphics/objects/smoke.png")));
					} // for
				}
			} else {
				m_state=0;
			} // if
			break;
	default:
			m_state--;
	} // switch

	if (m_hit) {
		Sound_play(SFXM->get(TGL_SFX_FOLDER "/enemyhit"),sfx_volume);
		m_hit=false;
	} // if 

	if (m_hitpoints<=0) {
		Sound_play(SFXM->get(TGL_SFX_FOLDER "/explosion"),sfx_volume);
		map->add_auxiliary_front_object(new TGLobject_FX_explosion2(get_x(),get_y(),128,200));
		return false;
	} // if 


	return true;
} /* TGLobject_directionalcannon_down::cycle */ 
bool TGLobject_ship_accura::cycle(VirtualController *k,TGLmap *map,GLTManager *GLTM,SFXManager *SFXM,int sfx_volume)
{
	m_cycle++;

	// Check for collision:
	if (map->collision(this,0,0,0)) {
		if (!map->collision_with_foreground(this,0,0,0)) {
			TGLobject *obj = map->collision_with_object(this);
			if (obj->is_a("TGLobject_soft_bullet")) {
				int a=obj->get_angle()-90;
				while(a<0) a+=360;
				while(a>=360) a-=360;
				m_speed_x+=float(cos_degree(a)*48.0)/256.0f;
				m_speed_y+=float(sin_degree(a)*48.0)/256.0f;
			} else {
				Sound_play(SFXM->get("sfx/explosion"),sfx_volume);
				map->add_auxiliary_front_object(new TGLobject_FX_explosion2(get_x(),get_y(),256,200));
				return false;
			}
		} else {
			Sound_play(SFXM->get("sfx/explosion"),sfx_volume);
			map->add_auxiliary_front_object(new TGLobject_FX_explosion2(get_x(),get_y(),256,200));
			return false;
		}
	} // if 

	m_thrusting=false;

	if (m_fuel_recharging_timmer>0) {
		m_fuel_recharging_timmer--;
		if (m_fuel_recharging_timmer==0) {
			if (m_fuel_channel!=-1) {
				Mix_HaltChannel(m_fuel_channel);
				m_fuel_channel=-1;
			} // if 
		} // if 
	} // if 

	if (k->m_button[1] && (fabs(m_speed_x)+fabs(m_speed_y))<1) {
		TGLobject_ball *ball;

		ball=(TGLobject_ball *)map->object_exists("TGLobject_ball",get_x()-16,get_y(),get_x()+16,get_y()+64);
		if (ball!=0 && m_ball==0) {
			if (ball->attractor()) {
				if (ball->get_state()==0) map->action(0);
				ball->capture(5);
				m_ball=ball;
				Sound_play(SFXM->get("sfx/takeball"),sfx_volume);
			} // if 
		} // if 

		// Attractor effect:
		{
			if ((m_cycle%6)==0) {
				map->add_auxiliary_back_object(new TGLobject_FX_particle(get_x(),get_y()+48,0,0,-1,0,false,
												0.5f,0.5f,
												0.5f,0.5f,
												1,1,
												1,0,0.75,0.5f,50,GLTM->get("objects/ripple-back")));
				map->add_auxiliary_front_object(new TGLobject_FX_particle(get_x(),get_y()+48,0,0,-1,0,false,
												0.5f,0.5f,
												0.5f,0.5f,
												1,1,
												1,0,0.75,0.5f,50,GLTM->get("objects/ripple-front")));
			} // if 
		};
	} // if 

	if (k->m_button[0] && !k->m_old_button[0] && m_fuel>40) {
		TGLobject *bullet;
		int a=m_angle-90;
		while(a<0) a+=360;
		while(a>=360) a-=360;

		if (m_missile_side==0) {
			bullet=new TGLobject_bullet_hmissile(float(get_x()+(cos_degree(a)*8)+(sin_degree(a)*7)),float(get_y()+(sin_degree(a)*8)-(cos_degree(a)*7)),0,m_angle,4,1,GLTM->get("objects/bullet-small-grey-missile1"),GLTM->get("objects/bullet-small-grey-missile2"),this);
			m_missile_side=1;
		} else {
			bullet=new TGLobject_bullet_hmissile(float(get_x()+(cos_degree(a)*8)-(sin_degree(a)*7)),float(get_y()+(sin_degree(a)*8)+(cos_degree(a)*7)),0,m_angle,4,1,GLTM->get("objects/bullet-small-grey-missile1"),GLTM->get("objects/bullet-small-grey-missile2"),this);
			m_missile_side=0;
		} // if 
		if (m_ball!=0) bullet->exclude_for_collision(m_ball);
		map->add_object_back(bullet);
		m_fuel-=40;
		Sound_play(SFXM->get("sfx/shipshot2"),sfx_volume);
	} // if 

	if (k->m_joystick[VC_LEFT]) {
		m_angle-=4;
		if (m_angle<0) m_angle+=360;
	} // if 
	if (k->m_joystick[VC_RIGHT]) {
		m_angle+=4;
		if (m_angle>=360) m_angle-=360;
	} // if

	if (k->m_joystick[VC_UP] && m_fuel>0) {
		int a=m_angle-90;
		while(a<0) a+=360;
		while(a>=360) a-=360;
		m_speed_x+=float(cos_degree(a)*11.0)/256.0f;
		m_speed_y+=float(sin_degree(a)*11.0)/256.0f;
		m_thrusting=true;
		m_fuel--;
	} // if 

	if (m_speed_x>0) m_speed_x-=1.0f/256.0f;
	if (m_speed_x<0) m_speed_x+=1.0f/256.0f;
	m_speed_y+=2.0f/256.0f;

	if (m_speed_x>8) m_speed_x=8;
	if (m_speed_x<-8) m_speed_x=-8;
	if (m_speed_y>8) m_speed_y=8;
	if (m_speed_y<-8) m_speed_y=-8;
	m_x+=m_speed_x;
	m_y+=m_speed_y;

	if (m_x<0) {
		m_x=0;
		m_speed_x=0;
	} /* if */ 
	if (m_y<0) {
		m_y=0;
		m_speed_y=0;
	} /* if */ 
	if (m_x>(map->get_dx())) {
		m_x=float(map->get_dx());
		m_speed_x=0;
	} /* if */ 
	if (m_y>(map->get_dy())) {
		m_y=float(map->get_dy());
		m_speed_y=0;
	} /* if */ 


	// Ball attraction:
	if (m_ball!=0) {
		float dx=m_ball->get_x()-get_x();
		float dy=m_ball->get_y()-get_y();
		float d=float(sqrt(dx*dx+dy*dy));

		if (d<2) d=2;
		{
			float inc=float(28/sqrt(d));
			float inc_x=((dx/d)*inc)/256.0f;
			float inc_y=((dy/d)*inc)/256.0f;
			m_ball->set_speed_x(m_ball->get_speed_x()-inc_x);
			m_ball->set_speed_y(m_ball->get_speed_y()-inc_y);
		}

	} // if 

	if (m_thrusting) {
		if ((m_cycle%4)==0) map->add_auxiliary_back_object(new TGLobject_FX_particle(get_x(),get_y(),rand()%60,0,0,1,false,0.125f,0,0.5f,1.5f,50,GLTM->get("objects/smoke")));

		if (m_thrust_channel==-1) {
			m_thrust_channel=Sound_play_continuous(SFXM->get("sfx/thrust"),sfx_volume);
		} // if 
	} else {
		if (m_thrust_channel!=-1) {
			Mix_HaltChannel(m_thrust_channel);
			m_thrust_channel=-1;
		} // if 
	} // if

	return true;
} /* TGLobject::cycle */ 
bool TGLobject_ha_directionalcannon_left::cycle(VirtualController *k,class TGLmap *map,GLTManager *GLTM,SFXManager *SFXM,int sfx_volume)
{
	TGLobject_ship *ship;
	m_cycle++;
	bool in_range=false;

	ship=(TGLobject_ship *)map->object_exists("TGLobject_ship",get_x()-400,get_y()-320,get_x()+400,get_y()+320);
	if (ship!=0) {

		// compute desired angle:
		float dx=ship->get_x()-get_x(),dy=ship->get_y()-get_y();
		float angle=float((180*atan2(float(dx),float(dy)))/M_PI);
		angle=90-angle;
		while (angle>180) angle-=360;
		while (angle<-180) angle+=360;

		{
			int a;
			float best_a=angle;
			float s_sx=ship->get_speedx();
			float s_sy=ship->get_speedy();
			float b_sx,b_sy;
			float d;
			float ls,lb;
			float error,min_error=10000;

			int min=-80,max=80;
			/* Copute the error given an angle "alpha": */ 
			for(a=min;a<max;a+=1) {
				b_sx=float(2*cos_degree(a));
				b_sy=float(2*sin_degree(a));

				d=s_sy*b_sx-s_sx*b_sy;
				if (d!=0) {
					ls=(dx*b_sy-dy*b_sx)/d;
					lb=(s_sy*dx-s_sx*dy)/d;

					if (lb>0) {
						error=float(fabs(ls-lb));
					} else {
						error=10000;
					} /* if */ 
				} else {
					error=10000;
				} /* if */ 

				if (error<min_error) {
					best_a=float(a);
					min_error=error;
				} /* if */ 
			} /* for */ 

			while (best_a>360) best_a-=360;
			while (best_a<0) best_a+=360;

			if (float(fabs(angle-best_a))>60 &&
				float(fabs(angle-best_a))<300) {
				float d=angle-best_a;

				if (d>0 && d<180) best_a=angle-60;
						     else best_a=angle+60;
			} /* if */ 

			angle=best_a;
		}	

		if (angle>=-80 && angle<=80) {
			// ship in valid range:
			if (m_angle<angle) m_angle++;
			if (m_angle>angle) m_angle--;
			if (m_angle<angle) m_angle++;
			if (m_angle>angle) m_angle--;
			if (abs(m_angle-int(angle))<2) in_range=true;
		} // if 
	} // if 


	switch(m_state) {
	case 0:	if (in_range) m_state=1;
			break;
	case 1: if (in_range) {
				// fire
				TGLobject *bullet;
				int a=m_angle;
				while(a<0) a+=360;
				while(a>=360) a-=360;
				bullet=new TGLobject_bullet(float(get_x()+(cos_degree(a)*14)),float(get_y()+(sin_degree(a)*14)),0,m_angle+90,2,1,GLTM->get("objects/bullet-grey"),this);
				map->add_object_back(bullet);
				m_state=128;
				Sound_play(SFXM->get("sfx/shot"),sfx_volume);

				// Smoke:
				{
					int i;
					for(i=0;i<4;i++) {
						map->add_auxiliary_back_object(new TGLobject_FX_particle(float(get_x()+(cos_degree(a)*14)),float(get_y()+(sin_degree(a)*14)),rand()%60,float((rand()%101)-50)/256.0f,float((rand()%101)-50)/256.0f,1,false,0.25f,0,0.25f,0.75f,50,GLTM->get("objects/smoke")));
					} // for
				}
			} else {
				m_state=0;
			} // if
			break;
	default:
			m_state--;
	} // switch

	if (m_hit) {
		Sound_play(SFXM->get("sfx/enemyhit"),sfx_volume);
		m_hit=false;
	} // if 

	if (m_hitpoints<=0) {
		Sound_play(SFXM->get("sfx/explosion"),sfx_volume);
		map->add_auxiliary_front_object(new TGLobject_FX_explosion2(get_x(),get_y(),128,200));
		return false;
	} // if 

	return true;
} /* TGLobject_ha_directionalcannon_left::cycle */ 
Beispiel #12
0
bool CGame::cycle(unsigned char *keyboard,unsigned char *old_keyboard)
{
	List<CObject> l;
	CObject *o;

	if (keyboard[SDLK_F1] && !old_keyboard[SDLK_F1]) {
		if (paused) paused=false;
			   else paused=true;
	} /* if */ 

	if (paused) return true;

	if (start_delay>0) {
		start_delay--;
		start_delay2=25;
		if (start_delay==0) {
			if (S_greenlight!=0) Sound_play(S_greenlight);
			start_delay2=25;
		} /* if */ 
	} else {
		if (start_delay2>0) {
			start_delay2--;
			if (start_delay2==0) {
				if ((current_level%2)==1) Sound_create_music("sd:/apps/roadfighter-wii/sound/game_theme.ogg",-1);
									 else Sound_create_music("sd:/apps/roadfighter-wii/sound/game_theme2.ogg",-1);
			} /* if */ 
		} /* if */ 
	} /* if */ 

	if (game_state==0 && game_timmer==0) {
		if (S_carstart!=0) Sound_play(S_carstart);
	} /* if */ 


	if (keyboard[SDLK_ESCAPE] && !old_keyboard[SDLK_ESCAPE] && game_state==0) {
		game_state=1;
		game_timmer=fade_time;
		esc_pressed=true;
	} /* if */ 

	if (keyboard[SDLK_BACKSPACE] && !old_keyboard[SDLK_BACKSPACE] && game_state==0) {
		game_state=1;
		game_timmer=fade_time;
		backspace_pressed=true;
	} /* if */ 

	l.Instance(background);
	l.Rewind();
	while(l.Iterate(o)) o->cycle(keyboard,old_keyboard);

	l.Instance(middleground);
	l.Rewind();
	while(l.Iterate(o)) o->cycle(keyboard,old_keyboard);

	l.Instance(foreground);
	l.Rewind();
	while(l.Iterate(o))  o->cycle(keyboard,old_keyboard);

	l.Instance(objects);
	l.Rewind();
	while(l.Iterate(o))  {
//		if (start_delay==0 && o->get_state()==0) o->set_state(1);
		if (!o->cycle(keyboard,old_keyboard)) todelete.Add(o);
	} /* while */ 

	while(!todelete.EmptyP()) {
		o=todelete.ExtractIni();
		objects.DeleteElement(o);
		delete o;
		o=0;
	} /* while */ 

	if (game_state==0) game_timmer++;
	if (game_state==1) game_timmer--;

	/* Add cars to the race: */ 
	{

		/* Very simple rule: add a car 512 pixels before each racer (if this new car is		*/ 
		/* not very close to another racer): */ 
		List<CObject> l;
		List<int> l2,l3;
		int *ip,*ip2;
		CObject *o;
		CCarObject *co;
		int new_car_y=-1;

		l.Instance(focusing_objects);
		l.Rewind();
		l2.Instance(focusing_next_car);
		l2.Rewind();
		l3.Instance(focusing_next_car_index);
		l3.Rewind();
		while(l.Iterate(o) && l2.Iterate(ip) && l3.Iterate(ip2)) {

			co=(CCarObject *)o;
			if ((-co->get_y_speed())>0.8F*MAX_SPEED) *ip=(*ip)-1;

			if ((*ip)<=0) {
				new_car_y=o->get_y()-CAR_APPEARING_OFFSET;
				if ((first_player(o) || 
					 min_distance_to_other_players(new_car_y,o)>PLAYING_WINDOW) &&
					 min_distance_to_car(new_car_y)>64) {
					/* Change this in function of the level: */ 
					int *pattern;
					int pattern1[]={0,1,0,0,0,4,
						           0,1,0,0,0,0,0,2,0,1,0,1,0,4,
								   0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,4,-1,6};
					int pattern2[]={0,1,0,2,0,0,0,4,
						            0,0,2,2,0,2,0,0,0,2,0,4,
									2,2,2,0,0,0,1,0,1,0,0,0,4,-1,8};
					/*	gpgbppg tggWggbtggpgg gpgbtggObgpgbppg ... */ 
					int pattern3[]={0,2,0,1,2,2,0,4,
									3,0,0,0,0,1,3,0,0,2,0,0,4,
									0,2,0,1,3,0,0,1,0,2,0,1,2,2,0,4,-1,8};
					/*	gbtggpg tggbtggptgg tgggtggpgggbtggpg ... */ 
					int pattern4[]={0,1,3,0,0,2,0,4,
									3,0,0,1,3,0,0,2,3,0,0,4,
									3,0,0,0,3,0,0,2,0,0,0,1,3,0,0,2,0,4,-1,8};
					/* tggbppppg pgpgbpptggbtgpptggbppppg ... */ 
					int pattern5[]={3,0,0,1,2,2,2,2,0,4,
									2,0,2,0,1,2,2,3,0,0,1,3,0,2,2,3,0,0,1,2,2,2,2,0,4,-1,10};
					/* gggpppgpppg tggpppgbtgpptggggggpppgpppg ... */ 
					int pattern6[]={0,0,0,2,2,2,0,2,2,2,0,4,
									3,0,0,2,2,2,0,1,3,0,2,2,3,0,0,0,0,0,0,2,2,2,0,2,2,2,0,-1,10};

					pattern=pattern1;
					if (current_level==2) pattern=pattern2;
					if (current_level==3) pattern=pattern3;
					if (current_level==4) pattern=pattern4;
					if (current_level==5) pattern=pattern5;
					if (current_level==6) pattern=pattern6;
					if (pattern[*ip2]==-1) *ip2=pattern[(*ip2)+1];
					
					if (pattern[*ip2]==0) add_enemy_car(0,new_car_y);
					if (pattern[*ip2]==1) add_enemy_car(1,new_car_y);
					if (pattern[*ip2]==2) add_enemy_car(2,new_car_y);
					if (pattern[*ip2]==3) add_enemy_car(3,new_car_y);
					if (pattern[*ip2]==4) add_enemy_car(4,new_car_y);

					if (obstacle_chance[game_mode][current_level-1]!=-1 &&
						(rand()%obstacle_chance[game_mode][current_level-1])==0) {
						int i=rand()%100;
						if (i<obstacle_oil[game_mode][current_level-1]) {
							add_obstacle(0,new_car_y);
						} else {
							i-=obstacle_oil[game_mode][current_level-1];
							if (i<obstacle_water[game_mode][current_level-1]) {
								add_obstacle(1,new_car_y);
							} else {
								add_obstacle(2,new_car_y);
							} /* if */ 
						} /* if */ 
					} /* if */ 

 					fastcar_counter++;
					if (fastcar_chance[game_mode][current_level-1]!=-1 &&
						fastcar_counter>fastcar_chance[game_mode][current_level-1]) {
						fastcar_counter=0;
						add_enemy_car(5,o->get_y()+128);
					} /* if */ 
			
					if (CAR_INTERVAL==16) {
						*ip=CAR_INTERVAL+(rand()%16)-8;
					} else if (CAR_INTERVAL==12) {
						*ip=CAR_INTERVAL+(rand()%16)-8;
					} else {
						*ip=CAR_INTERVAL;
					} /* if */ 
					(*ip2)++;
				} /* if */ 
			} /* if */ 
		} /* while */ 
	}

	/* Test if all the players are out of fuel: */ 
	if (game_state==0) { 
		bool found=false;
		l.Instance(focusing_objects);
		l.Rewind();
		while(l.Iterate(o)) {
			CPlayerCarObject *pco=(CPlayerCarObject *)o;
			if (pco->get_fuel()>0 || pco->get_y_speed()!=0) found=true;
		} /* while */ 

		if (!found) {
			/* All out of fuel: */ 
			game_state=1;
			game_timmer=fade_time*2;
		} /* if */ 
	}

	/* Test if level completed: */ 
	if (game_state==0 && level_completed()) {
		game_state=1;
		game_timmer=fade_time*4;
	} /* if */ 

	if (game_state==1 && game_timmer<0) return false;
	return true;
} /* CGame::cycle */ 
void structSpectrumEditor :: v_play (double fmin, double fmax) {
	autoSound sound = Spectrum_to_Sound_part ((Spectrum) data, fmin, fmax);
	Sound_play (sound.peek(), NULL, NULL);
}
void passage_mainloop(int map,int map_x,int map_y,unsigned char *screen,int dx,int dy)
{
	unsigned char *keyboard;

	SDL_PumpEvents();
	keyboard = (unsigned char *)SDL_GetKeyState(NULL);

	/* Dibujar el marco: */ 
	int i;

	for(i=0;i<32;i++) {
		tiles[143]->
			draw(GAME_VIEW_X+i*TILE_SIZE_X,GAME_VIEW_Y,
				 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
		tiles[143]->
			draw(GAME_VIEW_X+i*TILE_SIZE_X,GAME_VIEW_Y+18*TILE_SIZE_Y,
				 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	} /* for */ 
	for(i=0;i<19;i++) {
		tiles[143]->
			draw(GAME_VIEW_X,GAME_VIEW_Y+i*TILE_SIZE_Y,
				 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
		tiles[143]->
			draw(GAME_VIEW_X+TILE_SIZE_X,GAME_VIEW_Y+i*TILE_SIZE_Y,
				 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
		tiles[143]->
			draw(GAME_VIEW_X+30*TILE_SIZE_X,GAME_VIEW_Y+i*TILE_SIZE_Y,
				 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
		tiles[143]->
			draw(GAME_VIEW_X+31*TILE_SIZE_X,GAME_VIEW_Y+i*TILE_SIZE_Y,
				 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	} /* for */ 

	tiles[ladder_tile]->
		draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+19*TILE_SIZE_Y,
				TILE_SIZE_X*2,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	tiles[character_tile[character]+7]->
		draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+16*TILE_SIZE_Y,
				TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

	/* Dibujar los bocadillos: */ 
	tiles[151]->
		draw(GAME_VIEW_X+4*TILE_SIZE_X,GAME_VIEW_Y+4*TILE_SIZE_Y,
			 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	tiles[150]->
		draw(GAME_VIEW_X+27*TILE_SIZE_X,GAME_VIEW_Y+4*TILE_SIZE_Y,
			 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	tiles[149]->
		draw(GAME_VIEW_X+27*TILE_SIZE_X,GAME_VIEW_Y+10*TILE_SIZE_Y,
			 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	tiles[148]->
		draw(GAME_VIEW_X+4*TILE_SIZE_X,GAME_VIEW_Y+10*TILE_SIZE_Y,
			 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	for(i=5;i<27;i++) {
		tiles[146]->
			draw(GAME_VIEW_X+i*TILE_SIZE_X,GAME_VIEW_Y+4*TILE_SIZE_Y,
				 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
		tiles[146]->
			draw(GAME_VIEW_X+i*TILE_SIZE_X,GAME_VIEW_Y+10*TILE_SIZE_Y,
				 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	} /* for */ 
	for(i=5;i<10;i++) {
		tiles[147]->
			draw(GAME_VIEW_X+4*TILE_SIZE_X,GAME_VIEW_Y+i*TILE_SIZE_Y,
				 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
		tiles[147]->
			draw(GAME_VIEW_X+27*TILE_SIZE_X,GAME_VIEW_Y+i*TILE_SIZE_Y,
				 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	} /* for */ 
	tiles[145]->
		draw(GAME_VIEW_X+11*TILE_SIZE_X,GAME_VIEW_Y+4*TILE_SIZE_Y,
			 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);

	tiles[151]->
		draw(GAME_VIEW_X+4*TILE_SIZE_X,GAME_VIEW_Y+11*TILE_SIZE_Y,
			 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	tiles[150]->
		draw(GAME_VIEW_X+27*TILE_SIZE_X,GAME_VIEW_Y+11*TILE_SIZE_Y,
			 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	tiles[149]->
		draw(GAME_VIEW_X+27*TILE_SIZE_X,GAME_VIEW_Y+15*TILE_SIZE_Y,
			 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	tiles[148]->
		draw(GAME_VIEW_X+4*TILE_SIZE_X,GAME_VIEW_Y+15*TILE_SIZE_Y,
			 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	for(i=5;i<27;i++) {
		tiles[146]->
			draw(GAME_VIEW_X+i*TILE_SIZE_X,GAME_VIEW_Y+11*TILE_SIZE_Y,
				 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
		tiles[146]->
			draw(GAME_VIEW_X+i*TILE_SIZE_X,GAME_VIEW_Y+15*TILE_SIZE_Y,
				 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	} /* for */ 
	for(i=12;i<15;i++) {
		tiles[147]->
			draw(GAME_VIEW_X+4*TILE_SIZE_X,GAME_VIEW_Y+i*TILE_SIZE_Y,
				 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
		tiles[147]->
			draw(GAME_VIEW_X+27*TILE_SIZE_X,GAME_VIEW_Y+i*TILE_SIZE_Y,
				 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
	} /* for */ 
	tiles[144]->
		draw(GAME_VIEW_X+20*TILE_SIZE_X,GAME_VIEW_Y+15*TILE_SIZE_Y,
			 TILE_SIZE_X,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);

	if (map==0 && map_x==5 && map_y==9) {
		/* DEMETER */ 
		tile_print("h F5 TO F9",TILE_SIZE_X*6,TILE_SIZE_Y*21,screen,dx,dy);

		tile_print("DEMETER",TILE_SIZE_X*17,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[154]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		int slot=-1;
		/* Guardar el juego a disco: */ 

		if (keyboard[SDLK_F5] && !old_keyboard[SDLK_F5]) slot=1;
		if (keyboard[SDLK_F6] && !old_keyboard[SDLK_F6]) slot=2;
		if (keyboard[SDLK_F7] && !old_keyboard[SDLK_F7]) slot=3;
		if (keyboard[SDLK_F8] && !old_keyboard[SDLK_F8]) slot=4;
		if (keyboard[SDLK_F9] && !old_keyboard[SDLK_F9]) slot=5;

		if (slot!=-1) {
			char passwd[48];
			char tmp[80];
			FILE *fp;

			generatepassword(passwd);

			sprintf(tmp,"sgame%.2i.txt",slot);
			fp=f1open(tmp,"w",USERDATA);
			if (fp!=0) {
				int i;
				for(i=0;i<48;i++) {
					fprintf(fp,"%c",passwd[i]);
				} /* for */ 
				fclose(fp);
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 

		if (passage_state==0) {
			tile_print("YOU WANT THE SECRET",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("CODE TO WAKEN",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
			tile_print("MY MEMORY KEEP THE",TILE_SIZE_X*10,TILE_SIZE_Y*11,screen,dx,dy);
			tile_print("RECORDS ABOUT YOU?",TILE_SIZE_X*10,TILE_SIZE_Y*12,screen,dx,dy);
			tile_print("   YES         NO",TILE_SIZE_X*10,TILE_SIZE_Y*13,screen,dx,dy);
			if (currently_selecting==0) {
				tiles[152]->
					draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
						TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
			} /* if */ 
			if (currently_selecting==1) {
				tiles[152]->
					draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
						TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
			} /* if */ 
			if (keyboard[RIGHT_KEY] && !old_keyboard[RIGHT_KEY]) {
				if (currently_selecting<1) {
					currently_selecting++;
					Sound_play(S_select);
				} /* if */ 
			} /* if */ 
			if (keyboard[LEFT_KEY] && !old_keyboard[LEFT_KEY]) {
				if (currently_selecting>0) {
					currently_selecting--;
					Sound_play(S_select);
				} /* if */ 
			} /* if */ 
			if (keyboard[SWORD_KEY] && !old_keyboard[SWORD_KEY]) {
				if (currently_selecting==0) passage_state=2;
				if (currently_selecting==1) passage_state=1;
				keyboard[SWORD_KEY]=false;
			} /* if */ 
		} /* if */ 
		if (passage_state==1) {
			tile_print("RESCUE THE BABY AS ",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("SOON AS POSSIBLE",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} /* if */ 
		if (passage_state==2) {
			char passwd[48];
			char buf[20];
			int k;

			for(k=0;k<20;k++) buf[k]=' ';
			generatepassword(passwd);
			buf[0]=passwd[0]; buf[1]=passwd[1]; buf[2]=passwd[2]; buf[3]=passwd[3];
			buf[5]=passwd[4]; buf[6]=passwd[5]; buf[7]=passwd[6]; buf[8]=passwd[7];
			buf[10]=passwd[8]; buf[11]=passwd[9]; buf[12]=passwd[10]; buf[13]=passwd[11];
			buf[15]=passwd[12]; buf[16]=passwd[13]; buf[17]=passwd[14]; buf[18]=passwd[15];
			buf[19]=0;
			tile_print(buf,TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);

			buf[0]=passwd[16]; buf[1]=passwd[17]; buf[2]=passwd[18]; buf[3]=passwd[19];
			buf[5]=passwd[20]; buf[6]=passwd[21]; buf[7]=passwd[22]; buf[8]=passwd[23];
			buf[10]=passwd[24]; buf[11]=passwd[25]; buf[12]=passwd[26]; buf[13]=passwd[27];
			buf[15]=passwd[28]; buf[16]=passwd[29]; buf[17]=passwd[30]; buf[18]=passwd[31];
			buf[19]=0;
			tile_print(buf,TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);

			buf[0]=passwd[32]; buf[1]=passwd[33]; buf[2]=passwd[34]; buf[3]=passwd[35];
			buf[5]=passwd[36]; buf[6]=passwd[37]; buf[7]=passwd[38]; buf[8]=passwd[39];
			buf[10]=passwd[40]; buf[11]=passwd[41]; buf[12]=passwd[42]; buf[13]=passwd[43];
			buf[15]=passwd[44]; buf[16]=' '; buf[17]=' '; buf[18]=' ';
			buf[19]=0;
			tile_print(buf,TILE_SIZE_X*10,TILE_SIZE_Y*11,screen,dx,dy);

			tile_print("DID YOU GET THEM?",TILE_SIZE_X*10,TILE_SIZE_Y*12,screen,dx,dy);
			tile_print("   YES",TILE_SIZE_X*10,TILE_SIZE_Y*13,screen,dx,dy);
			tiles[152]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
			if (keyboard[SWORD_KEY] && !old_keyboard[SWORD_KEY]) {
				passage_state=3;
			} /* if */ 
		} /* if */ 
		if (passage_state==3) {
			tile_print("SEE YOU AGAIN",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
		} /* if */ 

	} /* if */ 

	if (map==0 && map_x==8 && map_y==15) {
		int price[3]={20,30,20};

		/* ARES */ 
		tile_print("ARES",TILE_SIZE_X*18,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[153]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		if (passage_state==0) {
			tile_print("YOU CAN BUY SOME OF",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("MY TREASURE",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} else {
			tile_print("COINS ARE NOT",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("ENOUGH.",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} /* if */ 
		if (shop_item[0]) {
			tiles[arrow_tile]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[1]) {
			tiles[items_tile+30]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[2]) {
			tiles[armas_tile+4]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+8*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		tile_print("   20    30    20",TILE_SIZE_X*10,TILE_SIZE_Y*13,screen,dx,dy);

		if (currently_selecting==0) {
			tiles[152]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==1) {
			tiles[152]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==2) {
			tiles[152]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 

		if (keyboard[RIGHT_KEY] && !old_keyboard[RIGHT_KEY]) {
			passage_state=0;
			if (currently_selecting<2) {
				currently_selecting++;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[LEFT_KEY] && !old_keyboard[LEFT_KEY]) {
			passage_state=0;
			if (currently_selecting>0) {
				currently_selecting--;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[SWORD_KEY] && !old_keyboard[SWORD_KEY]) {
			passage_state=0;
			if (n_coins>=price[currently_selecting] && shop_item[currently_selecting]) {
				/* Comprar objeto: */ 
				n_coins-=price[currently_selecting];
				shop_item[currently_selecting]=false;
				switch(currently_selecting) {
				case 0:n_arrows+=50;
					break;
				case 1:item[30]=true;
					   item[31]=false;
					   item[27]=false;
					break;
				case 2:item[36]=true;
					break;
				} /* if */ 
				Sound_play(S_item);
			} else {
				if (shop_item[currently_selecting] && n_coins<price[currently_selecting]) {
					Sound_play(S_nocoins);
					passage_state=1;
				} /* if */ 
			} /* if */ 
			
		} /* if */ 

	} /* if */ 

	if (map==0 && map_x==0 && map_y==13) {
		int price[3]={30,5,20};

		/* HEPHAESTUS */ 
		tile_print("HEPHAESTUS",TILE_SIZE_X*15,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[153]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		if (passage_state==0) {
			tile_print("YOU CAN BUY SOME OF",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("MY TREASURE",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} else {
			tile_print("COINS ARE NOT",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("ENOUGH.",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} /* if */ 
		if (shop_item[0]) {
			tiles[armas_tile+5]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+8*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[1]) {
			tiles[arrow_tile+1]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[2]) {
			tiles[arrow_tile]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		tile_print("   30    05    20",TILE_SIZE_X*10,TILE_SIZE_Y*13,screen,dx,dy);

		if (currently_selecting==0) {
			tiles[152]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==1) {
			tiles[152]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==2) {
			tiles[152]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 

		if (keyboard[RIGHT_KEY] && !old_keyboard[RIGHT_KEY]) {
			passage_state=0;
			if (currently_selecting<2) {
				currently_selecting++;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[LEFT_KEY] && !old_keyboard[LEFT_KEY]) {
			passage_state=0;
			if (currently_selecting>0) {
				currently_selecting--;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[SWORD_KEY] && !old_keyboard[SWORD_KEY]) {
			passage_state=0;
			if (n_coins>=price[currently_selecting] && shop_item[currently_selecting]) {
				/* Comprar objeto: */ 
				n_coins-=price[currently_selecting];
				shop_item[currently_selecting]=false;
				switch(currently_selecting) {
				case 0:item[37]=true;
					break;
				case 1:n_keys+=2;
					break;
				case 2:n_arrows+=50;
					break;
				} /* if */ 
				Sound_play(S_item);
			} else {
				if (shop_item[currently_selecting] && n_coins<price[currently_selecting]) {
					Sound_play(S_nocoins);
					passage_state=1;
				} /* if */ 
			} /* if */ 
		} /* if */ 

	} /* if */ 


	if (map==0 && map_x==11 && map_y==10) {
		/* DEATH */ 
		tile_print("DEATH",TILE_SIZE_X*18,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[167]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		if ((live_character[0] || !can_revive_character[0]) && 
			(live_character[1] || !can_revive_character[1]) && passage_state==0) {
			tile_print("IF YOUR LOVER IS",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("KILLED,COME BACK",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
			tile_print("HERE WITH abc100,",TILE_SIZE_X*10,TILE_SIZE_Y*11,screen,dx,dy);
			tile_print("dec100, AND fgc20.",TILE_SIZE_X*10,TILE_SIZE_Y*12,screen,dx,dy);
		} else {
			if (passage_state==0) {
				tile_print("GIVE ME abc100,",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
				tile_print("dec100 AND fgc20 IN",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
				tile_print("RETURN FOR REVIVING",TILE_SIZE_X*10,TILE_SIZE_Y*11,screen,dx,dy);
				tile_print("YOUR LOVER.",TILE_SIZE_X*10,TILE_SIZE_Y*12,screen,dx,dy);
				tile_print("   YES       NO",TILE_SIZE_X*10,TILE_SIZE_Y*13,screen,dx,dy);
				if (currently_selecting==0) {
					tiles[152]->
						draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
							TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
				} /* if */ 
				if (currently_selecting==1) {
					tiles[152]->
						draw(GAME_VIEW_X+20 *TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
							TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
				} /* if */ 
				if (keyboard[RIGHT_KEY] && !old_keyboard[RIGHT_KEY]) {
					if (currently_selecting<1) {
						currently_selecting++;
						Sound_play(S_select);
					} /* if */ 
				} /* if */ 
				if (keyboard[LEFT_KEY] && !old_keyboard[LEFT_KEY]) {
					if (currently_selecting>0) {
						currently_selecting--;
						Sound_play(S_select);
					} /* if */ 
				} /* if */ 
				if (keyboard[SWORD_KEY] && !old_keyboard[SWORD_KEY]) {
					if (currently_selecting==0 && n_arrows>=100 && n_coins>=100 && n_keys>=20) {
						n_arrows-=100;
						n_coins-=100;
						n_keys-=20;
						can_revive_character[1-character]=false;
						live_character[0]=live_character[1]=true;
						player_energy[1-character]=player_max[1-character];
						passage_state=2;
					} /* if */ 
					if (currently_selecting==1) passage_state=1;
					keyboard[SWORD_KEY]=false;
				} /* if */ 
			} /* if */ 

			if (passage_state==1) {
				tile_print("THEN,YOU MUST FIGHT",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
				tile_print("ALL BY YOURSELF",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
				tile_print("GO,RIGHT NOW.",TILE_SIZE_X*10,TILE_SIZE_Y*11,screen,dx,dy);
			} /* if */ 

			if (passage_state==2) {
				tile_print("YOUR LOVER HAS",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
				tile_print("REVIVED, GO AND GET",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
				tile_print("BACK THE LITTLE BABY",TILE_SIZE_X*10,TILE_SIZE_Y*11,screen,dx,dy);
				tile_print("TOGETHER. GO AHEAD!",TILE_SIZE_X*10,TILE_SIZE_Y*12,screen,dx,dy);
			} /* if */ 
		} /* if */ 	
	} /* if */ 


	if (map==0 && map_x==9 && map_y==7) {
		int price[3]={20,25,5};

		/* HEPHAESTUS */ 
		tile_print("HEPHAESTUS",TILE_SIZE_X*15,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[153]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		if (passage_state==0) {
			tile_print("YOU CAN BUY SOME OF",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("MY TREASURE",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} else {
			tile_print("COINS ARE NOT",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("ENOUGH.",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} /* if */ 
		if (shop_item[0]) {
			tiles[arrow_tile]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[1]) {
			tiles[items_tile+22]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[2]) {
			tiles[key_tile]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		tile_print("   20    25    05",TILE_SIZE_X*10,TILE_SIZE_Y*13,screen,dx,dy);

		if (currently_selecting==0) {
			tiles[152]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==1) {
			tiles[152]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==2) {
			tiles[152]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 

		if (keyboard[RIGHT_KEY] && !old_keyboard[RIGHT_KEY]) {
			passage_state=0;
			if (currently_selecting<2) {
				currently_selecting++;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[LEFT_KEY] && !old_keyboard[LEFT_KEY]) {
			passage_state=0;
			if (currently_selecting>0) {
				currently_selecting--;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[SWORD_KEY] && !old_keyboard[SWORD_KEY]) {
			passage_state=0;
			if (n_coins>=price[currently_selecting] && shop_item[currently_selecting]) {
				/* Comprar objeto: */ 
				n_coins-=price[currently_selecting];
				shop_item[currently_selecting]=false;
				switch(currently_selecting) {
				case 0:n_arrows+=50;
					break;
				case 1:item[22]=true;
					break;
				case 2:n_keys+=2;
					break;
				} /* if */ 
				Sound_play(S_item);
			} else {
				if (shop_item[currently_selecting] && n_coins<price[currently_selecting]) {
					Sound_play(S_nocoins);
					passage_state=1;
				} /* if */ 
			} /* if */ 
			 
		} /* if */ 

	} /* if */ 


	if (map==0 && map_x==12 && map_y==2) {
		int price[3]={20,50,5};

		/* ARES */ 
		tile_print("ARES",TILE_SIZE_X*18,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[153]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		if (passage_state==0) {
			tile_print("YOU CAN BUY SOME OF",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("MY TREASURE",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} else {
			tile_print("COINS ARE NOT",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("ENOUGH.",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} /* if */ 
		if (shop_item[0]) {
			tiles[arrow_tile]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[1]) {
			tiles[items_tile+12]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[2]) {
			tiles[key_tile]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		tile_print("   20    50    05",TILE_SIZE_X*10,TILE_SIZE_Y*13,screen,dx,dy);

		if (currently_selecting==0) {
			tiles[152]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==1) {
			tiles[152]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==2) {
			tiles[152]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 

		if (keyboard[RIGHT_KEY] && !old_keyboard[RIGHT_KEY]) {
			passage_state=0;
			if (currently_selecting<2) {
				currently_selecting++;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[LEFT_KEY] && !old_keyboard[LEFT_KEY]) {
			passage_state=0;
			if (currently_selecting>0) {
				currently_selecting--;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[SWORD_KEY] && !old_keyboard[SWORD_KEY]) {
			passage_state=0;
			if (n_coins>=price[currently_selecting] && shop_item[currently_selecting]) {
				/* Comprar objeto: */ 
				n_coins-=price[currently_selecting];
				shop_item[currently_selecting]=false;
				switch(currently_selecting) {
				case 0:n_arrows+=50;
					break;
				case 1:item[12]=true;
					break;
				case 2:n_keys+=2;
					break;
				} /* if */ 
				Sound_play(S_item);
			} else {
				if (shop_item[currently_selecting] && n_coins<price[currently_selecting]) {
					Sound_play(S_nocoins);
					passage_state=1;
				} /* if */ 
			} /* if */ 
			
		} /* if */ 

	} /* if */ 


	if (map==0 && map_x==2 && map_y==2) {
		int price[3]={30,20,5};

		/* HEPHAESTUS */ 
		tile_print("HEPHAESTUS",TILE_SIZE_X*15,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[153]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		if (passage_state==0) {
			tile_print("YOU CAN BUY SOME OF",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("MY TREASURE",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} else {
			tile_print("COINS ARE NOT",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("ENOUGH.",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} /* if */ 
		if (shop_item[0]) {
			tiles[items_tile+20]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[1]) {
			tiles[arrow_tile]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[2]) {
			tiles[key_tile]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		tile_print("   30    20    05",TILE_SIZE_X*10,TILE_SIZE_Y*13,screen,dx,dy);

		if (currently_selecting==0) {
			tiles[152]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==1) {
			tiles[152]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==2) {
			tiles[152]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 

 
		if (keyboard[RIGHT_KEY] && !old_keyboard[RIGHT_KEY]) {
			passage_state=0;
			if (currently_selecting<2) {
				currently_selecting++;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[LEFT_KEY] && !old_keyboard[LEFT_KEY]) {
			passage_state=0;
			if (currently_selecting>0) {
				currently_selecting--;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[SWORD_KEY] && !old_keyboard[SWORD_KEY]) {
			passage_state=0;
			if (n_coins>=price[currently_selecting] && shop_item[currently_selecting]) {
				/* Comprar objeto: */ 
				n_coins-=price[currently_selecting];
				shop_item[currently_selecting]=false;
				switch(currently_selecting) {
				case 0:item[20]=true;
					break;
				case 1:n_arrows+=50;
					break;
				case 2:n_keys+=2;
					break;
				} /* if */ 
				Sound_play(S_item);
			} else {
				if (shop_item[currently_selecting] && n_coins<price[currently_selecting]) {
					Sound_play(S_nocoins);
					passage_state=1;
				} /* if */ 
			} /* if */ 
		
		} /* if */ 
	} /* if */ 


	if (map==0 && map_x==2 && map_y==5) {
		int price[3]={20,25,5};

		/* DETEMETER */ 
		tile_print("DEMETER",TILE_SIZE_X*17,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[154]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		if (passage_state==0) {
			tile_print("YOU CAN BUY SOME OF",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("MY TREASURE",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} else {
			tile_print("COINS ARE NOT",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("ENOUGH.",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} /* if */ 
		if (shop_item[0]) {
			tiles[arrow_tile]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[1]) {
			tiles[items_tile]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[2]) {
			tiles[key_tile]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		tile_print("   20    25    05",TILE_SIZE_X*10,TILE_SIZE_Y*13,screen,dx,dy);

		if (currently_selecting==0) {
			tiles[152]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==1) {
			tiles[152]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==2) {
			tiles[152]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 

		if (keyboard[RIGHT_KEY] && !old_keyboard[RIGHT_KEY]) {
			passage_state=0;
			if (currently_selecting<2) {
				currently_selecting++;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[LEFT_KEY] && !old_keyboard[LEFT_KEY]) {
			passage_state=0;
			if (currently_selecting>0) {
				currently_selecting--;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[SWORD_KEY] && !old_keyboard[SWORD_KEY]) {
			passage_state=0;
			if (n_coins>=price[currently_selecting] && shop_item[currently_selecting]) {
				/* Comprar objeto: */ 
				n_coins-=price[currently_selecting];
				shop_item[currently_selecting]=false;
				switch(currently_selecting) {
				case 0:n_arrows+=50;
					break;
				case 1:item[0]=true;
					break;
				case 2:n_keys+=2;
					break;
				} /* if */ 
				Sound_play(S_item);
			} else {
				if (shop_item[currently_selecting] && n_coins<price[currently_selecting]) {
					Sound_play(S_nocoins);
					passage_state=1;
				} /* if */ 
			} /* if */  

		} /* if */ 

	} /* if */ 


	if (map==0 && map_x==12 && map_y==8) {
		int price[3]={20,40,5};

		/* ARES */ 
		tile_print("ARES",TILE_SIZE_X*18,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[153]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		if (passage_state==0) {
			tile_print("YOU CAN BUY SOME OF",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("MY TREASURE",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} else {
			tile_print("COINS ARE NOT",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("ENOUGH.",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} /* if */ 
		if (shop_item[0]) {
			tiles[arrow_tile]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[1]) {
			tiles[items_tile+31]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[2]) {
			tiles[key_tile]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		tile_print("   20    40    05",TILE_SIZE_X*10,TILE_SIZE_Y*13,screen,dx,dy);

		if (currently_selecting==0) {
			tiles[152]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==1) {
			tiles[152]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==2) {
			tiles[152]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 


		if (keyboard[RIGHT_KEY] && !old_keyboard[RIGHT_KEY]) {
			passage_state=0;
			if (currently_selecting<2) {
				currently_selecting++;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[LEFT_KEY] && !old_keyboard[LEFT_KEY]) {
			passage_state=0;
			if (currently_selecting>0) {
				currently_selecting--;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[SWORD_KEY] && !old_keyboard[SWORD_KEY]) {
			passage_state=0;
			if (n_coins>=price[currently_selecting] && shop_item[currently_selecting]) {
				/* Comprar objeto: */ 
				n_coins-=price[currently_selecting];
				shop_item[currently_selecting]=false;
				switch(currently_selecting) {
				case 0:n_arrows+=50;
					break;
				case 1: item[27]=false;
						item[30]=false;
						item[31]=true;
					break;
				case 2:n_keys+=2;
					break;
				} /* if */ 
				Sound_play(S_item);
			} else {
				if (shop_item[currently_selecting] && n_coins<price[currently_selecting]) {
					Sound_play(S_nocoins);
					passage_state=1;
				} /* if */ 
			} /* if */ 

		} /* if */ 

	} /* if */ 


	if (map==0 && map_x==8 && map_y==1) {
		int price[3]={20,50,5};

		/* ARES */ 
		tile_print("ARES",TILE_SIZE_X*18,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[153]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		if (passage_state==0) {
			tile_print("YOU CAN BUY SOME OF",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("MY TREASURE",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} else {
			tile_print("COINS ARE NOT",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("ENOUGH.",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} /* if */ 
		if (shop_item[0]) {
			tiles[arrow_tile]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[1]) {
			tiles[items_tile+27]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (shop_item[2]) {
			tiles[key_tile]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		tile_print("   20    50    05",TILE_SIZE_X*10,TILE_SIZE_Y*13,screen,dx,dy);

		if (currently_selecting==0) {
			tiles[152]->
				draw(GAME_VIEW_X+9*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==1) {
			tiles[152]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 
		if (currently_selecting==2) {
			tiles[152]->
				draw(GAME_VIEW_X+21*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 


		if (keyboard[RIGHT_KEY] && !old_keyboard[RIGHT_KEY]) {
			passage_state=0;
			if (currently_selecting<2) {
				currently_selecting++;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[LEFT_KEY] && !old_keyboard[LEFT_KEY]) {
			passage_state=0;
			if (currently_selecting>0) {
				currently_selecting--;
				Sound_play(S_select);
			} /* if */ 
		} /* if */ 
		if (keyboard[SWORD_KEY] && !old_keyboard[SWORD_KEY]) {
			passage_state=0;
			if (n_coins>=price[currently_selecting] && shop_item[currently_selecting]) {
				/* Comprar objeto: */ 
				n_coins-=price[currently_selecting];
				shop_item[currently_selecting]=false;
				switch(currently_selecting) {
				case 0:n_arrows+=50;
					break;
				case 1: item[27]=true;
						item[30]=false;
						item[31]=false;
					break;
				case 2:n_keys+=2;
					break;
				} /* if */ 
				Sound_play(S_item);
			} else {
				if (shop_item[currently_selecting] && n_coins<price[currently_selecting]) {
					Sound_play(S_nocoins);
					passage_state=1;
				} /* if */ 
			} /* if */ 

		} /* if */ 

	} /* if */ 


	if (map==0 && map_x==7 && map_y==7) {
		/* ASCLEPIUS */ 
		tile_print("ASCLEPIUS",TILE_SIZE_X*16,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[178]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		tile_print("SEE A FAIRY TO",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
		tile_print("RESTORE YOUR",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		tile_print("VITALITY.",TILE_SIZE_X*10,TILE_SIZE_Y*11,screen,dx,dy);
	} /* if */ 

	if (map==1) {
		/* DEMETER en el mundo 1 */ 
		tile_print("DEMETER",TILE_SIZE_X*17,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[154]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		tile_print("TAKE A MINE WITH YOU",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
		tile_print("WHEN YOU GO TO",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		tile_print("WORLD 4",TILE_SIZE_X*10,TILE_SIZE_Y*11,screen,dx,dy);
	} /* if */ 

	if (map==2) {
		/* ATHENA en el mundo 2 */ 
		tile_print("ATHENA",TILE_SIZE_X*17,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[161]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		tile_print("HIT THE WALL WITH",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
		tile_print("YOUR SWORD IF YOU",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		tile_print("WANT TO GO TO THE",TILE_SIZE_X*10,TILE_SIZE_Y*11,screen,dx,dy);
		tile_print("OPPOSITE SHORE.",TILE_SIZE_X*10,TILE_SIZE_Y*12,screen,dx,dy);
	} /* if */ 

	if (map==3) {
		/* ATHENA en el mundo 3 */ 
		tile_print("ATHENA",TILE_SIZE_X*17,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[161]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		tile_print("APHRODITE.DO NOT BE",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
		tile_print("AFRAID OF WATER.",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
	} /* if */ 

	if (map==4) {
		/* DEMETER en el mundo 4 */ 
		tile_print("DEMETER",TILE_SIZE_X*17,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[154]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		tile_print("THE PURE WATER IS",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
		tile_print("INSIDE THE WALL.",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
	} /* if */ 

	if (map==5) {
		int price[1]={30};

		/* DETEMETER */ 
		tile_print("DEMETER",TILE_SIZE_X*17,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[154]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		if (passage_state==0) {
			tile_print("YOU CAN BUY SOME OF",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("MY TREASURE",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} else {
			tile_print("COINS ARE NOT",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("ENOUGH.",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} /* if */ 
		if (shop_item[0]) {
			tiles[items_tile+3]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		tile_print("         30",TILE_SIZE_X*10,TILE_SIZE_Y*13,screen,dx,dy);

		if (currently_selecting==0) {
			tiles[152]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 

		if (keyboard[SWORD_KEY] && !old_keyboard[SWORD_KEY]) {
			passage_state=0;
			if (n_coins>=price[currently_selecting] && shop_item[currently_selecting]) {
				/* Comprar objeto: */ 
				n_coins-=price[currently_selecting];
				shop_item[currently_selecting]=false;
				item[3]=true;
				Sound_play(S_item);
			} else {
				if (shop_item[currently_selecting] && n_coins<price[currently_selecting]) {
					Sound_play(S_nocoins);
					passage_state=1;
				} /* if */ 
			} /* if */  

		} /* if */ 

	} /* if */ 

	if (map==6) {
		/* ATHENA en el mundo 6 */ 
		tile_print("ATHENA",TILE_SIZE_X*17,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[161]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		tile_print("HIT THE WALL WHEN",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
		tile_print("YOU ARE HALFWAY OF",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		tile_print("THE STAIRS.",TILE_SIZE_X*10,TILE_SIZE_Y*11,screen,dx,dy);
	} /* if */ 

	if (map==7) {
		/* DEMETER en el mundo 7 */ 
		tile_print("DEMETER",TILE_SIZE_X*17,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[154]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		tile_print("FIND THE SPELL",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
		tile_print("WRITTEN ON A STONE",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		tile_print("MONUMENT UNDER THE",TILE_SIZE_X*10,TILE_SIZE_Y*11,screen,dx,dy);
		tile_print("WATER.",TILE_SIZE_X*10,TILE_SIZE_Y*12,screen,dx,dy);
	} /* if */ 

	if (map==8) {
		int price[1]={30};

		/* DETEMETER */ 
		tile_print("DEMETER",TILE_SIZE_X*17,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[154]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		if (passage_state==0) {
			tile_print("YOU CAN BUY SOME OF",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("MY TREASURE",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} else {
			tile_print("COINS ARE NOT",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
			tile_print("ENOUGH.",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		} /* if */ 
		if (shop_item[0]) {
			tiles[items_tile+11]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+7*TILE_SIZE_Y,
					 screen,col_buffer,dx,dy,dx);
		} /* if */ 
		tile_print("         30",TILE_SIZE_X*10,TILE_SIZE_Y*13,screen,dx,dy);

		if (currently_selecting==0) {
			tiles[152]->
				draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+12*TILE_SIZE_Y,
					TILE_SIZE_X,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);
		} /* if */ 

		if (keyboard[SWORD_KEY] && !old_keyboard[SWORD_KEY]) {
			passage_state=0;
			if (n_coins>=price[currently_selecting] && shop_item[currently_selecting]) {
				/* Comprar objeto: */ 
				n_coins-=price[currently_selecting];
				shop_item[currently_selecting]=false;
				item[11]=true;
				Sound_play(S_item);
			} else {
				if (shop_item[currently_selecting] && n_coins<price[currently_selecting]) {
					Sound_play(S_nocoins);
					passage_state=1;
				} /* if */ 
			} /* if */  

		} /* if */ 

	} /* if */ 


	if (map==9) {
		/* DEMETER en el mundo 9 */ 
		tile_print("DEMETER",TILE_SIZE_X*17,TILE_SIZE_Y*5,screen,dx,dy);
		tiles[154]->
			draw(GAME_VIEW_X+15*TILE_SIZE_X,GAME_VIEW_Y+2*TILE_SIZE_Y,
					TILE_SIZE_X*2,TILE_SIZE_Y*2,screen,col_buffer,dx,dy,dx);

		tile_print("A GATE WHICH LEADS",TILE_SIZE_X*10,TILE_SIZE_Y*9,screen,dx,dy);
		tile_print("TO GALIOUS WILL",TILE_SIZE_X*10,TILE_SIZE_Y*10,screen,dx,dy);
		tile_print("APPEAR SOMEWHERE IN",TILE_SIZE_X*10,TILE_SIZE_Y*11,screen,dx,dy);
		tile_print("THE CASTLE.",TILE_SIZE_X*10,TILE_SIZE_Y*12,screen,dx,dy);
	} /* if */ 

} /* passage_mainloop */ 
Beispiel #15
0
int F1SpiritApp::gameoptions_cycle(KEYBOARDSTATE *k)
{
	if (state_cycle == 0) {

		menu_fading = -1;
		menu_fading_ctnt = MENU_CONSTANT;
		menu_current_menu = 5;

		/* ... */

	} 

	if (menu_fading == 0) {} else {
		if (menu_fading > 0)
			menu_fading_ctnt++;
		else
			menu_fading_ctnt--;

		if (menu_fading_ctnt <= 0 && menu_fading == -1) {
			menu_fading = 0;
		} 

		if (menu_fading_ctnt >= MENU_CONSTANT && menu_fading == 1) {
			menu_fading = 0;
			race_game->race_state = 3;
			race_game->race_state_timmer = 0;
			race_desired_action = 0;
			Sound_unpause_music();
			race_game->resumeSFX();
			race_game->rain_channel = 0;
			return APP_STATE_RACE;
		} 

		if (menu_fading_ctnt >= MENU_CONSTANT && menu_fading == 2) {
			menu_fading = 0;
			Sound_unpause_music();
			race_game->resumeSFX();
			race_game->rain_channel = 0;
			return APP_STATE_RACE;
		} 

		if (menu_fading_ctnt >= MENU_CONSTANT && menu_fading == 3) {
			menu_fading = 0;
			race_game->race_state = 3;
			race_game->race_state_timmer = 0;
			race_desired_action = 1;
			Sound_unpause_music();
			race_game->resumeSFX();
			race_game->rain_channel = 0;
			return APP_STATE_RACE;
		} 
	} 

	if (state_cycle == 0 || menu_state == MENU_CONSTANT*2 || menu_redefining_key || menu_force_rebuild_menu) {
		int browsing = 0;

		if (menu_options[1] != 0)
			browsing = 1;

		if (state_cycle != 0) {

#ifdef F1SPIRIT_DEBUG_MESSAGES
			output_debug_message("Executing gameoptions action: %i(%i)\n", menu_option_type[browsing][menu_selected[browsing]], menu_option_parameter[browsing][menu_selected[browsing]]);
#endif

			switch (menu_option_type[browsing][menu_selected[browsing]]) {

				case 0:  /* QUIT RACE: */
					menu_fading = 1;
					menu_fading_ctnt = 0;
					break;

				case 1:  /* MENU CHANGE: */
					menu_current_menu = menu_option_parameter[browsing][menu_selected[browsing]];

					if (menu_current_menu == 23) {
						menu_readme_start_y = 0;
						menu_readme_move_y = 0;
					} 

					break;

				case 7:  /* SET A KEY: */
					break;

				case 8:  /* SET A JOYSTICK: */
					menu_current_menu = menu_option_parameter[browsing][menu_selected[browsing]];

					{
						int i;
						FILE *fp;
						PlayerCCar *v;
						current_player->set_joystick(menu_selected[0] - 7, menu_selected[1] - 1);
						i = menu_selected[0] - 7;
						v = race_game->player_cars[i];

						if (menu_selected[1] - 1 == -1) {
							v->up = current_player->get_key(i, 0);
							v->down = current_player->get_key(i, 1);
							v->left = current_player->get_key(i, 2);
							v->right = current_player->get_key(i, 3);
							v->accelerate = current_player->get_key(i, 4);
							v->brake = current_player->get_key(i, 5);
						} else {
							int j = menu_selected[1] - 1;
							v->up = k->joystick_0_pos + j * k->joystick_size + 2;
							v->down = k->joystick_0_pos + j * k->joystick_size + 3;
							v->left = k->joystick_0_pos + j * k->joystick_size;
							v->right = k->joystick_0_pos + j * k->joystick_size + 1;
							v->accelerate = k->joystick_0_pos + j * k->joystick_size + 4;
							v->brake = k->joystick_0_pos + j * k->joystick_size + 5;
						} 

						if (v->up < 0)
							v->up = 0;

						if (v->up >= k->k_size)
							v->up = 0;

						if (v->down < 0)
							v->down = 0;

						if (v->down >= k->k_size)
							v->down = 0;

						if (v->left < 0)
							v->left = 0;

						if (v->left >= k->k_size)
							v->left = 0;

						if (v->up < 0)
							v->up = 0;

						if (v->right >= k->k_size)
							v->right = 0;

						if (v->up < 0)
							v->up = 0;

						if (v->accelerate >= k->k_size)
							v->accelerate = 0;

						if (v->up < 0)
							v->up = 0;

						if (v->brake >= k->k_size)
							v->brake = 0;

						v = 0;

						fp = f1open(player_filename, "wb", USERDATA);

						if (fp != 0) {
							current_player->save(fp);
							fclose(fp);
						} 
					}

					break;

				case 11:  /* MENU CHANGE TO SUBMENU: */
					menu_current_menu = menu_option_parameter[browsing][menu_selected[browsing]];
					break;

				case 13: { /* CONTINUE RACE: */
						menu_selecting_player++;
						menu_fading = 2;
						menu_fading_ctnt = 0;
					}

					break;

				case 15: { /* CHANGE MUSIC VOLUME: */
					}

					break;

				case 16: { /* CHANGE SFX VOLUME: */
					}

					break;

				case 24: { /* RESTART RACE: */
						menu_selecting_player++;
						menu_fading = 3;
						menu_fading_ctnt = 0;

						// also stop music/sfx on restart
						Mix_HaltChannel(SFX_RAIN);
						Sound_pause_music();
					}

					break;

			} 
		} 

		delete []menu_title[0];

		menu_title[0] = 0;

		delete []menu_options[0];

		menu_options[0] = 0;

		delete []menu_title[1];

		menu_title[1] = 0;

		delete []menu_options[1];

		menu_options[1] = 0;

#ifdef F1SPIRIT_DEBUG_MESSAGES

		output_debug_message("Generating a new gameoptions menu: %i\n", menu_current_menu);

#endif

		switch (menu_current_menu) {

			case 5:

			case 6:

			case 7:

			case 8:

			case 19:

			case 20:

			case 22:

			case 24: {
					int i, l, pos;
					char *volumes[5] = {"NONE", "LOW ", "MED.", "HIGH", "MAX."};

					l = strlen("PLAYER 000\n") * current_player->get_nplayers() + strlen("CONTINUE\nQUIT\nRESTART\n\nMUSIC VOL: MAX.\nSFX VOL: MAX.\nPLAYER 1\nPLAYER 2\nPLAYER 3\nPLAYER 4\n") + 1;
					if (arcade)
						l = strlen("CONTINUE\nQUIT\n\nMUSIC VOL: MAX.\nSFX VOL: MAX.\nPLAYER 1\n")+1;
					menu_options[0] = new char[l];
					pos = 0;
					{
						int v1 = 0, v2 = 0;
						v1 = current_player->get_music_volume() / 32;
						v2 = current_player->get_sfx_volume() / 32;

						if (arcade)
							sprintf(menu_options[0], "CONTINUE\nQUIT\n\nMUSIC VOL: %s\nSFX VOL: %s\n", volumes[v1], volumes[v2]);
						else
							sprintf(menu_options[0], "CONTINUE\nQUIT\nRESTART\n\nMUSIC VOL: %s\nSFX VOL: %s\n", volumes[v1], volumes[v2]);
					}

					pos = strlen(menu_options[0]);

					if(arcade) {
						for (i = 0;i < 1;i++) {
							sprintf(menu_options[0] + pos, "PLAYER %i\n", i + 1);
							pos = strlen(menu_options[0]);
						} 
					} else 
					{
						for (i = 0;i < current_player->get_nplayers();i++) {
							sprintf(menu_options[0] + pos, "PLAYER %i\n", i + 1);
							pos = strlen(menu_options[0]);
						} 
					}

					menu_title[0] = new char[strlen("PAUSE") + 1];

					strcpy(menu_title[0], "PAUSE");

					if (arcade)
						menu_noptions[0] = 5+1;
					else
						menu_noptions[0] = current_player->get_nplayers() + 7;

					menu_option_type[0][0] = 13;
					menu_option_type[0][1] = 0;

					if (arcade) {
						menu_option_type[0][2] = -1;
						menu_option_type[0][3] = 15;
						menu_option_type[0][4] = 16;
						menu_option_type[0][5] = 11;
						menu_option_parameter[0][5] = 22;
					} else 
					{
						menu_option_type[0][2] = 24;
						menu_option_type[0][3] = -1;
						menu_option_type[0][4] = 15;
						menu_option_type[0][5] = 16;
						menu_option_type[0][6] = 11;
						menu_option_parameter[0][6] = 22;

						for (i = 0;i < current_player->get_nplayers();i++) {
							menu_option_type[0][i + 7] = 11;
							menu_option_parameter[0][i + 7] = 22;
						} 
					}

					menu_first_option[0] = 0;
				}

				if (menu_current_menu == 22) {
					menu_title[1] = 0;
					menu_options[1] = new char[strlen("KEYBOARD CFG.\nJOYSTICK/KEYS\nBACK\n") + 1];
					strcpy(menu_options[1], "KEYBOARD CFG.\nJOYSTICK/KEYS\nBACK\n");
					menu_noptions[1] = 3;
					menu_option_type[1][0] = 1;
					menu_option_type[1][1] = 1;
					menu_option_type[1][2] = 1;
					menu_option_parameter[1][0] = 7;
					menu_option_parameter[1][1] = 8;
					menu_option_parameter[1][2] = 5;
					menu_first_option[1] = 0;
				} 

				if (menu_current_menu == 7) {
					char tmp[256];
					menu_title[1] = 0;
					sprintf(tmp, "GEAR UP: %s\nGEAR DOWN: %s\nLEFT: %s\nRIGHT: %s\nACCEL.: %s\nBRAKE: %s\nBACK\n",
					        SDL_GetKeyName(SDLKey(current_player->get_key(menu_selected[0] - 6, 0))),
					        SDL_GetKeyName(SDLKey(current_player->get_key(menu_selected[0] - 6, 1))),
					        SDL_GetKeyName(SDLKey(current_player->get_key(menu_selected[0] - 6, 2))),
					        SDL_GetKeyName(SDLKey(current_player->get_key(menu_selected[0] - 6, 3))),
					        SDL_GetKeyName(SDLKey(current_player->get_key(menu_selected[0] - 6, 4))),
					        SDL_GetKeyName(SDLKey(current_player->get_key(menu_selected[0] - 6, 5))));
					//    strupr(tmp);
					menu_options[1] = new char[strlen(tmp) + 1];
					strcpy(menu_options[1], tmp);
					menu_noptions[1] = 7;
					menu_option_type[1][0] = 7;
					menu_option_type[1][1] = 7;
					menu_option_type[1][2] = 7;
					menu_option_type[1][3] = 7;
					menu_option_type[1][4] = 7;
					menu_option_type[1][5] = 7;
					menu_option_type[1][6] = 1;
					menu_option_parameter[1][0] = 7;
					menu_option_parameter[1][1] = 7;
					menu_option_parameter[1][2] = 7;
					menu_option_parameter[1][3] = 7;
					menu_option_parameter[1][4] = 7;
					menu_option_parameter[1][5] = 7;
					menu_option_parameter[1][6] = 6;
					menu_first_option[1] = 0;

					if (current_player->get_joystick(menu_selected[0]) != -1) {
						current_player->set_joystick(menu_selected[0], -1);
						{
							FILE *fp;

							fp = f1open(player_filename, "wb", USERDATA);

							if (fp != 0) {
								current_player->save(fp);
								fclose(fp);
							} 
						}
					} 
				} 

				if (menu_current_menu == 8) {
					int nj = SDL_NumJoysticks();
					int i, pos;

					menu_options[1] = new char[nj * strlen("JOYSTICK 000\n") + strlen("KEYBOARD\nBACK\n") + 1];
					pos = 0;
					sprintf(menu_options[1] + pos, "KEYBOARD\n");
					pos = strlen(menu_options[1]);

					for (i = 0;i < nj;i++) {
						sprintf(menu_options[1] + pos, "JOYSTICK %i\n", i);
						pos = strlen(menu_options[1]);
					} 

					sprintf(menu_options[1] + pos, "BACK\n");

					menu_noptions[1] = nj + 2;

					for (i = 0;i < nj + 1;i++) {
						menu_option_type[1][i] = 8;
						menu_option_parameter[1][i] = 6;
					} 

					menu_option_type[1][nj + 1] = 1;

					menu_option_parameter[1][nj + 1] = 6;

					menu_first_option[1] = 0;
				} 
		} 


		if ((menu_options[1] == 0 && menu_prev_nmenus != 2 && !menu_force_rebuild_menu)) {
			menu_selected[0] = 0;
			menu_selected_timmer[0] = 0;
		} 

		if (!menu_redefining_key && !menu_force_rebuild_menu)
			menu_selected[1] = 0;

		if (!menu_redefining_key && !menu_force_rebuild_menu)
			menu_selected_timmer[1] = 0;

		if (!menu_redefining_key && !menu_force_rebuild_menu)
			menu_state = 0;

		menu_force_rebuild_menu = false;
	} else {
		if (menu_fading == 0) {
			if (menu_state < MENU_CONSTANT)
				menu_state++;

			if (menu_state == MENU_CONSTANT) {
				menu_prev_nmenus = 0;

				if (menu_options[0] != 0)
					menu_prev_nmenus++;

				if (menu_options[1] != 0)
					menu_prev_nmenus++;
			} 

			if (menu_state > MENU_CONSTANT)
				menu_state++;
		} 
	} 


	if (menu_readme_move_y != 0) {
		menu_readme_start_y += menu_readme_move_y;

		if (menu_readme_move_y > 0)
			menu_readme_move_y--;

		if (menu_readme_move_y < 0)
			menu_readme_move_y++;

		if (menu_readme_start_y < 0)
			menu_readme_start_y = 0;
	} 

	if (menu_state == MENU_CONSTANT) {
		int browsing = 0;

		if (menu_options[1] != 0)
			browsing = 1;

		if (!menu_redefining_key) {
			if ((k->keyboard[SDLK_DOWN] && !k->old_keyboard[SDLK_DOWN]) ||
			        (k->keyboard[SDLK_RIGHT] && !k->old_keyboard[SDLK_RIGHT])) {
				if ((k->keyboard[SDLK_RIGHT] && !k->old_keyboard[SDLK_RIGHT]) &&
				        (menu_option_type[browsing][menu_selected[browsing]] == 15 ||
				         menu_option_type[browsing][menu_selected[browsing]] == 16)) {
					if (menu_option_type[browsing][menu_selected[browsing]] == 15) {
						int v = current_player->get_music_volume();

						if (v == 128)
							current_player->set_music_volume(0);

						if (v == 96)
							current_player->set_music_volume(128);

						if (v == 64)
							current_player->set_music_volume(96);

						if (v == 32)
							current_player->set_music_volume(64);

						if (v == 0)
							current_player->set_music_volume(32);
					} else {
						int v = current_player->get_sfx_volume();

						if (v == 128)
							current_player->set_sfx_volume(0);

						if (v == 96)
							current_player->set_sfx_volume(128);

						if (v == 64)
							current_player->set_sfx_volume(96);

						if (v == 32)
							current_player->set_sfx_volume(64);

						if (v == 0)
							current_player->set_sfx_volume(32);
					} 

					menu_force_rebuild_menu = true;

					Sound_play(S_menu_move, 128);

					{
						FILE *fp;

						fp = f1open(player_filename, "wb", USERDATA);

						if (fp != 0) {
							current_player->save(fp);
							fclose(fp);
						} 
					}
				} else {
					menu_selected[browsing]++;

					if (menu_option_type[browsing][menu_selected[browsing]] == -1)
						menu_selected[browsing]++;

					Sound_play(S_menu_move, 128);

					if (menu_selected[browsing] >= menu_noptions[browsing])
						menu_selected[browsing] -= menu_noptions[browsing];

					menu_selected_timmer[browsing] = 0;
				} 
			} 

			if ((k->keyboard[SDLK_UP] && !k->old_keyboard[SDLK_UP]) ||
			        (k->keyboard[SDLK_LEFT] && !k->old_keyboard[SDLK_LEFT])) {

				if ((k->keyboard[SDLK_LEFT] && !k->old_keyboard[SDLK_LEFT]) &&
				        (menu_option_type[browsing][menu_selected[browsing]] == 15 ||
				         menu_option_type[browsing][menu_selected[browsing]] == 16)) {
					if (menu_option_type[browsing][menu_selected[browsing]] == 15) {
						int v = current_player->get_music_volume();

						if (v == 128)
							current_player->set_music_volume(96);

						if (v == 96)
							current_player->set_music_volume(64);

						if (v == 64)
							current_player->set_music_volume(32);

						if (v == 32)
							current_player->set_music_volume(0);

						if (v == 0)
							current_player->set_music_volume(128);
					} else {
						int v = current_player->get_sfx_volume();

						if (v == 128)
							current_player->set_sfx_volume(96);

						if (v == 96)
							current_player->set_sfx_volume(64);

						if (v == 64)
							current_player->set_sfx_volume(32);

						if (v == 32)
							current_player->set_sfx_volume(0);

						if (v == 0)
							current_player->set_sfx_volume(128);
					} 

					menu_force_rebuild_menu = true;

					Sound_play(S_menu_move, 128);

					{
						FILE *fp;

						fp = f1open(player_filename, "wb", USERDATA);

						if (fp != 0) {
							current_player->save(fp);
							fclose(fp);
						} 
					}
				} else {
					menu_selected[browsing]--;

					if (menu_option_type[browsing][menu_selected[browsing]] == -1)
						menu_selected[browsing]--;

					Sound_play(S_menu_move, 128);

					if (menu_selected[browsing] < 0)
						menu_selected[browsing] += menu_noptions[browsing];

					menu_selected_timmer[browsing] = 0;
				} 
			} 

			if (k->keyboard[SDLK_ESCAPE] && !k->old_keyboard[SDLK_ESCAPE]) {
				if (menu_current_menu == 5)
					menu_selected[browsing] = 0;
				else
					menu_selected[browsing] = menu_noptions[browsing] - 1;

				Sound_play(S_menu_select, 128);

				menu_state++;
			} 

			if (menu_option_type[browsing][menu_selected[browsing]] != 2 &&
			        ((k->keyboard[SDLK_SPACE] && !k->old_keyboard[SDLK_SPACE])
#ifdef PANDORA
					||  (k->keyboard[SDLK_PAGEDOWN] && !k->old_keyboard[SDLK_PAGEDOWN])
#endif
				))
				{
				if (menu_option_type[browsing][menu_selected[browsing]] != 19 &&
				        menu_option_type[browsing][menu_selected[browsing]] != 20)
					Sound_play(S_menu_select, 128);

				if (menu_option_type[browsing][menu_selected[browsing]] == 7) {
					/* redefining a key: */
					menu_redefining_key = true;
				} else {
					if (menu_option_type[browsing][menu_selected[browsing]] == 15 ||
					        menu_option_type[browsing][menu_selected[browsing]] == 16 ||
					        menu_option_type[browsing][menu_selected[browsing]] == 19 ||
					        menu_option_type[browsing][menu_selected[browsing]] == 20) {
						if (menu_option_type[browsing][menu_selected[browsing]] == 15) {
							int v = current_player->get_music_volume();

							if (v == 128)
								current_player->set_music_volume(0);

							if (v == 96)
								current_player->set_music_volume(128);

							if (v == 64)
								current_player->set_music_volume(96);

							if (v == 32)
								current_player->set_music_volume(64);

							if (v == 0)
								current_player->set_music_volume(32);
						} 

						if (menu_option_type[browsing][menu_selected[browsing]] == 16) {
							int v = current_player->get_sfx_volume();

							if (v == 128)
								current_player->set_sfx_volume(0);

							if (v == 96)
								current_player->set_sfx_volume(128);

							if (v == 64)
								current_player->set_sfx_volume(96);

							if (v == 32)
								current_player->set_sfx_volume(64);

							if (v == 0)
								current_player->set_sfx_volume(32);
						} 

						menu_force_rebuild_menu = true;
					} else {
						menu_state++;
					} 
				} 
			} 


		} else {
			int i, np;
			np = menu_selected[0] - 6;
			PlayerCCar *v = race_game->player_cars[np];

			for (i = 0;i < SDLK_LAST;i++) {
				if (k->keyboard[i] && !k->old_keyboard[i]) {
					current_player->set_key(np, menu_selected[1], i);

					if (current_player->get_joystick(np) == -1) {
						v->up = current_player->get_key(np, 0);
						v->down = current_player->get_key(np, 1);
						v->left = current_player->get_key(np, 2);
						v->right = current_player->get_key(np, 3);
						v->accelerate = current_player->get_key(np, 4);
						v->brake = current_player->get_key(np, 5);
					} 

					if (v->up < 0)
						v->up = 0;

					if (v->up >= k->k_size)
						v->up = 0;

					if (v->down < 0)
						v->down = 0;

					if (v->down >= k->k_size)
						v->down = 0;

					if (v->left < 0)
						v->left = 0;

					if (v->left >= k->k_size)
						v->left = 0;

					if (v->up < 0)
						v->up = 0;

					if (v->right >= k->k_size)
						v->right = 0;

					if (v->up < 0)
						v->up = 0;

					if (v->accelerate >= k->k_size)
						v->accelerate = 0;

					if (v->up < 0)
						v->up = 0;

					if (v->brake >= k->k_size)
						v->brake = 0;

					v = 0;

					menu_redefining_key = false;

					menu_force_rebuild_menu = true;

					Sound_play(S_menu_select, 128);

					{
						FILE *fp;

						fp = f1open(player_filename, "wb", USERDATA);

						if (fp != 0) {
							current_player->save(fp);
							fclose(fp);
						} 
					}
				} 
			} 
		} 
	} 

	menu_selected_timmer[0]++;

	menu_selected_timmer[1]++;

	return APP_STATE_GAMEOPTIONS;
}