Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit) (+2)

ok nice... thank you ! i did even more ! ;) there is sound with it... and if you are far you can't hear it :) (a friend helped me)

1st Script : Display the lightning randomly

var randomFrames = Math.floor(Math.random() * 241) + 60;

this.wait(randomFrames);

2nd Script : Allows you to hear the thunder from a distance; the closer you get, the louder the sound becomes

var playerX = $gamePlayer.x;

var playerY = $gamePlayer.y;

var eventX = $gameMap.event(75).x;

var eventY = $gameMap.event(75).y;

var distance = $gameMap.distance(playerX, playerY, eventX, eventY);

var maxDistance = 30; // La distance maximale à partir de laquelle le volume sera réduit à zéro

var volume = 90 - (distance * (90 / maxDistance));

if (volume > 0) {

AudioManager.playSe({ name: 'thunder9', volume: volume, pitch: 100, pan: 0 });

}