Screen Shatter Effect

Blitz3D Forums/Blitz3D Programming/Screen Shatter Effect

JA2(Posted 2008) [#1]
Hi, I'm wanting to do a screen shatter effect in my new game as a kind of screen wipe. Does anyone have this:

http://www.blitzbasic.com/codearcs/codearcs.php?code=672


chwaga(Posted 2008) [#2]
yeah, i've been looking for that, when i really wanted on a mini brick-breaking game i made, naturally, the link was dead


Rroff(Posted 2008) [#3]
Should be fairly easy... copy the screen buffer as a texture and apply it to a surface made up of a few polygons and animate the polygons...


MadJack(Posted 2008) [#4]
There's this in the code archives;

http://www.blitzbasic.com/codearcs/codearcs.php?code=672


JA2(Posted 2008) [#5]
Thanks MadJack, but that is the code I'm referring to. The .zip file is corrupt...

I want to avoid using a texture tho, it needs to be accurate tho so I want to use a 2d effect over the 3d screen :s


MadJack(Posted 2008) [#6]
Duh - however I'm pretty sure I have it on my home system (I'm at work at present).

If you can wait another 4 hours or so, I can upload a zip.


MadJack(Posted 2008) [#7]
in the meantine, here's all the code (I think);
Function shatter()	

	For ps.pic_shard = Each pic_shard
		FreeImage ps\im:Delete ps
	Next


	img=CreateImage(GraphicsWidth(),GraphicsHeight() )
	screen_splinter_im=LoadAnimImage(("images\splinter1.png"),128,128,0,4)
	MaskImage screen_splinter_im,255,255,255

	screen_splinter2_im=LoadAnimImage(("images\splinter2.png"),128,128,0,4)
	MaskImage screen_splinter2_im,255,255,255
	
	CopyRect 0,0,GraphicsWidth(),GraphicsHeight(),0,0,FrontBuffer(),ImageBuffer(img)
	MaskImage img,255,0,0
	
	Dim matrix(GraphicsWidth()/64,GraphicsHeight()/64)

	shardsacross=(GraphicsWidth()/64)+1
	shardsdown=(GraphicsHeight()/64)+1
	
	For lp=1 To shardsacross*shardsdown
		
		; a little bit of recursion here, shouldn't be too big a deal
		Repeat
  			lpx=Rnd(1,shardsacross)-1
  			lpy=Rnd(1,shardsdown)-1		
 		Until matrix(lpx,lpy)=0	
		matrix(lpx,lpy)=1	
		
		tmp=Rand(0,3)
		
		ps.pic_shard=New pic_shard
		ps\x=lpx*64
		ps\y=lpy*64
		ps\my=(Rnd(-2,0)+(lpy-5))*(Float(GraphicsHeight())/480)
		ps\mx=(Rnd(-1,1)+(Float((lpx*2)-shardsacross)/shardsacross*5))*(Float(GraphicsWidth())/640)
		ps\im=CreateImage(128,128)
			
		CopyRect (lpx*64)-32,(lpy*64)-32,128,128,0,0,ImageBuffer(img),ImageBuffer(ps\im)
		MaskImage ps\im,255,0,0
		SetBuffer ImageBuffer(img)
		DrawImage screen_splinter_im,(lpx*64)-32,(lpy*64)-32,tmp
		SetBuffer ImageBuffer(ps\im)
		DrawImage screen_splinter2_im,0,0,tmp
		Color 255,0,0
		
		If lpy=0 Then Rect 0,0,128,32,1
		If lpy=shardsdown-1 Then Rect 0,96,128,32,1
	Next
	SetBuffer BackBuffer()
	
	FreeImage img:FreeImage screen_splinter_im:FreeImage screen_splinter2_im

End Function

Function update_splinters()
	For ps.pic_shard = Each pic_shard
		ps\y=ps\y+ps\my:ps\my=ps\my+(0.6*(Float(GraphicsHeight())/480))
		ps\x=ps\x+ps\mx
		If ps\y>GraphicsHeight()+100 Or ps\x<-100 Or ps\x>GraphicsWidth()+100 Then FreeImage ps\im:Delete ps
	Next
End Function




JA2(Posted 2008) [#8]
Thanks for the code, MadJack ;) Would be great if you have the splinter pics too :)


MadJack(Posted 2008) [#9]
http://madjack.fileburst.com/shatter.zip


JA2(Posted 2008) [#10]
Thanks MadJack :D


Yo! Wazzup?(Posted 2008) [#11]
If you weren't able to get it, I would have recomended this:

http://www.blitzbasic.com/codearcs/codearcs.php?code=727