Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: uswin on Thu 28/06/2007 18:41:33

Title: creating a thunder effect ?
Post by: uswin on Thu 28/06/2007 18:41:33
hallo everyone, i want to ask something, how can i create such a thunder effect
i mean i want my character to stepback everytime the thunder effect (lightning effect)is occured every 5/10 second concurent with shakescreen is it possible ? to create such event ?
Title: Re: creating a thunder effect ?
Post by: rancidrat on Sun 01/07/2007 16:05:57
Yeah you can do it
I dont have my manual here so I dont know the code off hand.
But what I would do is:
Make a timer when the room starts
Settimer(1,50);

then in the repeately execute section I would say this:

If (Istimerexpired(1) ==1)
{
1. play sound  --  thunder sound
2. rawdraw save screen    --- see manual under Room section
3.rawdrawimage or colour to make the lightning effect  see manual under Room section
4. wait(1)  ---Wait a short time for the people to see the effect
5. Shakescreen -- see manual under SREEN
6. rawdraw restore screen --- Lightning Flash stops
7. C.player.Move() --- make the player move back
8. Settimer(1,50) -- Reset the timer
}

If you dont know what I mean then I will paste for you the exact code from the manual. But im pretty sure this sould give you the right effect!

Title: Re: creating a thunder effect ?
Post by: uswin on Sun 01/07/2007 19:16:12
thanks guy, i am gonna try this as soon as possible !
thanks !
Title: Re: creating a thunder effect ?
Post by: Ishmael on Sun 01/07/2007 19:35:14
I'd do the flicker with a full-screen size GUI, and timing is, atleast for me, easier to control through a variable increasing with every run of repeatedly_execute, and set to zero every time the lightning strikes. You can use a random under if (lightningdelay > GetGameSpeed() * 5) to create variance in the delay, and trigger the lightning at GetGameSpeed * 10 of the variable to set the max delay to 10 seconds.
Title: Re: creating a thunder effect ?
Post by: rancidrat on Sun 01/07/2007 22:20:26
This kinda looks ok:
script for Room: Player enters room (after fadein)
 
SetTimer(1,50);

script for Room: Repeatedly execute
 

if (IsTimerExpired(1)==1)
{
PlaySound(1);       //Sound1.wav must be the thundersound
RawSaveScreen();    // Save the current screen in memory
RawClearScreen(15); // Makes the background White
Wait(10);           // Pauses the game so that you can see
RawRestoreScreen(); // Brings back the original background
ShakeScreenBackground(4, 4, 5); // Shakes the screen
SetTimer(1, Random(200));    // resets the timer
}

The other option is to put RawDrawImage(0,0,6);  instead of the RawClearScreen(15) function, where the 6 is the image slot of a background image the same as the rooms one accept for some cool lightning stuff drawn unto it.


Title: Re: creating a thunder effect ?
Post by: R4L on Mon 02/07/2007 22:06:51
Akumayo also has a module for this. Search it up.