“New” Soundcloud account

I was definitely right about being swamped with other projects last week and it looks like this week too.

So rather than having a proper update, I’m just going to post a link to Sarcastibots “new” sound cloud account that was just set up 5 months ago.

So far we’ve uploaded a preliminary theme for Malwrath which maybe handy if we ever go back to that project.

Platformer Update 8

And another slow week although for different reasons. Last week I discovered Wang Tiles and remembered that aperodic tiling is a thing. So instead of working on adding features. I spent time figuring out how to implement Wang Tiles.

I’ll discuss aperiodic tiling and Wang Tiles next week, since this is going to be another slow week due not to me being distracted by a new shiny but because of life.

Platformer Update 7

It’s definitely been a slower week. Mostly I’ve been working on the animation for breakable crates. I tried a couple out and have settled on this one for the time being.

Not exactly sure what’s going on with the crenelations at the top of the box, but those were the shapes I got when I subdivided the original crate. Fun fact since it’s animated I can use lower resolution images and still not have it look terrible; so that little *.gif is pixel for pixel the final size.

Beyond the crate I made a number of other fixes to the working graphics for the player and the HUD.

Continuing Fun Times With Box2D

I’ve spent most of the week working on making destructible boxes for the platformer. The actual mechanics of this are fairly simple, and psedocode for the process is below.

if condition is met then

destroy box

The conditional statement can be checked during the regular update cycle (otherwise known as polling) or whenever a different condition is met (otherwise known as a listener).

For the destructible boxes the condition would be met if the impulse on the box would exceed a threshold value. I decided to use the listener method of checking the destruction condition; since, I already had a Box2D contact listener for the projectiles.

And now the fun starts so let’s add some equations. first impulse courtesy of Wikipedia.

\mathbf {J} =\int _{t_{1}}^{t_{2}}\mathbf {F} \,dt=\Delta \mathbf {p} =m\mathbf {v_{2}} -m\mathbf {v_{1}}

According to our good friends at Wikipedia impulse is the sum of the forces applied over a time period (t1 to t2) which can be expressed as a change in momentum and as mass times change in velocity.   hyper physics

It is not surprising then that the initial implementation measured the change in velocity between when the Box2D contact listener called beginContact() and endContact() on the destructible box. (there are legitimate issues with this implementation I know about them. If you’re having trouble imagining them think of someone pushing a sled gradually up to speed and then the pusher stops abruptly.) This was done because velocity is relatively easy to visualize and calculate. for example if the box were to start falling and impact the ground the some time later. The impact velocity could be calculated using either the fall time or the distance.  Assuming the velocity prior to impact >0 and immediately after impact is <=0. This should make it easy to tune the destruction velocity threshold depending on how many stories an object is expected to fall and remain intact.

After doing some mathematical manipulation and assuming initial velocity is zero. we get v² = 2ax. And we’re already to pick out some velocity thresholds.  So let’s move into the real err platformer world; where I took the liberty of having destructible box impact velocities logged for the record as well as start heights.

Experiment acceleration distance expected velocity actual velocity
Experiment 1 12 m/s/s 7.4 m 9.4 m/s 2.4 m/s
Experiment 2 12 m/s/s 7.3 m 9.4 m/s 1.99 m/s
Experiment 3 12 m/s/s 20.5 m 15.7 m/s 3.4 m/s

Something weird is definitely going on here. I’m currently assuming this is an artifact of how I was getting the velocity from Box2D. But I didn’t really dig into it too far since I realized there were other problems with this method, and switched to getting a ‘PostSolve’ impulse reading from Box2D which is closer but still different from the values I’m calculating. I suspect that I’m getting readings at the wrong time or that Box2D is taking additional things into consideration that were left out of the simple motion equations. (e.g. friction).

My conclusion for the week is, since a 10 cm difference in height resulted in a massive shift in impact velocity. This is annoying because it means that objects will require manual tuning of impact forces.