Project X Forums http://px.worms2d.info/forum/ |
|
Variable Wind http://px.worms2d.info/forum/viewtopic.php?f=13&t=404 |
Page 1 of 1 |
Author: | Pac-Man [ Tue Jan 03, 2012 11:21 pm ] | ||
Post subject: | Variable Wind | ||
A small script by me put in a lib. Probably interesting for BnG, Forts and Tower with the RubberWorm windy option. The wind is changed while the worm is moving. If the worm is on the left of the map, the wind goes right, if the worm is on the right, it goes left. If the worm is in the center, there's no wind. I put in a multiplicator to let you easily change that effect in the script. By default the maximum wind strength possible inside the map bounds is the default WA wind maximum. Code: require utils;
float _windStrength; float _multiplicator; void VariableWind::Init() { _windStrength = 0.0; // Increase the multiplicator to have stronger wind _multiplicator = 0.65; } override void CTurnGame::Message(CObject* sender, EMType type, int size, CMessageData* data) { // Calculations each frame if (type == M_FRAME) { CWorm *worm = GetCurrentWorm(); if (worm != NullObj) { // Calculate wind strength _windStrength = (worm->PosX - GS->LevelSX / 2) / GS->LevelSX * -_multiplicator; Env->Wind = _windStrength; CMessageData* messageData = new CMessageData; messageData->fparams[0] = _windStrength; Root->Message(Root, M_UPDATEWIND, 4, messageData); } } super; }
|
Author: | oinky [ Wed Jan 04, 2012 3:17 pm ] |
Post subject: | Re: Variable Wind |
This is exactly what I needed! Thanks! |
Author: | Pac-Man [ Wed Jan 04, 2012 3:56 pm ] |
Post subject: | Re: Variable Wind |
Also nice for Tower and Forts, I just noticed ![]() |
Author: | Curtis [ Sun Mar 18, 2012 5:00 am ] |
Post subject: | Re: Variable Wind |
wicked.... Can think of few good uses for this.......good idea dude..... |
Author: | Pac-Man [ Mon Mar 19, 2012 6:58 pm ] |
Post subject: | Re: Variable Wind |
As we saw its nice for windy rubber shopper ![]() |
Author: | Atr0x [ Thu Nov 22, 2012 4:52 pm ] |
Post subject: | Re: Variable Wind |
and make variable wind during turn ? |
Author: | Danylo [ Tue Jul 29, 2014 2:18 pm ] |
Post subject: | Re: Variable Wind |
interesting script... :) btw, does this modification better in performance? i mean remembering current worm PosX and avoiding superfluous calculations? Code: require utils; also Root->IsTimerActive() check is also useful i think. there is no need to reset wind if false.
float _windStrength; float _multiplicator; int posXLastFrame; void wind::Init() { _windStrength = 0.0; // Increase the multiplicator to have stronger wind _multiplicator = 0.65; } override void CWorm::Message(CObject* sender, EMType type, int size, CMessageData* data) { super; if (this != GetCurrentWorm()) return; // Calculations each frame if (type == M_FRAME && posXLastFrame != PosX && Root->IsTimerActive()) { // Calculate wind strength _windStrength = (PosX - GS->LevelSX / 2) / GS->LevelSX * -_multiplicator; Env->Wind = _windStrength; CMessageData* messageData = new CMessageData; messageData->fparams[0] = _windStrength; Root->Message(Root, M_UPDATEWIND, 4, messageData); // Remember worm's horizontal position posXLastFrame = PosX; } } |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |