Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Wobble Effect Ver1.0 ( memblocks )

Author
Message
Freddix
AGK Developer
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 14th Jan 2003 02:51
Here is a small snippet that make a deformation effect on 2D images . . . using cosinus.

WE_Set_Wobble_Amplitude(_amp)
- Define maximal amplitude for sinus deformation.
WE_Set_Wobble_Speed(_speed)
- define sinus speed per line.
WE_Set_Wobble_Step(_step)
- Define sinus shift for 1 line.
WE_wobble_Effect(_image,_imagetarget)
- make wobble effect from image '_image' to image '_imagetarget'

wht do you think of it ?


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 _amp359 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
Freddix
AGK Developer
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 14th Jan 2003 02:53
Arg ! I always have problem when I post on that forum !
1 times on 2 code don't show correctly !

Login to post a reply

Server time is: 2024-11-24 07:29:06
Your offset time is: 2024-11-24 07:29:06