
10-11-2007, 09:43 AM
|
|
Registered User
|
 |
Join Date: Sep 2004
Posts: 5,260
|
|
Quote:
Originally Posted by Angel_Light
[PHP] Example :
PHP Code:
function onKeyPressed() {
if (params[1] == "d") {
setShootParams(1, this.x, this.y); //[1] being the unique ID to the projectile
shoot( player.x, player.y, player.z, getangle(vecx( player.dir), vecy( player.y)), 0, 0, "idle", null); //you only used the angle once, no need for the var
}
}
function onActionProjectile2(id, hitx, hity) {
//Upon adding the ID, you can do things like
switch(temp.id) {
case 1: this.dropExplosion(2, {temp.hitx, temp.hity}); break;
case 2:
for (temp.i = 0; temp.i < 10; temp.i++) {
this.dropExplosion(2, {random(temp.hitx - 5, temp.hitx + 5, random(temp.hity - 5, temp.hity + 5});
}
break;
}
}
//Could also make it dropExplosion(explosion type, bomb type, pos) [to support the other putexplosion]
function dropExplosion(type, pos) {
putexplosion(temp.type, temp.pos[0], temp.pos[1]);
}
|
edit |
|
|
|