PDA

View Full Version : Shattering effect


Yen
10-24-2006, 07:48 PM
I'm really fond of this effect. I like it a lot.

Why don't I use getimgwidth/height()?
If the image isn't loaded into memory, it returns no value. I'm setting constants to the height and width, so the effect will still display even if the image hasn't been loaded yet.

function onPlayerEnters() {
this.psize = 4; // Number of columns and rows of particles to be used (x^2 is the total number of particles)
this.imgw = 32; // Width of the image being used
this.imgh = 32; // Height of the image being used
this.useimg = "block.png"; // Image to be used
hideimgs(50,50+this.psize^2);
showimg(50,this.useimg,x + 1.5 - (this.imgw/16) / 2, y + 1.5 - (this.imgh/16) / 2);
InitChips();
setTimer(.2);
}

function InitChips() {
this.cx = new[this.psize^2];
this.cy = new[this.psize^2];
this.ca = new[this.psize^2];
this.cs = new[this.psize^2];
this.cs2 = new[this.psize^2];
this.cr = new[this.psize^2];
this.cm = new[this.psize^2];
for (a = 0; a < this.psize^2; a++) {
this.cx[a] = ((this.imgw/this.psize) * (a%this.psize)) / 16;
this.cy[a] = (int(this.imgh/this.psize) * int(a/this.psize)) / 16;
this.ca[a] = random(0,pi*2);
this.cs[a] = this.cs2[a] = random(.3,.6);
this.cr[a] = 0;
this.cm[a] = int(random(0,2));
}
}

function onTimeout() {
for (b = 0; b < this.psize^2; b++) {
if (this.cy[b] > 3.5) {
hideimg(50+b);
continue;
}
showimg(50+b,this.useimg,(player.x + 1.5 - (this.imgw/16)/2) + this.cx[b],(player.y + 1.5 - (this.imgh/16)/2) + this.cy[b]);
changeimgpart(50+b, (this.imgw/this.psize) * (b%this.psize), int(this.imgh/this.psize) * int(b/this.psize), (this.imgw/this.psize), (this.imgh/this.psize));
findimg(50+b).rotation = this.cr[b];
this.cr[b] += random(pi/8,pi/12);
this.cs2[b] -= .1;
this.cy[b] -= this.cs2[b];
this.cx[b] += cos(this.ca[b]) * (this.cs[b] / 3);
if (this.cy[b] > 3.5) hideimg(50+b);
}
setTimer(.05);
}

xAndrewx
10-24-2006, 08:32 PM
lmao, cool =D

smirt362
10-24-2006, 08:54 PM
Could you give us a screenshot? I'm interested to know what it looks like.

Yen
10-24-2006, 08:55 PM
You can't really screenshot an effect that moves, like this. :(

Log on Zodiac and ask a level 20+ Ninja to use 'Seal of Water' on you.