Ejemplo n.º 1
0
//--------- Begin of function Sprite::process_turn --------//
void Sprite::process_turn()
{
	err_when(!sprite_info->need_turning);
	match_dir();
	if(is_dir_correct())
		cur_action = SPRITE_MOVE;
}
Ejemplo n.º 2
0
//------ Begin of function Sprite::set_dir -------//
void Sprite::set_dir(UCHAR newDir)
{
	if(newDir != final_dir)
	{
		final_dir = newDir;
		turn_delay = 0;
	}

	if(!sprite_info->need_turning)
		cur_dir = final_dir;
	else
		match_dir();
}
Ejemplo n.º 3
0
//------ Begin of function Sprite::set_dir -------//
void Sprite::set_dir(int curX, int curY, int destX, int destY)
{
	UCHAR newDir = get_dir(curX, curY, destX, destY);
	if(newDir != final_dir)
	{
		final_dir = newDir;
		turn_delay = 0;
	}

	if(!sprite_info->need_turning)
		cur_dir = final_dir;
	else
		match_dir(); // start turning
}
Ejemplo n.º 4
0
void UnitMarine::process_extra_move()
{
	static short vector_x_array[] = { 0,  1, 1, 1, 0, -1, -1, -1};	// default vectors, temporary only
	static short vector_y_array[] = {-1, -1, 0, 1, 1,  1,  0, -1};

	if(!match_dir()) // process turning
		return;

	if(cur_x!=go_x || cur_y!=go_y)
	{
		//------------------------------------------------------------------------//
		// set cargo_recno, extra_move_in_beach
		//------------------------------------------------------------------------//
		if(cur_x==next_x && cur_y==next_y)
		{
			int goXLoc = go_x>>ZOOM_X_SHIFT_COUNT;
			int goYLoc = go_y>>ZOOM_Y_SHIFT_COUNT;
			if(!world.get_loc(goXLoc, goYLoc)->can_move(mobile_type))
			{
				go_x = next_x;
				go_y = next_y;
				return;
			}

			int curXLoc = next_x_loc();
			int curYLoc = next_y_loc();
			world.set_unit_recno(curXLoc, curYLoc, mobile_type, 0);
			world.set_unit_recno(goXLoc, goYLoc, mobile_type, sprite_recno);
			next_x = go_x;
			next_y = go_y;
			
			err_when( ((curXLoc%2)|(curYLoc%2)) + ((goXLoc%2)|(goYLoc%2)) != 1); // one pair location must be even, another is not even
			in_beach = !(curXLoc%2 || curYLoc%2);
			
			if(goXLoc%2 || goYLoc%2) // not even location
				extra_move_in_beach = EXTRA_MOVING_IN;
			else // even location
				extra_move_in_beach = EXTRA_MOVING_OUT;
		}
		//else
		//	int debug = 0;
		
		//---------- process moving -----------//
		short stepX = sprite_info->speed;
		short stepY = sprite_info->speed;
		short vectorX = vector_x_array[final_dir] * sprite_info->speed;	// cur_dir may be changed in the above set_next() call
		short vectorY = vector_y_array[final_dir] * sprite_info->speed;

		if(abs(cur_x-go_x) <= stepX)
			cur_x = go_x;
		else
			cur_x += vectorX;

		if(abs(cur_y-go_y) <= stepY)
			cur_y = go_y;
		else
			cur_y += vectorY;

		err_when(extra_move_in_beach!=EXTRA_MOVING_IN && extra_move_in_beach!=EXTRA_MOVING_OUT);
		err_when(cur_action!=SPRITE_SHIP_EXTRA_MOVE);
	}