Guest User

Untitled

a guest
Jan 12th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.29 KB | None | 0 0
  1. <?php
  2.     $snowRange = $plugin->getOption("range");
  3.    
  4.     echo "<format textcolor=\"" . $plugin->getOption("particle_color") . "\"/>";
  5.     for($i=0;$i<$plugin->getOption("particle_count");$i++){
  6.         echo "<label id=\"plugin_snow_" . $i . "\" text=\"" . $plugin->getOption("particle") . "\" textsize=\"" . $plugin->getOption("particle_size") . "\" 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.             snowPositionY -= moveDistance;
  36.            
  37.         }
  38.        
  39.         Void testOnBottom(Integer i){
  40.             declare Real snowPositionX for Page;
  41.             declare Real snowPositionY for Page;
  42.             if(-90 > snowPositionY){
  43.                 snowPositionX = MathLib::Rand(" . ($snowRange["minX"] - 10) . ", " . ($snowRange["maxX"] + 10) . ") * 1.;
  44.                 snowPositionY = MathLib::Rand(" . $snowRange["maxY"] . ", " . ($snowRange["maxY"] + 10) . ") * 1.;
  45.             }
  46.         }
  47.        
  48.         Void snowEventLoop(){
  49.             declare Real snowMovementHorizontal for Page;
  50.             declare Real snowPositionX for Page;
  51.             declare Real snowPositionY for Page;
  52.             declare Integer snowflakeCount for Page;
  53.             for(i,0, snowflakeCount - 1){
  54.                 declare CGameManialinkLabel snowflake = (Page.GetFirstChild(\"plugin_snow_\" ^ i) as CGameManialinkLabel);
  55.                 snowPositionX = snowflake.PosnX;
  56.                 snowPositionY = snowflake.PosnY;
  57.                 testOnBottom(i);
  58.                 moveFlakesVertical(i);
  59.                 simulateTumbling(i, snowMovementHorizontal);
  60.                 simulateWind(i);
  61.                 snowflake.PosnX = snowPositionX;
  62.                 snowflake.PosnY = snowPositionY;
  63.                 snowMovementHorizontal += 0.1;
  64.                 if(snowMovementHorizontal == " . ($snowRange["maxX"] + 20) . ".){ snowMovementHorizontal = 0.; }
  65.             }      
  66.         }
  67.        
  68.         Void runSnow(){
  69.             snowEventLoop();
  70.             updateTimePerFrame();
  71.         }
  72.        
  73.         Void initiateSnow(){
  74.             declare Integer lastFrameTimestamp for Page = CurrentTime;
  75.             declare Real snowPositionX for Page = 0.;
  76.             declare Real snowPositionY for Page = 0.;
  77.             declare Real snowMovementHorizontal for Page = 0.;
  78.             declare Real snowTumblingForce for Page = " . $plugin->getOption("tumbling") . " * 1.;
  79.             declare Real SnowFallSpeed for Page = ". $plugin->getOption("speed") . " * 1.;
  80.             declare Integer snowflakeCount for Page = " . $plugin->getOption("particle_count") . ";
  81.         }");
  82.     Maniascript::addStaticCode(ManiascriptHook::Start, "initiateSnow();");
  83.     Maniascript::addStaticCode(ManiascriptHook::EachFrame, "runSnow();");
  84. ?>
Add Comment
Please, Sign In to add comment