void Game_Vehicle::Update() {
	Game_Character::Update();
	Game_Character::UpdateSprite();
	SyncWithPlayer();

	if (type == Airship) {
		if (IsAscending()) {
			data.remaining_ascent -= 8;
			if (!IsAscending())
				walk_animation = true;
		} else if (IsDescending()) {
			data.remaining_descent -= 8;
			if (!IsDescending()) {
				if (CanLand()) {
					SetLayer(RPG::EventPage::Layers_same);
					driving = false;
					data.flying = false;
					walk_animation = false;
					pattern = 1;
				} else {
					// Can't land here, ascend again
					data.remaining_ascent = SCREEN_TILE_WIDTH;
				}
			}
		}
	}
}
Beispiel #2
0
bool Game_Vehicle::IsMovable() {
	if (!IsInUse())
		return false;
	if (type == Airship && (IsAscending() || IsDescending()))
		return false;
	return !IsMoving();
}
void main()
{
    Triplet T;
    ElemType m;
    Status i;

    i=InitTriplet(T,5,7,9);
    printf("调用初始化函数后,i=%d(1:成功) T的三个值为:%d %d %d\n",i,T[0],T[1],T[2]); /* 当ElemType的类型变化时,要相应改变printf()的格式符。 */

    i=Get(T,2,m);
    if(i==OK)
        printf("T的第2个值为:%d\n",m);

    i=Put(T,2,6);
    if(i==OK)
        printf("将T的第2个值改为6后,T的三个值为:%d %d %d\n",T[0],T[1],T[2]);

    i=IsAscending(T); /* 此类函数实参与ElemType的类型无关,当ElemType的类型变化时,实参不需改变 */
    printf("调用测试升序的函数后,i=%d(0:否 1:是)\n",i);

    i=IsDescending(T);
    printf("调用测试降序的函数后,i=%d(0:否 1:是)\n",i);

    if((i=Max(T,m))==OK) /* 先赋值再比较 */
        printf("T中的最大值为:%d\n",m);

    if((i=Min(T,m))==OK)
        printf("T中的最小值为:%d\n",m);

    DestroyTriplet(T); /* 函数也可以不带回返回值 */
    printf("销毁T后,T=%u(NULL)\n",T);

}
void Game_Vehicle::SyncWithPlayer() {
	if (!driving || IsAscending() || IsDescending())
		return;
	SetX(Main_Data::game_player->GetX());
	SetY(Main_Data::game_player->GetY());
	remaining_step = Main_Data::game_player->GetRemainingStep();
	SetDirection(Main_Data::game_player->GetDirection());
	SetSpriteDirection(Main_Data::game_player->GetSpriteDirection());
}
Beispiel #5
0
int Game_Vehicle::GetAltitude() const {
	if (!data.flying)
		return 0;
	else if (IsAscending())
		return (SCREEN_TILE_WIDTH - data.remaining_ascent) / (SCREEN_TILE_WIDTH / TILE_SIZE);
	else if (IsDescending())
		return data.remaining_descent / (SCREEN_TILE_WIDTH / TILE_SIZE);
	else
		return SCREEN_TILE_WIDTH / (SCREEN_TILE_WIDTH / TILE_SIZE);
}
Beispiel #6
0
int Game_Vehicle::GetAltitude() const {
	if (!IsFlying())
		return 0;
	else if (IsAscending())
		return (SCREEN_TILE_SIZE - data()->remaining_ascent) / (SCREEN_TILE_SIZE / TILE_SIZE);
	else if (IsDescending())
		return data()->remaining_descent / (SCREEN_TILE_SIZE / TILE_SIZE);
	else
		return SCREEN_TILE_SIZE / (SCREEN_TILE_SIZE / TILE_SIZE);
}
Beispiel #7
0
void Game_Vehicle::Update(bool process_movement) {

	if (!process_movement) {
		return;
	}

	if (IsAboard()) {
		SyncWithPlayer();
	} else {
		Game_Character::UpdateMovement();
	}

	if (type == Airship) {
		if (IsStopping()) {
			if (IsAscending()) {
				data()->remaining_ascent = data()->remaining_ascent - 8;
			} else if (IsDescending()) {
				data()->remaining_descent = data()->remaining_descent - 8;
				if (!IsDescending()) {
					if (CanLand()) {
						Main_Data::game_player->UnboardingFinished();
						SetFlying(false);
						Main_Data::game_player->SetFlying(false);
					} else {
						// Can't land here, ascend again
						data()->remaining_ascent = SCREEN_TILE_SIZE;
					}
				}
			}
		}
	}

	if (type == Airship) {
		UpdateAnimationAirship();
	} else {
		UpdateAnimationShip();
	}
}
Beispiel #8
0
int main(int argc, char *argv[])
{
	
	int p = 0;
	int *r = &p;
	int *e = &p;
	int **T = &r;
	int s =  10;
	
	InitTriplet(T,4,5,6);
	printf("%d %d %d\n", T[0], T[1], T[2]);
	Get(T, 3, e);
	printf("%d\n",*e);
	Put(T, 3, s);
	printf("%d %d %d\n", T[0], T[1], T[2]);
	printf("%d\n",IsAscending(T));
	printf("%d\n",IsDescending(T));
	return 0;
}
Beispiel #9
0
int main(int argc, char* argv[])
{
	Triplet T;
	InitTriplet(T,5,7,9);

	ElemType e;
	Get(T,2,e);
	printf("%d ",e);

	Put(T,2,8);
	Get(T,2,e);
	printf("%d ",e);

	Max(T,e);
	printf("%d ",e);

	Min(T,e);
	printf("%d",e);

	printf("\nIs Ascending?%d(1-Y;0-N)\n",IsAscending(T));
	printf("Is Descendding?%d(1-Y;0-N)",IsDescending(T));
	system("pause");
	return 0;
}
Beispiel #10
0
bool Game_Vehicle::IsAscendingOrDescending() const {
	return IsAscending() || IsDescending();
}