Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-24-2006, 07:48 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Shattering effect

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.

PHP Code:
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,1.5 - (this.imgw/16) / 21.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 (
0this.psize^2a++) {
    
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 (
0this.psize^2b++) {
    if (
this.cy[b] > 3.5) {
      
hideimg(50+b);
      continue;
    }
    
showimg(50+b,this.useimg,(player.1.5 - (this.imgw/16)/2) + this.cx[b],(player.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.5hideimg(50+b);
  }
  
setTimer(.05);

Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:15 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.