yesterday i came up with an idea to implement proper sound for the paddlesteamer's engine. as know hardly any C++, i thought i'd write it down in text, but you get the idea. the idea is that as you pick up speed, you'll hear the engine running faster as well.
code:
if ship is not 'paddlesteamer',
(existing code for sailing sound effects)
{if ship is 'paddlesteamer', and
time is 1x,
{if current speed <12,0
play soundeffect 'chuff' with interval:
([square root](13-speed))/4, and
repeat}
{if current speed is equal to or >12.0,
play soundeffect 'full speed' once, and
play soundeffect 'chuff' with interval 0.25}
}
the interval mentioned above should be taken in seconds. the 'chuff' is the sound of a single stroke of the engine, and the 'full speed' soundeffect might be something that would play once you reach 12 knots. just a little sound for fun, maybe a blow on the whistle or something. the main purpose is preventing the game from trying to take the square root of 0 or less, which is impossible.
the code in bold represents the increase in speed. the reason why i've chosen a formula with a square root is because the engine would then have a quick increase in speed at low speeds, and a slower increase at higher speeds. i've done this because the engine would otherwise (like when it would be a linear increase) be going unrealistically slow at speeds of 4 knots and lower, and way too fast at high speeds. i've assumed that the statistical maximum speed for the ship is 13 knots, including speed upgrades. change the numbers if appropriate. also, i am aware that the forward slash could already have a coding purpose. the 'divide by' function should in that case be replaced by something similar. one important thing of note is that the interval doesn't indicate the time between the ending of the first and the beginning of the second, but the time between the beginnings of the 'chuff'.
the condition that time should be 1x might seem odd, but i've done this because the sound effect would be played annoyingly quickly if you would speed up the game, and potentially cause massive lag. you can try leaving it out, but i'm not sure how well it would go.
additionally, it would be nice to have a puff of smoke every time the 'chuff' is played, which shouldn't be that difficult to add into the above code.
code:
if ship is not 'paddlesteamer',
(existing code for sailing sound effects)
{if ship is 'paddlesteamer', and
time is 1x,
{if current speed <12,0
play soundeffect 'chuff' with interval:
([square root](13-speed))/4, and
repeat}
{if current speed is equal to or >12.0,
play soundeffect 'full speed' once, and
play soundeffect 'chuff' with interval 0.25}
}
the interval mentioned above should be taken in seconds. the 'chuff' is the sound of a single stroke of the engine, and the 'full speed' soundeffect might be something that would play once you reach 12 knots. just a little sound for fun, maybe a blow on the whistle or something. the main purpose is preventing the game from trying to take the square root of 0 or less, which is impossible.
the code in bold represents the increase in speed. the reason why i've chosen a formula with a square root is because the engine would then have a quick increase in speed at low speeds, and a slower increase at higher speeds. i've done this because the engine would otherwise (like when it would be a linear increase) be going unrealistically slow at speeds of 4 knots and lower, and way too fast at high speeds. i've assumed that the statistical maximum speed for the ship is 13 knots, including speed upgrades. change the numbers if appropriate. also, i am aware that the forward slash could already have a coding purpose. the 'divide by' function should in that case be replaced by something similar. one important thing of note is that the interval doesn't indicate the time between the ending of the first and the beginning of the second, but the time between the beginnings of the 'chuff'.
the condition that time should be 1x might seem odd, but i've done this because the sound effect would be played annoyingly quickly if you would speed up the game, and potentially cause massive lag. you can try leaving it out, but i'm not sure how well it would go.
additionally, it would be nice to have a puff of smoke every time the 'chuff' is played, which shouldn't be that difficult to add into the above code.