B2D wave image.
BlitzPlus Forums/BlitzPlus Programming/B2D wave image.
| ||
I am very curious how to make this too... |
| ||
Yeah its buggin ma head now. I know what I need to do I just cant seem to get it fast enough. so some sample coed would be nice. |
| ||
Copying pixels will certainly be slow. Try using CopyRect to copy an entire row, or column, at a time. |
| ||
Ahh. I haddnt thought of that. Got any examples of code floyd ? |
| ||
load the image as an anim image (each frame is one pixel in height or width) and draw each line of the anim image with a sin offset.. this is a very fast method Skully |
| ||
Trying that now. Keep the ideas coming. Ill post my code when I get it working. |
| ||
Yeah what skully said ... one of the demos with Blitz2d had this for a title screen. |
| ||
Well I got it in the end, thanks to Skully for the animimage idea, its one of those why the hell didnt I think of that things... Here it is. All you need to do is supply an image. it will read it and get the sizes and stuff so you dont need to worry about how big it is. ;Image Wave Test.. Graphics 640,480,16,2 SetBuffer BackBuffer() Cls Global image=LoadImage("yavin.bmp") Global Width,height width=ImageWidth(image) height=ImageHeight(image) FreeImage image image=LoadAnimImage("yavin.bmp",width,1,1,height-1) Global wave#,amp#,slice slice=1 wave=.2 amp=8 ;Main While Not KeyHit(1) Cls update() render() Flip Wend Function update() wave=wave+6 End Function Function render() For looper=1 To height-2 DrawImage image,100+Sin(wave+looper)*amp,100+looper,looper Next End Function |
| ||
I hope this helps the others as well ;) |
| ||
And you can really goto town on this.. Here is another way to render the iamge. Does a sort of blurry thing. looks sweet. Function render() For looper=1 To height-2 Step 2 DrawImage image,100+Sin(wave+looper)*amp,100+looper,looper Next For looper=2 To height-2 Step 2 DrawImage image,100-Sin(wave+looper)*amp,100+looper,looper Next End Function |
| ||
This is my final one. I learnt what I wanted to learn so here it is for the rest of you. Hope it helps Reno , thanks for the tip Skully and check it out Floyd.. ;) ; ; Demo Wave Image ; ; By Yavin @ Team Rebellion Software ; Yavin@... ; www.teamrebellion.co.uk ; ; I this small chunk of code will help all of those coders out there ; who have been wanting to make some Demo type stuff but havent been ; able to work out the wave thing. ; ; ; All I ask is that if you improve the code coudl you re post so we ; can all learn from it. Graphics 800,600,16 SetBuffer BackBuffer() Cls Global image=LoadImage("yavin.bmp") Global Width,height width=ImageWidth(image) height=ImageHeight(image) FreeImage image Global horz=LoadAnimImage("yavin.bmp",width,1,1,height-1) Global vert=LoadAnimImage("yavin.bmp",1,height,1,width-1) Global wave#,amp#,slice,render_mode slice=1 wave=.2 amp=8 render_mode=1 ;Main While Not KeyHit(1) Cls update() render() Flip Wend Function update() wave=wave+6 If KeyHit(57) render_mode=render_mode+1 End If If KeyDown(200);up amp=amp+1 End If If KeyDown(208);down amp=amp-1 End If If KeyDown(203);left wave=wave+1 End If If KeyDown(205);right wave=wave-1 End If End Function Function render() Select render_mode Case 1 For looper=1 To height-2 DrawImage horz,0+Sin(wave+looper)*amp,0+looper,looper Next Case 2 For looper=1 To height-2 Step 2 DrawImage horz,0+Sin(wave+looper)*amp,0+looper,looper Next For looper=2 To height-2 Step 2 DrawImage horz,0-Sin(wave+looper)*amp,0+looper,looper Next Case 3 For looper=1 To height-2 Step 2 DrawImage horz,0+Sin(wave+looper)*amp,0+looper,looper Next For looper=2 To height-2 Step 2 DrawImage horz,0+Sin(wave+looper)*(amp/2),0+looper,looper Next Case 4 For looper=1 To width-2 DrawImage vert,0+looper,0+Sin(wave+looper)*amp,looper Next Case 5 For looper=1 To width-2 Step 2 DrawImage vert,0+looper,0+Sin(wave+looper)*amp,looper Next For looper=2 To width-2 Step 2 DrawImage vert,0+looper,0-Sin(wave+looper)*amp,looper Next Case 6 For looper=1 To width-2 Step 2 DrawImage vert,0+looper,0+Sin(wave+looper)*amp,looper Next For looper=2 To width-2 Step 2 DrawImage vert,0+looper,0+Sin(wave+looper)*(amp/2),looper Next Case 7 render_mode=1 End Select End Function |
| ||
Hahaha.. having some fun are we? Skully |
| ||
Thank, I see how to make this effect know ! The best use of this technic I see in a game is in "Thunder force 3" and "Musha Alest" on the Genesis :) |
| ||
Yeah I think I know what your talking about, when the end of level boses faze into screen. Yeah its a nice effect. And Skully . :) how did you guess m8. After looking at another amazing demo by darkbit factory I just thought how the hell do they do that. as I havent ever tried it. and so I spent an hour or 2 battering into it and thanks to the comments posted here I was able to get it going. So ta all. Oh yeah and coding is always fun for me m8 ;) |
| ||
note that the right and left keys don't do nothing in your code as you alway add 6 to the wave value at the start of the loop. ----------------- Function update() wave=wave+6 If KeyHit(57) render_mode=render_mode+1 End If If KeyDown(200);up amp=amp+1 End If If KeyDown(208);down amp=amp-1 End If If KeyDown(203);left wave=wave+1 End If If KeyDown(205);right wave=wave-1 End If End Function you can do somthing like that Function update() wave=wave+wavevar If KeyHit(57) render_mode=render_mode+1 End If If KeyDown(200);up amp=amp+1 End If If KeyDown(208);down amp=amp-1 End If If KeyDown(203);left wavevar=wavevar+1 End If If KeyDown(205);right wavevar=wavevar-1 End If End Function |