示例#1
0
int  progress_play(struct level *l)
{
    if (l && (level_opened(l) || config_cheat()))
    {
        level = l;

        next   = NULL;
        status = GAME_NONE;
        coins  = 0;
        timer  = 0;
        goal   = goal_i = level_goal(level);

        if (same_goal_e)
            same_goal_e = 0;
        else
            goal_e = (mode != MODE_CHALLENGE && level_completed(level) &&
                      config_get_d(CONFIG_LOCK_GOALS) == 0) || goal == 0;

        prev = curr;

        time_rank = RANK_LAST;
        goal_rank = RANK_LAST;
        coin_rank = RANK_LAST;

        return init_level();
    }
    return 0;
}
示例#2
0
static void gui_level(int id, int i)
{
    struct level *l = get_level(i);

    const GLubyte *fore = 0;
    const GLubyte *back = 0;

    int jd;

    if (!l)
    {
        gui_label(id, " ", GUI_SML, gui_blk, gui_blk);
        return;
    }

    if (level_opened(l))
    {
        fore = level_bonus(l)     ? gui_grn : gui_wht;
        back = level_completed(l) ? fore    : gui_yel;
    }

    jd = gui_label(id, level_name(l), GUI_SML, back, fore);

    if (level_opened(l) || config_cheat())
        gui_set_state(jd, START_LEVEL, i);
}
示例#3
0
void progress_stat(int s)
{
    int i, dirty = 0;

    status = s;

    coins = curr_coins();
    timer = (level_time(level) == 0 ?
             curr_clock() :
             level_time(level) - curr_clock());

    switch (status)
    {
    case GAME_GOAL:

        for (i = curr.score + 1; i <= curr.score + coins; i++)
            if (progress_reward_ball(i))
                curr.balls++;

        curr.score += coins;
        curr.times += timer;

        dirty = level_score_update(level, timer, coins,
                                   &time_rank,
                                   goal == 0 ? &goal_rank : NULL,
                                   &coin_rank);

        if (!level_completed(level))
        {
            level_complete(level);
            dirty = 1;
        }

        /* Compute next level. */

        if (mode == MODE_CHALLENGE)
        {
            for (next = level->next;
                 next && level_bonus(next);
                 next = next->next)
            {
                if (!level_opened(next))
                {
                    level_open(next);
                    dirty = 1;
                }
            }
        }
        else
        {
            for (next = level->next;
                 next && level_bonus(next) && !level_opened(next);
                 next = next->next)
                /* Do nothing */;
        }

        /* Open next level or complete the set. */

        if (next)
        {
            level_open(next);
            dirty = 1;
        }
        else
            done = mode == MODE_CHALLENGE;

        break;

    case GAME_FALL:
        /* Fall through. */

    case GAME_TIME:
        for (next = level->next;
             next && !level_opened(next);
             next = next->next)
            /* Do nothing */;

        curr.times += timer;
        curr.balls -= 1;

        break;
    }

    if (dirty && mode != MODE_STANDALONE)
        set_store_hs();

    demo_play_stat(status, coins, timer);
}
示例#4
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 */ 
示例#5
0
int process_key_up(int y, int x, int level, int have_key)
{
	int wall, c;
	move(--y, x); // Move the cursor up by one
	switch(wall = inch())
	{
		case '#' : move(++y, x); break;
		case '+' :
		{
			if(have_key == 1)
			{
				unlock();
				have_key--;
				move(++y, x);
			}
			else
			{
				move(22, 0);
				deleteln();
				mvprintw(22, 0, "This door appears to be locked.... You need a key.");
				move(++y, x);
			}
			break;
		}
		case ' ' :
		{
			move(++y, x);
			addch(' ');
			move(--y, x);
			addch('@');
			move(++y, x);
			break;
		}
		case 'o' :
		{
			level_completed(level++);
			switch(c = getch())
			{
				case 'c' : draw_maze(++level); break; // Continue and render next level.
				case 'q' : endwin(); return 0; break; // Close ncurses window
			}
			break;
		}
		case 'E' :
		{
			have_key++;
			move(22, 0);
			deleteln();
			mvprintw(22, 0, "You picked up a rusty key....");
			move(++y, x);
			addch(' ');
			move(--y, x);
			addch('@');
			move(y, x);
			break;
		}
	}
	refresh();
	return(y);
	return(x);
}