# K5Splode

From KeenWiki

**K5Splode** is a tool written by Lemm in 2010. It lets you edit the galaxy explosion pattern in the game over screen in Keen 5.
This is a monochrome pattern displayed after the "preburst image", containing up to 4000 individually moving pixels.
Each pixel has a starting coordinate and an initial velocity (that is, all pixels move in straight lines).

## Usage

The program is invoked under DOS by typing:

C:\PROMPT> K5SPLODE INFILE OUTFILE

*OUTFILE*: a`5MSC0004.BIN`style file that can be imported by ModKeen.*INFILE*: a text file where each line has the following form:

`p start.bmp <X(x,y);Y(x,y)>`

*p*: an integer from 0 to 4000 that limits how many points are in this pointset. The sum of*p*from all lines must be < 4000.

*start.bmp*: a 320x200 pixel 16-color or 2-color bitmap. All non-zero (i.e., non black) pixels will be counted as points. If the number of non-zero pixels in*start.bmp*exceeds*p*, then pixels will be randomly discarded from*start.bmp*until the limit is satisfied.

*<X(x,y);Y(x,y)>*: The respective x- and y-components that describe a vector field F(x,y) = X(x,y)i + Y(x,y)j, where*i*and*j*are the unit vectors <1,0> and <0,1>. The vector field describes the velocities of every point in the pointset. All velocities are constant throughout the length of the explosion. F(x,y) is evaluated for each point by passing the x and y coordinates of the point as arguments. We consider the origin of the vector field to be at the center of the bitmap (screen 160,100), and the positive X and Y directions of the vector field to be up and right on the screen, respectively.

You may comment out a line by placing a # in the first column of text.

## Mathematical Operations

Mathematical operations you can perform. Take care with regards to division by zero and function domains.

### Arithmetic Operations

addition: | a + b |

subtraction: | a - b |

multiplication: | a * b |

division: | a / b (careful not to divide by 0!) |

exponentiation: | a ^ b |

### Power Functions

Square Root | sqrt(a) |

### Exponential & Logarithmic Functions

Exponential function | exp(a) |

Base 10 log | log(a) |

Natural log | ln(a) |

### Trigonometric Functions

Sine | sin(a) |

Cosine | cos(a) |

Tangent | tan(a) |

Inverse Sine | asin(a) |

Inverse Cosine | acos(a) |

Inverse Tangent | atan(a) |

Secant | sec(a) |

Cosecant | csc(a) |

Cotangent | cot(a) |

### Hyperbolic Functions

Hyperbolic Sine | sinh(a) |

Hyperbolic Cosine | cosh(a) |

Hyperbolic Tangent | tanh(a) |

Inverse Hyperbolic Sine | sinh(a) |

Inverse Hyperbolic Cosine | cosh(a) |

Inverse Hyperbolic Tangent | tanh(a) |

### Rounding, Absolute Value, and Remainder Functions

Sign: | 1 if a>0, -1 if a<0, 0 if a=0 sgn(a) |

Absolute Value | abs(a) |

Ceiling | ceil(a) |

Floor | floor(a) |

### Random Functions

Random Number in -a<x<a | rnd(x) |

### Predefined Constants

You can use these constants in your equations

Definition | Symbol | Value |
---|---|---|

Screen Width | scw | 320 |

Screen Height | sch | 200 |

Pi | Pi | 3.1415 (apprx.) |

e | e | 2.7183 (apprx.) |

## Examples

Runnning the program with input file instr.txt

C:\PROMPT>K5SPLODE.EXE INSTR.TXT 5MSC0004.BIN

Check out INSTR.TXT for 3 example pointsets:

#Examples. Uncomment the lines to include in 5MSC0004.BIN #(You can include multiple lines at once). #Example 1: This slides points in test1.bmp up and left, one pixel per frame #500 test1.bmp <-1;1> #Example 2: This replicates the original galaxy burst #You can change "3.2" and "2.0" to speed up the respective x and y speeds 1000 test2.bmp <3.2*x/sqrt(x^2+y^2);2.0*y/sqrt(x^2+y^2)> #Example 3: Interesting pattern. #2500 test3.bmp <0.01*y/cos(x*2*Pi/scw);0.005*x/sin(y*2*Pi/sch)>