xboxscene.org forums

Author Topic: Auto Change Skin  (Read 81 times)

fornorst

  • Archived User
  • Newbie
  • *
  • Posts: 22
Auto Change Skin
« on: September 07, 2003, 08:48:00 AM »

CODE

DEF theBackground Background
{    
    skyColor 0 0 0      
    backdrop ImageTexture { url "xboxbg.xbx" }
}


On a first time, I tried to make something like that :

CODE

var nombreBackground = 2;
    var backGround;
    nomBackground = new Array("xboxbg1.xbx","xboxbg2.xbx");
    var j = math.random() * nombreBackground;    
    var i = approximer(j);    
    if (i==1)
      {
        return backGround
        {
         skyColor 0 0 0      
         backdrop ImageTexture { url "xboxbg1.xbx" }
        }
      }  
    else
      {
        return backGround
        {
         skyColor 0 0 0      
         backdrop ImageTexture { url "xboxbg2.xbx" }
        }
      }    
}


I also wrote the approximer function which transform a float into an int. But whitout success. After a few test, i've understand that i can't wrote any code in the DEF : error 21 at each time !

Then, i tried to do that :

CODE

DEF theBackground Background
{    
    defBackGround()
}

function defBackGround()
{
   
    var nombreBackground = 2;
    var backGround;
    nomBackground = new Array("xboxbg1.xbx","xboxbg2.xbx");
    var j = math.random() * nombreBackground;
    var k = 0.66;
    var i = approximer(k);    
    if (i==1)
      {
        return backGround
        {
         skyColor 0 0 0      
         backdrop ImageTexture { url "xboxbg1.xbx" }
        }
      }  
    else
      {
        return backGround
        {
         skyColor 0 0 0      
         backdrop ImageTexture { url "xboxbg2.xbx" }
        }
      }    
}

function approximer(reel) {  // on cherche l'approximation à l'entier près du reél reel
      var compteur = 0;
      while ( reel > 1 ){
        reel = reel -1;             // reel--
        compteur = compteur + 1;    // compteur++      
      }
      if (reel >= 0.5 )
        return compteur+1;
      else
        return compteur;    
    }


But it don't work  sad.gif  Could you help me ?

PS : i'm sorry for my bad english but i'm french and i've some problems with foreign languages  unsure.gif
Logged