Thread: Distance?
View Single Post
  #3  
Old 10-08-2011, 04:21 AM
pig132 pig132 is offline
professional troll
Join Date: May 2006
Posts: 260
pig132 will become famous soon enough
EDIT: Scratch that didn't need to use it.

Ran into another problem. It works great, but its pretty much doing the opposite. I've messed with the math in temp.done but its still not right. The closer I am to the player, the lower the alpha. Which is the opposite and I'm not sure how I can flip it? Also I think the distance needs to be converted to less than 1 (decimals under 1) but i'm stumped!

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
setTimer(0.05);
}

function 
onTimeout() {
  for (
temp.plallplayers) {
    if (
pl.level.name == null) continue;
    
//define distance formula
    
temp.= (pl.player.x) ^ 2;
    
temp.= (pl.player.y) ^ 2;
    
temp.= (temp.temp.b) ^ 0.5;
    
    
temp.done temp.c;
    
    
player.chat temp.done;
    
temp.pl.alpha temp.done;
  }
  
setTimer(0.05);

Sorry!

There's got to be an easier way of doing this:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
setTimer(0.05);
  
player.alpha 1;
}

function 
onTimeout() {
  for (
temp.plallplayers) {
    if (
pl.level.name == null) continue;
    
//define distance formula
    
temp.= (pl.player.x) ^ 2;
    
temp.= (pl.player.y) ^ 2;
    
temp.= (temp.temp.b) ^ 0.5;
    
    
temp.done temp.c;
    
    
//player.chat = temp.done;
    
    
if (temp.5) {
      
pl.alpha 1;
    }
    
    if (
temp.&& temp.<= 10) {
      
pl.alpha 0.75;
    }
    
    if (
temp.10 && temp.<= 15) {
      
pl.alpha 0.5;
    }
    
    if (
temp.15 && temp.<= 20) {
      
pl.alpha 0.25;
    }
    
    if (
temp.20) {
      
pl.alpha 0;
    }
  }
  
setTimer(0.05);


Last edited by pig132; 10-08-2011 at 04:39 AM..
Reply With Quote