adapting a source script to a personnal code

Find quick help here to get you started with Hollywood

adapting a source script to a personnal code

Postby stefff285 » Fri Jan 16, 2015 12:03 pm

hi all

as i'm totally a noob, i tried to adapt this source to a personnal effect. so then the deformation works but i have no idea how to put the
same color in background than the picture, i tried BGpic but it flicks a lot. thanx a lot for help :) regards

Code: Select all

/*
** Important! Check if the used Hollywood version is at least
** version 2.0!
*/
@VERSION 2,0

/*
** external data
*/

@BRUSH 1, "logo02.png"
@BGPIC 1, "fond.png"
DisplayBGPic(1)


/*
** Highlight buttons 1
*/


/*
** Highlight buttons 2
*/





/*
** init wave parameters, dynamically adapts to brush dimensions
** input: maxwave
*/
Function p_InitWave()

   Deg = 0

   w = GetAttribute(#BRUSH, 1, #ATTRWIDTH)
   h = GetAttribute(#BRUSH, 1, #ATTRHEIGHT)

   wp = w
   w = w + 1 * 4

   cx = 640 - w
   cx = cx \ 2
   cy = 480 - h
   cy = cy \ 2

    If cx < 0
   w = w + cx
   cx = 0
    EndIf
   
    If cy < 0
   h = h + cy
   cy = 0
    EndIf
      
   CreateBrush(3, w, h)

EndFunction


/*
** Main loop
*/
Function p_MainLoop()

   Deg = Deg + 4
   If(Deg > 358) Then Deg = 0

   ; brush 3 is our buffer to work with
   SelectBrush(3)
   
     

   ; shift every line with sine value
   For y = 0 To h-2 Step 2 Do DisplayBrushPart(1, 0, y, sintable[Deg + y] * maxwave + maxwave, y, wp, 2)
   
   EndSelect

   ; user pressed close gadget, prepare brush 4
   If(shutdown = True)
      CreateBrush(4, w, h)
      SelectBrush(4)
      DisplayBGPicPart(1, cx, cy, w, h, 0, 0)
      EndSelect

      shutdown = 15
   EndIf

   ; crossfade brush 4 out with the effect still running!
   If(shutdown > 0)
      If(shutdown < 255)
         MixBrush(3, 4, shutdown)
         shutdown = shutdown + 16
      Else
         MixBrush(3, 4, 255)
         End
      EndIf
   EndIf

   ; show the result brush!
       
   DisplayBrush(3, #CENTER, #CENTER)
     
   
     

   StartTimer(1)

EndFunction

sintable = {}

pi! = 3.141592
degrad! = pi! / 180

; make a table for fast sine access first
For i = 0 To 999 Do sintable[i] = Sin(i * degrad! * 2)

; init wave settings
maxwave =5

p_InitWave()

InstallEventHandler({CloseWindow = Function() If shutdown = False Then shutdown = True EndFunction})



StartTimer(1)
StartTimer(2)
SetInterval(1, p_MainLoop, 1000/25) ; 25 fps


boxw = TextWidth("1000.0 fps")
boxh = TextHeight("1000.0 fps")
a = 25

EscapeQuit(True)

Repeat
   WaitEvent
Forever
User avatar
stefff285
 
Posts: 221
Joined: Sat Mar 03, 2012 1:59 pm
Location: dijon / france

Re: adapting a source script to a personnal code

Postby stefff285 » Sat Jan 17, 2015 1:09 pm

perhaps making a fonction() with only the BGpic and putting this fonction before the other in the set interval part ? thanx to help me pleaz
User avatar
stefff285
 
Posts: 221
Joined: Sat Mar 03, 2012 1:59 pm
Location: dijon / france

Re: adapting a source script to a personnal code

Postby Allanon » Sat Jan 17, 2015 1:35 pm

Hi steff285,
I have had a look at your code, if I've understood correctly you want to mix the deformed brush into the background, I've made some changes to your script, particularly I've changed the brush 3 creation adding the alpha channel and the brush editing adding #SELMODE_COMBO.
For the example I've used a png brush with an alphachannel so that the source brush background is transparent.

Here is the modified script, just replace the graphics with your original source file, it should works:
Code: Select all
/*
** Important! Check if the used Hollywood version is at least
** version 2.0!
*/
@VERSION 2,0

/*
** external data
*/

@BRUSH 1, "2.png", { LoadAlpha = True } ; <==================
@BGPIC 1, "1.jpg"
DisplayBGPic(1)


/*
** Highlight buttons 1
*/


/*
** Highlight buttons 2
*/





/*
** init wave parameters, dynamically adapts to brush dimensions
** input: maxwave
*/
Function p_InitWave()

   Deg = 0

   w = GetAttribute(#BRUSH, 1, #ATTRWIDTH)
   h = GetAttribute(#BRUSH, 1, #ATTRHEIGHT)

   wp = w
   w = w + 1 * 4

   cx = 640 - w
   cx = cx \ 2
   cy = 480 - h
   cy = cy \ 2

    If cx < 0
   w = w + cx
   cx = 0
    EndIf
   
    If cy < 0
   h = h + cy
   cy = 0
    EndIf
       
   CreateBrush(3, w, h, #BLACK, { AlphaChannel = True, Clear = True }) ; <=============

EndFunction


/*
** Main loop
*/
Function p_MainLoop()

   Deg = Deg + 4
   If(Deg > 358) Then Deg = 0

   ; brush 3 is our buffer to work with
   SelectBrush(3, #SELMODE_COMBO) ; <==================
   
     

   ; shift every line with sine value
   For y = 0 To h-2 Step 2 Do DisplayBrushPart(1, 0, y, sintable[Deg + y] * maxwave + maxwave, y, wp, 2)
   
   EndSelect

   ; user pressed close gadget, prepare brush 4
   If(shutdown = True)
      CreateBrush(4, w, h)
      SelectBrush(4)
      DisplayBGPicPart(1, cx, cy, w, h, 0, 0)
      EndSelect

      shutdown = 15
   EndIf

   ; crossfade brush 4 out with the effect still running!
   If(shutdown > 0)
      If(shutdown < 255)
         MixBrush(3, 4, shutdown)
         shutdown = shutdown + 16
      Else
         MixBrush(3, 4, 255)
         End
      EndIf
   EndIf

   ; show the result brush!
       
   DisplayBrush(3, #CENTER, #CENTER)
     
   
     

   StartTimer(1)

EndFunction

sintable = {}

pi! = 3.141592
degrad! = pi! / 180

; make a table for fast sine access first
For i = 0 To 999 Do sintable[i] = Sin(i * degrad! * 2)

; init wave settings
maxwave =5

p_InitWave()

InstallEventHandler({CloseWindow = Function() If shutdown = False Then shutdown = True EndFunction})



StartTimer(1)
StartTimer(2)
SetInterval(1, p_MainLoop, 1000/25) ; 25 fps


boxw = TextWidth("1000.0 fps")
boxh = TextHeight("1000.0 fps")
a = 25

EscapeQuit(True)

Repeat
   WaitEvent
Forever
User avatar
Allanon
 
Posts: 370
Joined: Sun Feb 14, 2010 8:53 pm
Location: Italy

Re: adapting a source script to a personnal code

Postby stefff285 » Sat Jan 17, 2015 6:10 pm

hello allanon

thanx a lot i go monday try this, i actually haven't my datas to try it

regards to you

stéphane
User avatar
stefff285
 
Posts: 221
Joined: Sat Mar 03, 2012 1:59 pm
Location: dijon / france

Re: adapting a source script to a personnal code

Postby Allanon » Sat Jan 17, 2015 6:23 pm

I hope it works :)
User avatar
Allanon
 
Posts: 370
Joined: Sun Feb 14, 2010 8:53 pm
Location: Italy

Re: adapting a source script to a personnal code

Postby stefff285 » Sat Jan 17, 2015 6:24 pm

ok it works nice ! i did tried on linux by wine :)
so i have to understand the COMBO command to continue

thanx a lot now i have to make my sinus scrolling text and then understand how to

regards to you yet
User avatar
stefff285
 
Posts: 221
Joined: Sat Mar 03, 2012 1:59 pm
Location: dijon / france

Re: adapting a source script to a personnal code

Postby stefff285 » Sun Jan 18, 2015 12:31 pm

ok the scrolling text rulez !

i have now the idea to make a rotozoom , i tried first this , a zoom factor but it seems to go too quickly but then i have no idea how to make it cool

here is the source
Code: Select all
@SCREEN {Mode = "FullScreen", Width = 640, Height = 480}
@BRUSH 1, "logo01.png"

x = 1
y = 1

Function p_scale()
    For x = 1 To 800
    x = x + 1
    y = y + 1
    ScaleBrush(1, x, y )
    DisplayBrush(1, 0, 0 )
    Next
EndFunction

p_scale()

EscapeQuit(True)

SetInterval(1, p_scale, 1000/50)

; begin double buffering!
BeginDoubleBuffer

Repeat
   WaitEvent
Forever


thanx a lot for helping me

yogib33r
User avatar
stefff285
 
Posts: 221
Joined: Sat Mar 03, 2012 1:59 pm
Location: dijon / france

Re: adapting a source script to a personnal code

Postby Allanon » Sun Jan 18, 2015 8:45 pm

Several mistakes here :D
I've fixed your code with some comments in it, if you have any doubt just ask ;)
Code: Select all
@SCREEN {Mode = "FullScreen", Width = 640, Height = 480}
@BRUSH 1, "logo01.png"

x = 10
y = 10
s = 1

Function p_scale()
    ; For x = 1 To 800 <-- wrong! This routne is called every frame!!
   
    ; You should also clear the frame before rendering the new graphics
    SetFillStyle(#FILLCOLOR)
    Box(0, 0, 640, 480, #BLACK)
    x = x + s
    y = y + s
    If x > 200
      s = s - 1 ; invert zoom
    ElseIf x < 10
      s = s + 1
    EndIf
   
    ;ScaleBrush(1, x, y) ; <-- THIS DESTROY THE BRUSH AFTER SEVERAL SCALES!!!
    DisplayBrush(1, 100, 100, { Width = x, Height = y })
    Flip()  ; <-- needed to change buffer since you are using DoubleBuffer!!
    ; Next
EndFunction

; p_scale() <-- not needed!

EscapeQuit(True)

SetInterval(1, p_scale, 1000/50)

; begin double buffering!
BeginDoubleBuffer

Repeat
   WaitEvent()
Forever
 
 
User avatar
Allanon
 
Posts: 370
Joined: Sun Feb 14, 2010 8:53 pm
Location: Italy

Re: adapting a source script to a personnal code

Postby stefff285 » Mon Jan 19, 2015 11:52 am

hello allalon !
thanx a lot for tips and andvices !
i will make for sure a special gr33t for you !
thanx so much

i have to make sprites now, but i have to test all this this afternoon :)

so many regards to you ^^

yogi
User avatar
stefff285
 
Posts: 221
Joined: Sat Mar 03, 2012 1:59 pm
Location: dijon / france

Re: adapting a source script to a personnal code

Postby stefff285 » Fri Jan 23, 2015 4:50 pm

ok

it's working but the only point i faild about is to center the dezoom and zoom
allanon of course you will be on the demo product after some helpy friendchip cool notes and advices you give me ^^
so the the script :

Code: Select all
@SCREEN {Mode = "ask", Width = 640, Height = 480}
@BRUSH 1, "presents.png" , {Transparency = $000000}

x = 800
y = 600
s = 4
sens = 0

Function p_scale()

    ; You should also clear the frame before rendering the new graphics

    SetFillStyle(#FILLCOLOR)
    Box(0, 0, 640, 480, $31396e)
    If sens = 0
      x = x - s    ; a tester : x -= s
      y = y - s    ; a tester : y -= s

   If x < 250
     sens = 4 ; invert zoom
   EndIf
    Else
      x = x + s    ; a tester : x += s
      y = y + s    ; a tester : y += s

   If x > 640
   sens = 0 ; invert zoom
   
   EndIf
    EndIf

    DisplayBrush(1, 100, 50, { Width = x, Height = y })

    Flip()  ; <-- needed to change buffer since you are using DoubleBuffer!!

EndFunction

EscapeQuit(True)
SetInterval(1, p_scale, 1000/50)
BeginDoubleBuffer ; begin double buffering!
Repeat
   WaitEvent()
Forever


thanx a lot

yogib33r / NoExtra^Vital-Motion!^X-men
User avatar
stefff285
 
Posts: 221
Joined: Sat Mar 03, 2012 1:59 pm
Location: dijon / france

Next

Return to Newbie questions

Who is online

Users browsing this forum: No registered users and 2 guests