Arg ! I always have problem when I post on that forum !
1 times on 2 code don't show correctly !
Rem
Rem Wobble-Effect Ver 1.0
Rem
dim WE_Wobble(6)
Rem WE_Wobble(1)=Amplitude
Rem WE_Wobble(2)=Speed
Rem WE_Wobble(3)=Step
Rem WE_Wobble(4)=SYSTEM DO NOT MODIFY
Rem WE_Wobble(5)=Image XSize
Rem WE_Wobble(6)=Image YSize
Rem
Set display mode 640,480,16
sync rate 0 : sync on : sync
Rem
load image "gfx\character.jpg",1
Set cursor 0,0
Center text (bitmap width(0)/2),0,"Wobble Effect Ver1.0"
Center text (bitmap width(0)/2),16,"Author : Freddix ( freddbprojects@wanadoo.fr )"
Center text (bitmap width(0)/2),32,"Press spacekey to quit"
WE_Set_Wobble_Amplitude(8)
WE_Set_Wobble_Speed(4)
WE_Set_Wobble_Step(5)
Repeat
WE_Wobble_Effect(1,2)
paste image 2,(bitmap width(0)/2)-(WE_Wobble(5)/2),(bitmap height(0)/2)-(WE_Wobble(6)/2)
ink 0,0 : box 0,0,32,16 : ink rgb(255,255,255),0
set cursor 0,0 : print screen fps()
Sync
Until spacekey()=1
For boucle=1 to 2
if image exist(boucle)=1 then delete image boucle
next boucle
End
Rem
Function WE_wobble_Effect(_image,_imagetarget)
_memblock1=1 : _memblock2=2
if image exist(_image)=1
Rem We put the original graphic inside the first memblock slot.
make memblock from image _memblock1,_image
_length=get memblock size(_memblock1)
Rem We prepare the second memblock slot for
make memblock _memblock2,_length
_Xsize=memblock dword(_memblock1,0) : write memblock dword _memblock2,0,_Xsize
_Ysize=memblock dword(_memblock1,4) : write memblock dword _memblock2,4,_Ysize
_Depth=memblock dword(_memblock1,8) : write memblock dword _memblock2,8,_Depth
WE_Wobble(5)=_xsize : WE_Wobble(6)=_ysize
_len=_depth/8
Rem We Make The Wobble Effect Here.
_amp=WE_Wobble(1) : _speed=WE_Wobble(2) : _step=WE_Wobble(3) : _cos=WE_Wobble(4)
if _amp<1 then _amp=1
if _speed<1then _speed=1
if _step<1 then _step=1
if _cos<0 or _cos>359 then _cos=0
WE_Wobble(4)=wrapvalue(_cos+_step) : Rem We save the next 1st line cosinus value.
For boucle=0 to _ysize-1
ylinestart=12+(boucle*_xsize*_len)
ydecalage=cos(_cos)*_amp
xsizefinal=(_xsize*_len)-abs(ydecalage*_len)
_cos=wrapvalue(_cos+_speed)
Rem If shift value if 0 then we simply copy 1 line .
if ydecalage=0 then copy memblock _memblock1,_memblock2,ylinestart,ylinestart,_xsize*_len
Rem If shift is positive then we copy the desired part shifted to right of target.
if ydecalage>0
copy memblock _memblock1,_memblock2,ylinestart,ylinestart+(ydecalage*_len),xsizefinal
endif
Rem If shift is negative then we copy the desired part shifted to left of target.
if ydecalage<0
copy memblock _memblock1,_memblock2,ylinestart-(ydecalage*_len),ylinestart,xsizefinal
endif
next boucle
make image from memblock _imagetarget,_memblock2
Endif
if memblock exist(_memblock1)=1 then delete memblock _memblock1
if memblock exist(_memblock2)=1 then delete memblock _memblock2
EndFunction
REM COPY MEMBLOCK From, To, PosFrom, PosTo, Octets
Rem
Function WE_Set_Wobble_Amplitude(_amplitude)
if _amplitude<1 then _amplitude=1
WE_wobble(1)=_amplitude
EndFunction
Function WE_Set_Wobble_Speed(_Speed)
if _Speed<1 then _Speed=1
WE_wobble(2)=_Speed
EndFunction
Function WE_Set_Wobble_Step(_Step)
if _Step<1 then _Step=1
WE_wobble(3)=_Step
EndFunction