View Single Post
  #8  
Old 09-02-2008, 10:39 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
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.ithis.spikes) {
    
this.updatespike(temp.i);
    if (
this.checkspike(temp.i)) {
      
this.damageplayer();
    }
  }
  
this.settimer(0.05);
}
function 
shouldspawnspike() {
  return 
random(099) < this.spikechance;
}
function 
spawnspike() {
  
temp.spike = new TStaticVar();
  
temp.spike.= <random x>;
  
temp.spike.= <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.temp.spike.x;
    
this.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*
__________________
Reply With Quote