Esempio n. 1
0
/**
 *
 *  rct: 0x0067351F
 */
void money_effect_create_at(money32 value, int x, int y, int z)
{
	rct_money_effect *moneyEffect;
	rct_string_id stringId;
	char buffer[128];

	moneyEffect = (rct_money_effect*)create_sprite(2);
	if (moneyEffect == NULL)
		return;

	moneyEffect->value = value;
	moneyEffect->var_14 = 64;
	moneyEffect->var_09 = 20;
	moneyEffect->var_15 = 30;
	moneyEffect->sprite_identifier = SPRITE_IDENTIFIER_MISC;
	sprite_move(x, y, z, (rct_sprite*)moneyEffect);
	moneyEffect->misc_identifier = SPRITE_MISC_MONEY_EFFECT;
	moneyEffect->num_movements = 0;
	moneyEffect->move_delay = 0;

	stringId = 1388;
	if (value < 0) {
		value *= -1;
		stringId = 1399;
	}
	format_string(buffer, stringId, &value);
	RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224;
	moneyEffect->offset_x = -(gfx_get_string_width(buffer) / 2);
	moneyEffect->wiggle = 0;
}
Esempio n. 2
0
//--------- Begin of function UnitB::next_move ---------//
//
//	If there is unprocessed node(s) in the result_node_array,
// then next unprocessed node will be set to be the next location
// to move to. (i.e. go_? = location of the unprocessed node)
//
void UnitB::next_move()
{
	if( cur_path == NULL || !cur_path_result_id )
		return;

	//------------ all nodes are visited --------------//

	err_when(cur_x!=next_x || cur_y!=next_y);

	set_idle();

	//---- order the unit to move to the next checkpoint following the path ----//

	PathResult* pathResult = cur_path + cur_path_result_id - 1;
	cur_path_result_id--;

	err_when( pathResult->loc_x == cur_x_loc() && pathResult->loc_y == cur_y_loc() );

	sprite_move( pathResult->loc_x * LOCATE_WIDTH, pathResult->loc_y * LOCATE_HEIGHT );

	err_when(cur_x==go_x && cur_y==go_y && (cur_x!=next_x || cur_y!=next_y));
}
Esempio n. 3
0
/**
 *
 *  rct2: 0x0067396A (water)
 *  rct2: 0x006739A4 (snow)
 */
void jumping_fountain_create(int type, int x, int y, int z, int direction, int flags, int iteration)
{
    rct_jumping_fountain *jumpingFountain;

    jumpingFountain = (rct_jumping_fountain*)create_sprite(SPRITE_IDENTIFIER_MISC);
    if (jumpingFountain == NULL)
        return;

    jumpingFountain->iteration = iteration;
    jumpingFountain->var_2E = direction;
    jumpingFountain->flags = flags;
    jumpingFountain->sprite_direction = direction << 3;
    jumpingFountain->var_14 = 33;
    jumpingFountain->var_09 = 36;
    jumpingFountain->var_15 = 12;
    jumpingFountain->sprite_identifier = SPRITE_IDENTIFIER_MISC;
    sprite_move(x, y, z, (rct_sprite*)jumpingFountain);
    jumpingFountain->misc_identifier = type == JUMPING_FOUNTAIN_TYPE_SNOW ?
                                       SPRITE_MISC_JUMPING_FOUNTAIN_SNOW :
                                       SPRITE_MISC_JUMPING_FOUNTAIN_WATER;
    jumpingFountain->var_26 = 0;
}
Esempio n. 4
0
/**
 *
 *  rct: 0x00673232
 */
void money_effect_update(rct_money_effect *moneyEffect)
{
	invalidate_sprite_2((rct_sprite*)moneyEffect);
	moneyEffect->wiggle++;
	if (moneyEffect->wiggle >= 22)
		moneyEffect->wiggle = 0;

	moneyEffect->move_delay++;
	if (moneyEffect->move_delay < 2)
		return;

	moneyEffect->move_delay = 0;
	int x = moneyEffect->x + _moneyEffectMoveOffset[get_current_rotation()].x;
	int y = moneyEffect->y + _moneyEffectMoveOffset[get_current_rotation()].y;
	int z = moneyEffect->z;
	sprite_move(x, y, z, (rct_sprite*)moneyEffect);

	moneyEffect->num_movements++;
	if (moneyEffect->num_movements < 55)
		return;

	sprite_remove((rct_sprite*)moneyEffect);
}
Esempio n. 5
0
void sprite_array_move(sprite_t *spr, uint8_t n)
{
    while(n--)
        sprite_move(spr++);
}
Esempio n. 6
0
/**
 * Run the main game loop until the finished flag is set at 40fps (25ms interval).
 */
static void openrct2_loop()
{
	uint32 currentTick, ticksElapsed, lastTick = 0;
	static uint32 uncapTick = 0;
	static int fps = 0;
	static uint32 secondTick = 0;

	log_verbose("begin openrct2 loop");

	_finished = 0;
	do {
		if (gConfigGeneral.uncap_fps && gGameSpeed <= 4) {
			currentTick = SDL_GetTicks();
			if (uncapTick == 0) {
				// Reset sprite locations
				uncapTick = SDL_GetTicks();
				openrct2_reset_object_tween_locations();
			}

			// Limit number of updates per loop (any long pauses or debugging can make this update for a very long time)
			if (currentTick - uncapTick > 25 * 60) {
				uncapTick = currentTick - 25 - 1;
			}

			platform_process_messages();

			while (uncapTick <= currentTick && currentTick - uncapTick > 25) {
				// Get the original position of each sprite
				for (uint16 i = 0; i < MAX_SPRITES; i++) {
					_spritelocations1[i].x = g_sprite_list[i].unknown.x;
					_spritelocations1[i].y = g_sprite_list[i].unknown.y;
					_spritelocations1[i].z = g_sprite_list[i].unknown.z;
				}

				// Update the game so the sprite positions update
				rct2_update();

				// Get the next position of each sprite
				for (uint16 i = 0; i < MAX_SPRITES; i++) {
					_spritelocations2[i].x = g_sprite_list[i].unknown.x;
					_spritelocations2[i].y = g_sprite_list[i].unknown.y;
					_spritelocations2[i].z = g_sprite_list[i].unknown.z;
				}

				uncapTick += 25;
			}

			// Tween the position of each sprite from the last position to the new position based on the time between the last
			// tick and the next tick.
			float nudge = 1 - ((float)(currentTick - uncapTick) / 25);
			for (uint16 i = 0; i < MAX_SPRITES; i++) {
				if (!sprite_should_tween(&g_sprite_list[i]))
					continue;

				sprite_move(
					_spritelocations2[i].x + (sint16)((_spritelocations1[i].x - _spritelocations2[i].x) * nudge),
					_spritelocations2[i].y + (sint16)((_spritelocations1[i].y - _spritelocations2[i].y) * nudge),
					_spritelocations2[i].z + (sint16)((_spritelocations1[i].z - _spritelocations2[i].z) * nudge),
					&g_sprite_list[i]
				);
				invalidate_sprite_2(&g_sprite_list[i]);
			}

			if ((SDL_GetWindowFlags(gWindow) & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_HIDDEN)) == 0) {
				rct2_draw();
				platform_draw();
			}

			fps++;
			if (SDL_GetTicks() - secondTick >= 1000) {
				fps = 0;
				secondTick = SDL_GetTicks();
			}

			// Restore the real positions of the sprites so they aren't left at the mid-tween positions
			for (uint16 i = 0; i < MAX_SPRITES; i++) {
				if (!sprite_should_tween(&g_sprite_list[i]))
					continue;

				invalidate_sprite_2(&g_sprite_list[i]);
				sprite_move(_spritelocations2[i].x, _spritelocations2[i].y, _spritelocations2[i].z, &g_sprite_list[i]);
			}
			network_update();
		} else {
			uncapTick = 0;
			currentTick = SDL_GetTicks();
			ticksElapsed = currentTick - lastTick;
			if (ticksElapsed < 25) {
				if (ticksElapsed < 15)
					SDL_Delay(15 - ticksElapsed);
				continue;
			}

			lastTick = currentTick;

			platform_process_messages();

			rct2_update();

			if ((SDL_GetWindowFlags(gWindow) & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_HIDDEN)) == 0) {
				rct2_draw();
				platform_draw();
			}
		}
	} while (!_finished);
}