Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $snowRange = $plugin->getOption("range");
- echo "<format textcolor=\"FFFF\"/>";
- for($i=0;$i<$plugin->getOption("snowflakes");$i++){
- echo "<label id=\"plugin_snow_" . $i . "\" text=\"*\" posn=\"" . rand($snowRange["minX"] - 10, $snowRange["maxX"] + 10) . " " . rand($snowRange["maxY"], $snowRange["maxY"] + 190) . " 0\"/>";
- }
- Maniascript::includeLibrary("MathLib", "MathLib");
- Maniascript::addStaticCode(ManiascriptHook::Functions, "
- Void updateTimePerFrame(){
- declare Integer lastFrameTimestamp for Page;
- declare Integer timePerFrame for Page;
- timePerFrame = (CurrentTime - lastFrameTimestamp);
- lastFrameTimestamp = CurrentTime;
- }
- /*Void simulateWind(Integer i){
- declare Real snowPositionX for Page;
- declare Real wind = ". $plugin->getOption("wind") . " * 1.;
- snowPositionX += (wind / 100);
- }*/
- Void simulateTumbling(Integer i, Real h){
- declare Real snowPositionX for Page;
- declare Real snowTumblingForce for Page;
- snowPositionX += (MathLib::Sin(h) * snowTumblingForce);
- }
- Void moveFlakesVertical(Integer i){
- declare Real snowPositionY for Page;
- declare Real SnowFallSpeed for Page;
- declare Integer timePerFrame for Page;
- declare Real moveDistance = (timePerFrame * (SnowFallSpeed / 1000.0));
- //declare Real moveDistance = 0.7;
- snowPositionY -= moveDistance;
- }
- Void testOnBottom(Integer i){
- declare Real snowPositionX for Page;
- declare Real snowPositionY for Page;
- if(-90 > snowPositionY){
- snowPositionX = MathLib::Rand(" . ($snowRange["minX"] - 10) . ", " . ($snowRange["maxX"] + 10) . ") * 1.;
- snowPositionY = MathLib::Rand(" . $snowRange["maxY"] . ", " . ($snowRange["maxY"] + 10) . ") * 1.;
- }
- }
- Void snowEventLoop(){
- declare Real snowMovementHorizontal for Page;
- declare Real snowPositionX for Page;
- declare Real snowPositionY for Page;
- declare Integer snowflakeCount for Page;
- for(i,0, snowflakeCount - 1){
- declare CGameManialinkLabel snowflake = (Page.GetFirstChild(\"plugin_snow_\" ^ i) as CGameManialinkLabel);
- snowPositionX = snowflake.PosnX;
- snowPositionY = snowflake.PosnY;
- testOnBottom(i);
- moveFlakesVertical(i);
- simulateTumbling(i, snowMovementHorizontal);
- //simulateWind(i);
- snowflake.PosnX = snowPositionX;
- snowflake.PosnY = snowPositionY;
- snowMovementHorizontal += 0.1;
- if(snowMovementHorizontal == " . ($snowRange["maxX"] + 20) . ".){ snowMovementHorizontal = 0.; }
- }
- }
- Void runSnow(){
- snowEventLoop();
- updateTimePerFrame();
- }
- Void initiateSnow(){
- declare Integer lastFrameTimestamp for Page = CurrentTime;
- declare Real snowPositionX for Page = 0.;
- declare Real snowPositionY for Page = 0.;
- declare Real snowMovementHorizontal for Page = 0.;
- declare Real snowTumblingForce for Page = " . $plugin->getOption("tumbling") . " * 1.;
- declare Real SnowFallSpeed for Page = ". $plugin->getOption("speed") . " * 1.;
- declare Integer snowflakeCount for Page = " . $plugin->getOption("snowflakes") . ";
- }");
- Maniascript::addStaticCode(ManiascriptHook::Start, "initiateSnow();");
- Maniascript::addStaticCode(ManiascriptHook::EachFrame, "runSnow();");
- ?>
Add Comment
Please, Sign In to add comment