Guest User

Untitled

a guest
Jan 12th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.20 KB | None | 0 0
  1. <?php
  2.     $snowRange = $plugin->getOption("range");
  3.    
  4.     echo "<format textcolor=\"FFFF\"/>";
  5.     for($i=0;$i<$plugin->getOption("snowflakes");$i++){
  6.         echo "<label id=\"plugin_snow_" . $i . "\" text=\"*\" posn=\"" . rand($snowRange["minX"] - 10, $snowRange["maxX"] + 10) . " " . rand($snowRange["maxY"], $snowRange["maxY"] + 190) . " 0\"/>";
  7.     }
  8.    
  9.     Maniascript::includeLibrary("MathLib", "MathLib");
  10.     Maniascript::addStaticCode(ManiascriptHook::Functions, "
  11.         Void updateTimePerFrame(){
  12.             declare Integer lastFrameTimestamp for Page;
  13.             declare Integer timePerFrame for Page;
  14.             timePerFrame = (CurrentTime - lastFrameTimestamp);
  15.             lastFrameTimestamp = CurrentTime;
  16.         }
  17.        
  18.         /*Void simulateWind(Integer i){
  19.             declare Real snowPositionX for Page;
  20.             declare Real wind = ". $plugin->getOption("wind") . " * 1.;
  21.             snowPositionX += (wind / 100);
  22.         }*/
  23.        
  24.         Void simulateTumbling(Integer i, Real h){
  25.             declare Real snowPositionX for Page;
  26.             declare Real snowTumblingForce for Page;
  27.             snowPositionX += (MathLib::Sin(h) * snowTumblingForce);
  28.         }
  29.        
  30.         Void moveFlakesVertical(Integer i){
  31.             declare Real snowPositionY for Page;
  32.             declare Real SnowFallSpeed for Page;
  33.             declare Integer timePerFrame for Page;
  34.             declare Real moveDistance = (timePerFrame * (SnowFallSpeed / 1000.0));
  35.             //declare Real moveDistance = 0.7;
  36.             snowPositionY -= moveDistance;
  37.            
  38.         }
  39.        
  40.         Void testOnBottom(Integer i){
  41.             declare Real snowPositionX for Page;
  42.             declare Real snowPositionY for Page;
  43.             if(-90 > snowPositionY){
  44.                 snowPositionX = MathLib::Rand(" . ($snowRange["minX"] - 10) . ", " . ($snowRange["maxX"] + 10) . ") * 1.;
  45.                 snowPositionY = MathLib::Rand(" . $snowRange["maxY"] . ", " . ($snowRange["maxY"] + 10) . ") * 1.;
  46.             }
  47.         }
  48.        
  49.         Void snowEventLoop(){
  50.             declare Real snowMovementHorizontal for Page;
  51.             declare Real snowPositionX for Page;
  52.             declare Real snowPositionY for Page;
  53.             declare Integer snowflakeCount for Page;
  54.             for(i,0, snowflakeCount - 1){
  55.                 declare CGameManialinkLabel snowflake = (Page.GetFirstChild(\"plugin_snow_\" ^ i) as CGameManialinkLabel);
  56.                 snowPositionX = snowflake.PosnX;
  57.                 snowPositionY = snowflake.PosnY;
  58.                 testOnBottom(i);
  59.                 moveFlakesVertical(i);
  60.                 simulateTumbling(i, snowMovementHorizontal);
  61.                 //simulateWind(i);
  62.                 snowflake.PosnX = snowPositionX;
  63.                 snowflake.PosnY = snowPositionY;
  64.                 snowMovementHorizontal += 0.1;
  65.                 if(snowMovementHorizontal == " . ($snowRange["maxX"] + 20) . ".){ snowMovementHorizontal = 0.; }
  66.             }      
  67.         }
  68.        
  69.         Void runSnow(){
  70.             snowEventLoop();
  71.             updateTimePerFrame();
  72.         }
  73.        
  74.         Void initiateSnow(){
  75.             declare Integer lastFrameTimestamp for Page = CurrentTime;
  76.             declare Real snowPositionX for Page = 0.;
  77.             declare Real snowPositionY for Page = 0.;
  78.             declare Real snowMovementHorizontal for Page = 0.;
  79.             declare Real snowTumblingForce for Page = " . $plugin->getOption("tumbling") . " * 1.;
  80.             declare Real SnowFallSpeed for Page = ". $plugin->getOption("speed") . " * 1.;
  81.             declare Integer snowflakeCount for Page = " . $plugin->getOption("snowflakes") . ";
  82.         }");
  83.     Maniascript::addStaticCode(ManiascriptHook::Start, "initiateSnow();");
  84.     Maniascript::addStaticCode(ManiascriptHook::EachFrame, "runSnow();");
  85. ?>
Add Comment
Please, Sign In to add comment