Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
15767c3
commit 0b95dcd
Showing
5 changed files
with
78 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,42 +305,45 @@ uint32_t rct_duck::GetFrameImage(int32_t direction) const | |
return imageId; | ||
} | ||
|
||
void create_duck(int32_t targetX, int32_t targetY) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
chfast
Contributor
|
||
void create_duck(const CoordsXY& pos) | ||
{ | ||
rct_sprite* sprite = create_sprite(SPRITE_IDENTIFIER_MISC); | ||
if (sprite != nullptr) | ||
if (sprite == nullptr) | ||
return; | ||
|
||
CoordsXY targetPos = pos; | ||
|
||
int32_t offsetXY = scenario_rand() & 0x1E; | ||
targetPos.x += offsetXY; | ||
targetPos.y += offsetXY; | ||
|
||
sprite->duck.sprite_identifier = SPRITE_IDENTIFIER_MISC; | ||
sprite->duck.type = SPRITE_MISC_DUCK; | ||
sprite->duck.sprite_width = 9; | ||
sprite->duck.sprite_height_negative = 12; | ||
sprite->duck.sprite_height_positive = 9; | ||
sprite->duck.target_x = targetPos.x; | ||
sprite->duck.target_y = targetPos.y; | ||
uint8_t direction = scenario_rand() & 3; | ||
switch (direction) | ||
{ | ||
sprite->duck.sprite_identifier = SPRITE_IDENTIFIER_MISC; | ||
sprite->duck.type = SPRITE_MISC_DUCK; | ||
sprite->duck.sprite_width = 9; | ||
sprite->duck.sprite_height_negative = 12; | ||
sprite->duck.sprite_height_positive = 9; | ||
int32_t offsetXY = scenario_rand() & 0x1E; | ||
targetX += offsetXY; | ||
targetY += offsetXY; | ||
sprite->duck.target_x = targetX; | ||
sprite->duck.target_y = targetY; | ||
uint8_t direction = scenario_rand() & 3; | ||
switch (direction) | ||
{ | ||
case 0: | ||
targetX = 8191 - (scenario_rand() & 0x3F); | ||
break; | ||
case 1: | ||
targetY = scenario_rand() & 0x3F; | ||
break; | ||
case 2: | ||
targetX = scenario_rand() & 0x3F; | ||
break; | ||
case 3: | ||
targetY = 8191 - (scenario_rand() & 0x3F); | ||
break; | ||
} | ||
sprite->duck.sprite_direction = direction << 3; | ||
sprite_move(targetX, targetY, 496, sprite); | ||
sprite->duck.state = DUCK_STATE::FLY_TO_WATER; | ||
sprite->duck.frame = 0; | ||
case 0: | ||
targetPos.x = 8191 - (scenario_rand() & 0x3F); | ||
break; | ||
case 1: | ||
targetPos.y = scenario_rand() & 0x3F; | ||
break; | ||
case 2: | ||
targetPos.x = scenario_rand() & 0x3F; | ||
break; | ||
case 3: | ||
targetPos.y = 8191 - (scenario_rand() & 0x3F); | ||
break; | ||
} | ||
sprite->duck.sprite_direction = direction << 3; | ||
sprite_move(targetPos.x, targetPos.y, 496, sprite); | ||
sprite->duck.state = DUCK_STATE::FLY_TO_WATER; | ||
sprite->duck.frame = 0; | ||
} | ||
|
||
void duck_update(rct_duck* duck) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You should pass
CoordsXY
by value - on 64-bit systems it will be passed in single register.https://godbolt.org/z/Q64C-X