2013-9-30 journal, designPosted: 2013-09-30
While working today, I decided on something sort of interesting with one of the entities in the game. It arose accidentally.
In Even the Ocean, there are entities which launch water very quickly. It’s magic water though (…or something!), and when you touch it, your velocity becomes the same as the water – so the bullets launch upwards, thus, you kind of get boosted upwards into the air when touching a bullet.
I can choose how many “bullets” each entity launches – I set the default to five. The bullets all launch at the same time, but have staggered velocities (i/n * max_vel, where i = bullet index, n = nr of bullets). The way I set the velocity of the player is: if on a frame of the game, the bullet touches the player, then increment a “push velocity” counter which will be added to the players velocity in player’s physics routine, before the position of the player was updated (whew , that was a mouthful).
Anyways, what this basically amounts to is that if you are touching multiple bullets at once, the velocities end up being incremental. So if the bullets launch at velocities 90, 60, 30, and I touch all of them, I get a boost of 180 (whereas my desired behavior was only getting a boost of 90)
for each bullet:
if bullet overlaps player:
player’s velocity += bullet’s velocity.
What usually happened was, only the fastest bullet touched the player anyways (since this usually hits you on the ground or the air), so things behaved normally.
But sometimes, multiple bullets overlap the player in one frame, so instead, we get the effect of shooting the player up REALLLY fast.
I couldn’t reproduce it consistently, likely because there is some random factors I added into the initial bullet velocity. I instead now choose to use the fastest velocity of any number of bullets touching you.
But that interaction with boosting you too far was interesting, so additionally, I decided to be able to make it consistent, and sort of a “skill” thing. So now, when you press jump within a certain time frame, the bullet velocity that affects you, it is doubled (and then some). To sort of visualize this, just look at the GIF up there. If you jump *right* before the bullets launch, then the effect is doubled.
This isn’t physically realistic or anything, but it’s interesting and allows for various scenarios (needing to time it correctly to get some secret, needing tot ime it while avoiding other stuff, etc.)
Bugs can be great!