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 / Shatter Wipe Effect (dbpro)

Author
Message
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 3rd Jan 2003 07:17
OK, be kind, what do you think of my ShatterWipe effect?


sync on : sync rate 60
randomize timer()
set text opaque

bw = bitmap width(0)
bh = bitmap height(0)

rem --- make a sample image on bitmap 0
DrawSomething(0,0)
sync

create bitmap 1, bw, bh

t = 1
do
rem --- make a sample image in bitmap 1
DrawSomething(1,t)
inc t, 1 : if t = 3 then t = 0

set current bitmap 0
ink 16777215,0
center text bw / 2, 32, " Press any key! "
sync
wait key

ShatterWipe(1,10,8,10)
sync
loop

end

function DrawSomething(bmp,t)
set current bitmap bmp : cls 0
bw = bitmap width(bmp) : bh = bitmap height(bmp)
for i = 1 to 1000
ink rgb(rnd(255),rnd(255),rnd(255)),0
select t
case 0 : dot rnd(bw),rnd(bh) : endcase
case 1 : line rnd(bw),rnd(bh),rnd(bw),rnd(bh) : endcase
case 2 : r = rnd(40) + 10 : ellipse rnd(bw),rnd(bh),r,r : endcase
endselect
next i
endfunction


function ShatterWipe(bmp,gridwidth,gridheight,speed)
remstart
bmp = source bitmap to be displayed (size must equal to bitmap 0)

gridwidth, gridheight = number of divisions in bitmap. It's best to use values
that can easily divide into width and height of bitmap (min 4, max 20)

speed = how fast you want the blocks to fly

NOTE: function will use DRAW SPRITES LAST in order to work properly
remend

if bitmap exist(bmp) and bmp > 0
bw = bitmap width(0) : bh = bitmap height(0)

if bw = bitmap width(bmp) and bh = bitmap height(bmp)
if gridwidth 20 then gridwidth = 20
if gridheight 20 then gridheight = 20
if speed = bw
x = 0
inc y, spriteheight
endif

rem --- set direction speed of sprite
repeat : xd(i) = (rnd(speed*2) - speed) : until abs(xd(i)) > speed / 2
repeat : yd(i) = (rnd(speed*2) - speed) : until abs(yd(i)) > speed / 2
next i

draw sprites last
copy bitmap bmp,0
spritesoffscreen = 0

rem bw or sx bh or sy
Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 3rd Jan 2003 07:18
DAMN! That did'nt work! Lets try again....

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 3rd Jan 2003 07:19


Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 3rd Jan 2003 07:27
Shame it takes a while to display the effect when you press any key. And side from the blocks not rotating, its very clever...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 3rd Jan 2003 07:37
hmmm, I'm not the only one having a late night in the UK then

Some of that delay is caused by the drawing function I shoved in there, and as for rotating the blocks, ahem!... did'nt think of that

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 3rd Jan 2003 08:53
Taking MrTAToad`s suggestion, here is an updated version that has spinning blocks.



Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 3rd Jan 2003 09:00
hmmm, forgot to change:

undim yd() : undim xd()

to:

undim an() : undim yd() : undim xd()

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 3rd Jan 2003 14:13
Yes, been very late nights all through the Christmas period. Can't know I back at work though... shame...

I'll try it again later.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 3rd Jan 2003 22:57
Not bad at all, now you just need to get it to rotate around the X,Y,Z axis...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
KamaKase
22
Years of Service
User Offline
Joined: 29th Oct 2002
Location:
Posted: 4th Jan 2003 01:10
It said that the "Get Image" functions had one too many numbers after.

Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 4th Jan 2003 01:46
Hmmm, that error should'nt be showing if your using DBPro, patched with 3.1, strange...

...rotate around X,Y,Z axis...
I don't want to go too mad, after all this is only meant to be a snippet
Anyway I've made another revision, you wont see any difference when you run it, all I've done is tidied up the function a bit.



Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 4th Jan 2003 02:02
For KamaKase.

OK, if your using DBPro, remove the extra "1" off the end of the GetImage, It should still work, the blocks my look a bit blury, but as they are spinning and moving about it may not matter.

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 4th Jan 2003 02:03
Is it possible to grab a screen (which just happens to have 3D objects on it) ? If so, it would then be fairly easy to do a 3D version, consiting of x many planes...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 4th Jan 2003 02:54
Using planes in that way, is a tad above my head, something I'll have think about.

However, by modifying the ShatterWipe function slightly, I think I can produce something like what you suggest. The advantage with this version is it does'nt need an extra bitmap.



Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 4th Jan 2003 03:08
...Ahem! whoops, of course all references to the bmp parameter should've been removed first.

the line:
function ShatterWipe(bmp,columns,rows,speed)

should be:
function ShatterWipe(columns,rows,speed)

therefore:
ShatterWipe(1,10,8,8)

should be:
ShatterWipe(10,8,8)

...I must be getting tired. (yawn!)

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 4th Jan 2003 03:19
Better than being pickled...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 4th Jan 2003 18:02
Interesting


Merry Christmas to all Apollo members!
Visit [url]www.lightning-systems.co.uk[/url] :: [url]www.realgametools.net/forums[/url]
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 5th Jan 2003 16:02
Hey that's cool !
vivi
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 9th Jan 2003 00:17
This code could be used in a RPG turn base as a zoom in to battle.....or as a magic attack. Like ice as you may want it to break up.......you dont mind if i hang on to this do you ?

WHY WAIT FOR GAMES.......MAKE THEM COME TO YOU
>>>>www.sharksoft.scripterz.com<<<<<
THANKS IN ADVANCE
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 9th Jan 2003 04:37
Be my guest

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
vivi
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 10th Jan 2003 20:45
Thanks

WHY WAIT FOR GAMES.......MAKE THEM COME TO YOU
>>>>www.sharksoft.scripterz.com<<<<<
THANKS IN ADVANCE
Revolution
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location:
Posted: 11th Jan 2003 19:31
This is very good!
regujka
21
Years of Service
User Offline
Joined: 23rd Jan 2003
Location:
Posted: 23rd Jan 2003 21:06
Please send me the shader examples: regulyistvan@hotmail.com

Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 23rd Jan 2003 22:27
huh?

This post is not about shaders. I do not yet have GFX card capable of handling them, so I cannot experiment with them, a pity that.

Oh, I see what you've done, you have tagged this request on the end of a number of posts in different forums, whether they relate to shaders or not.

That's not a good idea.

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 4th Feb 2003 01:52
OK, try this, I think this will now work in DB standard, there's not much difference between this and the first version posted above.



I had to drop the following:
1) Rotating the sprites, because DB standard does not support this.
2) The Draw Sprites Last command, I believe sprites are always drawn last in DB standard (I can't remember).
3) Any references of Inc (or Dec) these two commands are not present in DB standard (well, version 1.0 anyway).

As for other wipes, I only created this wipe because I was stuck for something to do at the time, so I havn't made any others since, sorry. Perhaps next time when I have'nt anything to do

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 4th Feb 2003 02:16
...oh and:
4) Select, Case and Endselect, replaced with if's in the DrawSomething() function.

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 4th Feb 2003 22:28
Hmmm, I suspect its the use of -offsetx and -offsety, so I'll take any references to those out. They were only there for the rotation version.

I don't have a working copy of original DarkBasic any more (broke the cd) so its a bit tricky to test for compatabilty.

However, let's see if this works (fingers crossed):


...if not, don't worry, we'll get this thing to work

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.

Login to post a reply

Server time is: 2024-11-24 07:32:40
Your offset time is: 2024-11-24 07:32:40