PHP Code:
//#CLIENTSIDE
function onCreated() {
this.spikechance = 10; // 10 percent
this.spikebox = {<x>, <y>, <width>, <height>}; //area to spawn spikes
this.settimer(0.05);
}
function onTimeout() {
if (this.shouldspawnspike()) {
this.spikes.add(this.spawnspike());
}
for (temp.i: this.spikes) {
this.updatespike(temp.i);
if (this.checkspike(temp.i)) {
this.damageplayer();
}
}
this.settimer(0.05);
}
function shouldspawnspike() {
return random(0, 99) < this.spikechance;
}
function spawnspike() {
temp.spike = new TStaticVar();
temp.spike.x = <random x>;
temp.spike.y = <random y>;
// x and y should be in this.spikebox
return temp.spike;
}
function updatespike(spike) {
temp.spikeindex = this.spikes.index(temp.spike);
with (findimg(200 + temp.spikeindex)) {
this.x = temp.spike.x;
this.y = temp.spike.y;
// blah
}
}
function checkspike(spike) {
// Collision check
}
function damageplayer() {
// o.o
}
I like my styling better.
And that script would fill up the box, probably not what you want.
*Bored*