Exemple #1
0
void Player::move(Map *map)
{
    if (is_morphing()) {
        m_morph->move(map);
    }
    else {
        player_move(map);
    }
}
Exemple #2
0
void Player::draw(Surface *dest, Map *map,
                  int clip_x, int clip_y, int clip_w, int clip_h)
{
    if (is_morphing()) {
        m_morph->draw(dest, map, clip_x, clip_y, clip_w, clip_h);
    }
    else {
        Actor::draw(dest, map, clip_x, clip_y, clip_w, clip_h);
    }
}
Exemple #3
0
inline void update_motion(void){
	uint16_t chan;
	uint16_t test_chan;
	int16_t i;
	uint8_t is_distinct;


	for (chan=0;chan<NUM_CHANNELS;chan++)
	{
		//if morph has reached the end, shift our present position to the (former) fadeto destination
		if (motion_morphpos[chan]>=1.0)
		{
			note[chan] = motion_fadeto_note[chan];
			scale[chan] = motion_fadeto_scale[chan];
			//scale_bank[chan] = motion_fadeto_bank[chan];

			if (motion_spread_dest[chan] == note[chan])
				motion_spread_dir[chan] = 0;

			motion_morphpos[chan]=0.0;

			flag_update_LED_ring=1;
		}
	}



	//Initiate a motion if one is not happening
	if (!is_morphing()){

	//Rotation CW
		if (motion_rotate>0){
			motion_rotate--;
			for (chan=0;chan<6;chan++){
				if (!lock[chan]){
					motion_spread_dir[chan]=1;
					//Increment circularly
					if (motion_spread_dest[chan]>=(NUM_FILTS-1))
						motion_spread_dest[chan]=0;
					else
						motion_spread_dest[chan]++;
				}
			}
		} else

	//Rotation CCW
		if (motion_rotate<0){
			motion_rotate++;
			for (chan=0;chan<6;chan++){
				if (!lock[chan]){
					motion_spread_dir[chan]=-1;
					//Dencrement circularly
					if (motion_spread_dest[chan]==0)
						motion_spread_dest[chan]=NUM_FILTS-1;
					else
						motion_spread_dest[chan]--;
				}
			}
		}else

	//Rotate CV (jump)
		if (motion_notejump!=0){

			for (chan=0;chan<6;chan++){
				if (!lock[chan]){

					//Dec/Increment circularly
					motion_fadeto_note[chan]+=motion_notejump;
					while (motion_fadeto_note[chan]<0) motion_fadeto_note[chan]+=NUM_FILTS;
					while (motion_fadeto_note[chan]>=NUM_FILTS) motion_fadeto_note[chan] -= NUM_FILTS;

					//Dec/Increment circularly
					motion_spread_dest[chan]+=motion_notejump;
					while (motion_spread_dest[chan]<0) motion_spread_dest[chan]+=NUM_FILTS;
					while (motion_spread_dest[chan]>=NUM_FILTS) motion_spread_dest[chan] -= NUM_FILTS;


					//Check if the new destination is occupied by a locked channel, a channel we already notejump'ed or a blocked freq
					if  (freqblock & (1<<motion_fadeto_note[chan])){
						is_distinct=0;
					}else{
						for (is_distinct=1,test_chan=0;test_chan<NUM_CHANNELS;test_chan++){
							if (chan!=test_chan && motion_fadeto_note[chan]==motion_fadeto_note[test_chan] && (lock[test_chan] || test_chan<chan))
								is_distinct=0;
						}
					}
					while (!is_distinct){

						//Inc/decrement circularly

						if (motion_notejump>0){
							motion_fadeto_note[chan]=(motion_fadeto_note[chan] + 1) % NUM_FILTS;
						}else {
							if (motion_fadeto_note[chan]==0) motion_fadeto_note[chan] = NUM_FILTS-1;
							else motion_fadeto_note[chan] = motion_fadeto_note[chan] - 1;
						}

						//Check if the new destination is occupied by a locked channel, a channel we already notejump'ed or a blocked freq						
						if  (freqblock & (1<<motion_fadeto_note[chan])){
								is_distinct=0;
						}else{
							for (is_distinct=1,test_chan=0;test_chan<NUM_CHANNELS;test_chan++){
								if (chan!=test_chan && motion_fadeto_note[chan]==motion_fadeto_note[test_chan] && (lock[test_chan] || test_chan<chan))
									is_distinct=0;
							}
						}
					}
					//Start the motion morph
					motion_morphpos[chan] = f_morph;
					motion_fadeto_scale[chan]=motion_scale_dest[chan];

				}
			}
			motion_notejump=0;
		}
	}


	for (chan=0;chan<NUM_CHANNELS;chan++){

		if (motion_morphpos[chan]==0.0){

	//Spread
			//Problem: try spreading from 5 to 6, then 6 to 5.
			//channel 0 and 3 collide like this:
			//Start 18 x x 16 x x
			//End   16 x x 17 x x
			//So channel 0 starts to fade from 18 to 17
			//Channel 3 wants to fade to 17, but 17 is taken as a fadeto, so it fades to 18.
			//Next step:
			//Channel 0 fades to 16 and is done
			//Channel 3 fades from 18 to 19, 0, 1...17. Since its dir is set to +1, it has to go all the way around the long way from 18 to 17
			//Not big problem except that the scale is incremented on channel 3, and when spread is returned to 5, the scale does not decrement
			//Thus channel 3 will be in a different scale than when it started.
			//Solution ideas:
			//-ignore the issue, but force spread=1 to make all notes in the same scale (unless spanning 19/0)
			//-allow channels to fadeto the same spot, but not have the same motion_spread_dest
			// --ch0: 18->17 ch3: 16->17; ch0: 17->16 ch3: stay
			//-change the is_distinct code in fadeto to give priority to channels that are hitting their motion_spread_dest
			// --or somehow change it so ch0: 18->17, ch3:16->17 bumps ch0 18->16

			if (motion_spread_dest[chan] != note[chan]){

	//Check if the spread destination is still available
				if  (freqblock & (1<<motion_spread_dest[chan])){
					is_distinct=0;
				}else{
					for (is_distinct=1,test_chan=0;test_chan<NUM_CHANNELS;test_chan++){
						if (chan!=test_chan && (motion_spread_dest[chan]==motion_spread_dest[test_chan]) && (lock[test_chan]==1 || test_chan<chan || motion_spread_dir[test_chan]==0)) 
							is_distinct=0;
					}
				}
				while (!is_distinct){

					//Inc/decrement circularly
					if (motion_spread_dir[chan]==0)
						motion_spread_dir[chan]=1;

					if (motion_spread_dir[chan]>0){
						motion_spread_dest[chan]=(motion_spread_dest[chan] + 1) % NUM_FILTS;
					}else {
						if (motion_spread_dest[chan]==0) motion_spread_dest[chan] = NUM_FILTS-1;
						else motion_spread_dest[chan] = motion_spread_dest[chan] - 1;
					}

					//Check that it's not already taken by a locked channel, channel with a higher priority, a blocked freq or a non-moving channel
					if  (freqblock & (1<<motion_spread_dest[chan])){
						is_distinct=0;
					}else{
						for (is_distinct=1,test_chan=0;test_chan<NUM_CHANNELS;test_chan++){
							if (chan!=test_chan && (motion_spread_dest[chan]==motion_spread_dest[test_chan]) && (lock[test_chan]==1 || test_chan<chan || motion_spread_dir[test_chan]==0))
								is_distinct=0;
						}
					}
				}


	//Clockwise Spread
				if (motion_spread_dir[chan] > 0) {

					//Start the motion morph
					motion_morphpos[chan] = f_morph;

					// Shift the destination CW, wrapping it around
					is_distinct=0;
					while (!is_distinct){

						//Increment circularly
						if (motion_fadeto_note[chan]>=(NUM_FILTS-1)){
							motion_fadeto_note[chan]=0;

							// If scale rotation is on, increment the scale, wrapping it around
							if (rotate_to_next_scale){
								motion_fadeto_scale[chan]=(motion_fadeto_scale[chan]+1) % NUMSCALES;
								motion_scale_dest[chan]=(motion_scale_dest[chan]+1) % NUMSCALES;
							}
						}
						else
							motion_fadeto_note[chan]++;

						//Check that it's not already taken by a locked channel, channel with a higher priority, a blocked freq, or a non-moving channel
						if  (freqblock & (1<<motion_fadeto_note[chan])){
							is_distinct=0;
						}else{
							for (is_distinct=1,test_chan=0;test_chan<NUM_CHANNELS;test_chan++){
								if (chan!=test_chan && (motion_fadeto_note[chan]==motion_fadeto_note[test_chan]) && (lock[test_chan]==1 || test_chan<chan)) 
									is_distinct=0;
							}
						}
					}
				} else

	//Counter-clockwise Spread
				if (motion_spread_dir[chan]<0){

					//Start the motion morph
					motion_morphpos[chan] = f_morph;

					// Shift the destination CCW, wrapping it around and repeating until we find a distinct value
					is_distinct=0;
					while (!is_distinct){

						//Decrement circularly
						if (motion_fadeto_note[chan]==0) {
							motion_fadeto_note[chan] = NUM_FILTS-1;

							// If scale rotation is on, decrement the scale, wrapping it around
							if (rotate_to_next_scale){
								if (motion_fadeto_scale[chan]==0) motion_fadeto_scale[chan]=NUMSCALES-1;
								else motion_fadeto_scale[chan]--;
								if (motion_scale_dest[chan]==0) motion_scale_dest[chan]=NUMSCALES-1;
								else motion_scale_dest[chan]--;

							}
						}
						else
							motion_fadeto_note[chan]--;

						//Check that it's not already taken by a locked channel, channel with a higher priority, a blocked freq, or a non-moving channel
						if  (freqblock & (1<<motion_fadeto_note[chan])){
							is_distinct=0;
						}else{						
							for (is_distinct=1,test_chan=0;test_chan<NUM_CHANNELS;test_chan++){
								if (chan!=test_chan && (motion_fadeto_note[chan]==motion_fadeto_note[test_chan]) && (lock[test_chan]==1 || test_chan<chan)) 
									is_distinct=0;
							}
						}
					}
				}
			}
			else

	//Scale
			if (motion_scale_dest[chan] != motion_fadeto_scale[chan]){
				//Start the motion morph
				motion_morphpos[chan] = f_morph;

				motion_fadeto_scale[chan]=motion_scale_dest[chan];
			}
		}
	}
}