xboxscene.org forums

Author Topic: A Fade Effect  (Read 665 times)

flattspott

  • Archived User
  • Hero Member
  • *
  • Posts: 1220
A Fade Effect
« on: September 30, 2004, 10:47:00 PM »

CODE
//   FadeEffect

MinimumBuild 1230
Gosub Start

:Loop
SetFunc Input IQPeekMsgID
If %Input% != "" Gosub InputHandler
Gosub DrawEffect
Gosub GetFade
Sub Intensity 4
Goto Loop

:InputHandler
IQWaitMsg Any
If %MSG_ID% == UI_BACK Then
   Quit
Else
   BeginDraw
 Text 320 250 Center "Fade Effect by flattspott" Red
   EndDraw
   IQClear
   IQWaitMsg Any
EndIf
Return

:Start
Set Intensity 255
Gosub GetColors
Gosub GetBoxes
Return

:GetColors
For J = 0 To 5
   For I = 0 To 2
 SetFunc ColorPart%I% CvtToBase 16 2 %($rand%255)%
   Next
   Set Color%J% %ColorPart0%%ColorPart1%%ColorPart2%
Next
Return

:GetFade
If# %Intensity% <= 0 Then
   Gosub Start
Else
   SetFunc Fade CvtToBase 16 2 %Intensity%
EndIf
Return

:GetBoxes
For X = 0 To 5
   Set BoxLeft%X% %($rand%640)%
   Set BoxTop%X% %($rand%480)%
   Set BoxHeight%X% %($rand%480)%
   Set BoxWidth%X% %($rand%640)%
Next
Return

:DrawEffect
BeginDraw
   Box %BoxLeft0% %BoxTop0% %BoxHeight0% %BoxWidth0% 0x%Fade%%Color0% 0x%Fade%%Color0%
   Box %BoxLeft1% %BoxTop1% %BoxHeight1% %BoxWidth1% 0x%Fade%%Color1% 0x%Fade%%Color1%
   Box %BoxLeft2% %BoxTop2% %BoxHeight2% %BoxWidth2% 0x%Fade%%Color2% 0x%Fade%%Color2%
   Box %BoxLeft3% %BoxTop3% %BoxHeight3% %BoxWidth3% 0x%Fade%%Color3% 0x%Fade%%Color3%
   Box %BoxLeft4% %BoxTop4% %BoxHeight4% %BoxWidth4% 0x%Fade%%Color4% 0x%Fade%%Color4%
   Box %BoxLeft5% %BoxTop5% %BoxHeight5% %BoxWidth5% 0x%Fade%%Color5% 0x%Fade%%Color5%
EndDraw
Return
 <
Logged

SumDumGuy3

  • Archived User
  • Newbie
  • *
  • Posts: 48
A Fade Effect
« Reply #1 on: October 01, 2004, 02:14:00 AM »

Well, I am trying to learn so I took the opportunity to monkey around with your script for a few minutes... Here is what I came up with...

CODE
// FadeEffect In & Out

MinimumBuild 1230
Set SwitchFades 0
Gosub GetColorsOut
Gosub GetBoxesOut
Gosub Start

:Loop
SetFunc Input IQPeekMsgID
If %Input% != "" Gosub InputHandler
Gosub DrawEffect
Gosub GetFade
Goto Loop

:InputHandler
IQWaitMsg Any
If %MSG_ID% == UI_BACK Then
EndDraw
Quit
Else
BeginDraw
Text 320 250 Center "Fade Effect by flattspott (w/slight change by SumDumGuy)" Red
EndDraw
IQClear
IQWaitMsg Any
EndIf
Return

:Start
If# %SwitchFades% == 1 Then
Set IntensityOut 0
Set IntensityIn 255
Gosub GetColorsOut
Gosub GetBoxesOut
Else
Set IntensityOut 255
Set IntensityIn 0
Set SwitchFades 0
Gosub GetColorsIn
Gosub GetBoxesIn
EndIf
Return

:GetColorsIn
For J = 0 To 2
For I = 0 To 2
SetFunc ColorPart%I% CvtToBase 16 2 %($rand%255)%
Next
Set Color%J% %ColorPart0%%ColorPart1%%ColorPart2%
Next
Return

:GetColorsOut
For J = 3 To 5
For I = 0 To 2
SetFunc ColorPart%I% CvtToBase 16 2 %($rand%255)%
Next
Set Color%J% %ColorPart0%%ColorPart1%%ColorPart2%
Next
Return

:GetFade
If# %IntensityOut% <= 0 Then
Set SwitchFades 1
GoSub Start
EndIf
If# %IntensityOut% >= 255 Then
Set SwitchFades 0
GoSub Start
EndIf
If# %SwitchFades% == 0 Then
Sub IntensityOut 4
Add IntensityIn 4
Else
Add IntensityOut 4
Sub IntensityIn 4
EndIf
SetFunc FadeOut CvtToBase 16 2 %IntensityOut%
SetFunc FadeIn CvtToBase 16 2 %IntensityIn%
Return

:GetBoxesIn
For X = 0 To 2
Set BoxLeft%X% %($rand%640)%
Set BoxTop%X% %($rand%480)%
Set BoxHeight%X% %($rand%480)%
Set BoxWidth%X% %($rand%640)%
Next
Return

:GetBoxesOut
For X = 3 To 5
Set BoxLeft%X% %($rand%640)%
Set BoxTop%X% %($rand%480)%
Set BoxHeight%X% %($rand%480)%
Set BoxWidth%X% %($rand%640)%
Next
Return

:DrawEffect
BeginDraw
Box %BoxLeft0% %BoxTop0% %BoxHeight0% %BoxWidth0% 0x%FadeIn%%Color0% 0x%FadeIn%%Color0%
Box %BoxLeft1% %BoxTop1% %BoxHeight1% %BoxWidth1% 0x%FadeOut%%Color1% 0x%FadeOut%%Color1%
Box %BoxLeft2% %BoxTop2% %BoxHeight2% %BoxWidth2% 0x%FadeIn%%Color2% 0x%FadeIn%%Color2%
Box %BoxLeft3% %BoxTop3% %BoxHeight3% %BoxWidth3% 0x%FadeOut%%Color3% 0x%FadeOut%%Color3%
Box %BoxLeft4% %BoxTop4% %BoxHeight4% %BoxWidth4% 0x%FadeIn%%Color4% 0x%FadeIn%%Color4%
Box %BoxLeft5% %BoxTop5% %BoxHeight5% %BoxWidth5% 0x%FadeOut%%Color5% 0x%FadeOut%%Color5%
EndDraw
Return


Basically, the only thing I did was break it down so that half of the boxes are fading out while the other boxes are fading in. Any given box is not randomly regenerated until it has faded all the way in and then all of the way back out. so each box appears to fade in and then fade out then a new box is created in that ones place. The idea was for it to look like it had no begining and no end. just seamlessly fading from one set of boxes to another. However, it did not work quite according to plan... there is an annoying flash/flicker each time it switches the fade effect. It is like all of the boxes flash white when they hit their peak intensity as well as at their minimum intensity? I have no idea what I have done wrong to accomplish that? But anyway, I just wanted to mess around for a minute... Now, I have really got to get some work done and get to bed...

SDG  <
Logged