This is my entry for MiniLD 25 with the theme “The worst game you have ever made”. The goal was to make the worst game you have ever made. It was suprisingly hard not to make little improvements here and there, it’s something I usually do without thinking.

I’m working on a shooter written in the Monkey language. It’s a new cross-platform programming language that can generate code for a whole bunch of platforms including Win, Mac, HTML5, Flash, iOS, Android and more. It’s a really simple language that resembles BASIC. It is kind of limited since is has to work on all those platforms, but I’m having lots of fun playing with it.

Here’s what I’ve got so far. Enemies just keep on spawning at the moment, so it’s kind of repetitive. ðŸ˜›

Chrome recommended for performance. IE doesn’t even work yet (until IE9 which is coming out in a couple of days.)

There are currently two control schemes:

Mouse – aim and shoot

Arrows – move

or

Z – strafe

X – shoot

Arrows – move.

Space drops a bomb in both cases. And you shoot backwards. ðŸ™‚

I haven’t decided on which to use yet, if you have any feedback make a comment!

PLAY GAME! (Note: Lots of flashing going on. If you have epilepsy be aware!)

A flash experiment traces a path which is affected by gravity from planets. You can move the planets around to make interesting shapes. You can also add more planets and scale them.

**Updated!** Cleaned it up and added more controls. You can now change the number of steps the ray traces and a bunch of other things.

Some new variations on my Ludum Dare logo.

I attended the Global game jam in Gothenburg this weekend. My team made a platform game where you try to save at least one female and one male of the species, in order to save them from extinction (which was the theme). In order to succed you must play each level multiple times, where each previous run is recorded and played back from the beginning.

My team consisted of myself, Andreas Bjerkeholt and Alejandro Valenzuela (check out his detailed report of the event on his blog here!)

The first day we spent prototyping a number of other ideas, (including dinosaur metroite bowling and a planet-light bending simulator where the goal was to make a ray of light reach earth :)) before choosing this platformer.

In my last post I talked about a technique to calculate the velocity vector needed for a projectile to intercept a linearly moving target.

Here is a flash example and sourcecode:

#### Flash example

#### Download sourcecode

I have been playing with target intersection prediction after I played a game called Beacon, where the enemies predict where you are going.Â After a bit of struggle, I got it to work accurately. This post at stackoverflow helped.Â I’m going to explain how it works more in depth.

**Assumptions
**Here we have a cannon on the ground, trying to hit a flying target. Let us assume the target is travelling with constant velocity, unaffected by gravity, and so is the projectile shot by the cannon.

The target will have a known velocity `u`

. We will also know the speed of the projectile `|v|`

in advance, and we want to find the vector `v`

that will make it hit the target.

**Method
**The idea is to transform the shooter and target to a new coordinate system where the line between them is one of the axes, match up the parallell speed, and then calculate the appropriate tangential speed for the projectile.

In order for the projectile to hit the target, the I composants of the velocities, `vi`

and `ui`

must be equal. If they are not, the projectile will be too fast or slow in that direction and cannot hit the target.

To calculate `vi`

, first find the vector between A and B, and normalize it. Then project `u`

onto `AB`

using a dot product, giving `uj`

. Subtracting `uj`

from `u`

, we get `ui`

which is equal to `vi`

.

Once `vi`

has been determined, `|vj|`

can be found by using Pythagoras theorem, since we know the magnitude `|v|`

.

Then we can multiply the unit vector `AB`

by `|vj|`

to get `vj`

, and lastly, add together `vj`

and `vi`

to get `v`

**Pseudocode**

// Find the vector AB

ABx = Bx - Ax

ABy = By - Ay

// Normalize it

ABmag = sqrt(ABx * ABx + ABy * ABy)

ABx /= ABmag

ABy /= ABmag

// Project u onto AB

uDotAB = ABx * ux + ABy * uy

ujx = uDotAB * ABx

ujy = uDotAB * ABy

// Subtract uj from u to get ui

uix = ux - ujx

uiy = uy - ujy

// Set vi to ui (for clarity)

vix = uix

viy = uiy

// Calculate the magnitude of vj

viMag = sqrt(vix * vix + viy * viy)

vjMag = sqrt(vMag * vMag - viMag * viMag)

// Get vj by multiplying it's magnitude with the unit vector AB

vjx = ABx * vjMag

vjy = ABy * vjMag

// Add vj and vi to get v

vx = vjx + vix

vy = vjy + viy

It can be interesting to note that any vector v with vi=ui, and vj in the direction of the target, will make the projectile hit the target. For example the two purple lines in the diagram. But the only one with the correct magnitude is the v we have found.

This example is in 2D, but the same method can be used in 3D by considering the plane in which the target, cannon and target velocity lies.

**Corner Cases**

It is not always certain that the cannon can hit the target. This can be the case if the target is faster than the projectile, and moving away from it. For the hit to be possible `u`

must be greater than `vi`

at the time of fire. If `u<vi`

the expression in the square root will be negative, and thus the root will be undefined, so you should have a check for that.

**Example**

Flash example

**Source code**

Flashdevelop project

## Update:

I have updated this article with some pseudo code, and to be much easier to understand.

## Update 2, the same thing in 3D:

Unity3D example and source code

I made this logo for Ludum Dare’s logo making competition.

Much improved fromÂ my first submission I think.

I recently made a new video for the timelapse material I recorded during Ludum Dare #19.

There’s some gameplay footage at the end showing what the game looked like when I submitted it, before I polishing it to the state it is in now.

You can play The Secret Documents here.

I have set up this blog as a place to share thoughts, ideas and things I make that aren’t complete enough to put on the main site.

I will post about experiments and various other things like artwork or music that I make.