Dark Bit Factory & Gravity

PROGRAMMING => Other languages => Blitz => Topic started by: mike_g on January 06, 2007

Title: Pompom - Amoeba things[BB2D]
Post by: mike_g on January 06, 2007
A function I am working on that draws fuzzy things. It became a bit more complex than I initially expected so I might rewrite it useing types intead of arrays. I also plan on adding rotation and improving the speed. Anyway here it is:
Code: [Select]
;GLOBAL ARRAYS NEEDED
Dim fuzzer(10, 360), fuzzdir(10, 360)
;---------------------------------------------------------------------;
;***************************** DEMO **********************************;
;---------------------------------------------------------------------;
Graphics 1024, 768
SetBuffer BackBuffer()
SeedRnd MilliSecs()
Color 200, 50, 50
FUZZ_INIT(1, 100, 360)
FUZZ_INIT(2, 100, 360)
FUZZ_INIT(3, 100, 360)
FUZZ_INIT(4, 100, 360)
FUZZ_INIT(5, 100, 360)
While Not KeyHit(1)
Cls
FUZZY_CIRCLE(1, 300, 300, 100, 160, 50, 5, 1)
FUZZY_CIRCLE(2, 800, 500, 100, 360, 50, 5, 0)
FUZZY_CIRCLE(3, 550, 200, 50, 50, 40, 3, 0)
FUZZY_CIRCLE(4, 550, 200, 50, 50, 10, 1, 0)
FUZZY_CIRCLE(5, 400, 600, 100, 20, 10, 1, 0)
Flip
Wend
;---------------------------------------------------------------------;
;*************************** FUNCTIONS *******************************;
;---------------------------------------------------------------------;
Function FUZZ_INIT(number, intense, fuzz)
For i = 1 To fuzz
fuzzer(number, i) = Rand(0, intense)
Next
End Function
;------------------------------;
Function FUZZY_CIRCLE(number, cx, cy, rad, fuzz, intense, vibration, randy)
angstep# = Float(360) / Float(fuzz)

first_x = (cx - (rad +fuzzer(number, 1)) * Cos(deg#))
first_y = (cy - (rad +fuzzer(number, 1)) * Sin(deg#))
this_x = (cx - (rad +fuzzer(number, 1)) * Cos(deg#))
this_y = (cy - (rad +fuzzer(number, 1)) * Sin(deg#))
FUZZ_MOVE(number, 1, intense, vibration, randy)

LockBuffer
For i = 2 To fuzz
deg# = deg# + angstep#
last_x = this_x
last_y = this_y
FUZZ_MOVE(number, i, intense, vibration, randy)
this_x = (cx - (rad +fuzzer(number, i)) * Cos(deg#))
this_y = (cy - (rad +fuzzer(number, i)) * Sin(deg#))
Line last_x, last_y, this_x, this_y
Next
Line this_x, this_y, first_x, first_y
UnlockBuffer
End Function
;-------------------------------;
Function FUZZ_MOVE(number, i, intense, vibration, randy)
If fuzzdir(number, i) = 0
fuzzer(number, i) = fuzzer(number, i) + vibration +Rand(0, randy)
Else
fuzzer(number, i) = fuzzer(number, i) - vibration -Rand(0, randy)
EndIf

If fuzzer(number, i) >= intense
fuzzdir(number, i) = 1
Else If fuzzer(number, i) <= -intense
fuzzdir(number, i) =0
EndIf
End Function
Title: Re: Pompom - Amoeba things
Post by: Ghost^BHT on January 06, 2007
Very cool :) 
Title: Re: Pompom - Amoeba things
Post by: Clyde on January 06, 2007
That is awesome dude, welldone indeed :)
Title: Re: Pompom - Amoeba things
Post by: zawran on January 12, 2007
Thats pretty cool. It could be used for some kind of asteroid like enemies. Invasion of the fuzzies.
Title: Re: Pompom - Amoeba things
Post by: taj on January 12, 2007

Mike_g

Any chance of an exe? We dont all have basic here.
Title: Re: Pompom - Amoeba things
Post by: zawran on January 12, 2007
I have compiled it and put it online. You can download it from here:  amoebe (http://zac-interactive.dk/temp/amoebe.zip)
Title: Re: Pompom - Amoeba things
Post by: mike_g on January 13, 2007
Hey zawran thanks for putting an exe up for me. I would have done so myself but havent been paying much attention to the Blitz forums the last couple of days. Anyway have some karma :) and yeah Im working on a little vector graphics game at the moment so i might put them in as evil wobbly blobs.
Title: Re: Pompom - Amoeba things
Post by: benny! on January 13, 2007
Very nice. I liked the one at the left bottom best ! Thanks for supplying an exe as
I do not have Blitz either !!!
Title: Re: Pompom - Amoeba things
Post by: rdc on January 13, 2007
Cool indeed mike_g. Thanks for the exe zawran.
Title: Re: Pompom - Amoeba things
Post by: mike_g on January 14, 2007
Hey I'm glad you guys like it. I had a go at filling them using a (slightly crude) floodfill I made but it runs too slow if I use it each loop. The best way I can think of would be to start off with a fill and then switch only the pixels that need changing but I dont think i'm clever enough to work that one out :(

Maybe I'll do a line version, as opposed to circular. That would be a bit simpler to find out what pixels need changing.

Also in future I'll make exes for stuff. I dident originally do one for this cos I wasent finished with it, but then I got distracted and started doing something else.
Title: Re: Pompom - Amoeba things
Post by: rdc on January 14, 2007
This (http://www.codeproject.com/gdi/QuickFill.asp) article has some different flood-fill algos that may help. The quick-fill looks pretty good, although I haven't tried it myself.
Title: Re: Pompom - Amoeba things
Post by: mike_g on January 14, 2007
Cool :) I bookmarked it for now since i'm a little drunk, but i'll be sure to go over it tomorrow or something.
Title: Re: Pompom - Amoeba things
Post by: Clyde on January 14, 2007
Very cool stuff indeed.
Title: Re: Pompom - Amoeba things
Post by: taj on January 16, 2007
Zawran: karma++ for supplying the exe!

Nice effect mike_g...I especially like the one down the bottom right. I wonder what it would look like if you changed colour depending on distance from centre of circle (eg things in the midle of the circle darker and things outside brighter???)

Title: Re: Pompom - Amoeba things
Post by: mike_g on January 16, 2007
Quote from: taj
Nice effect mike_g...I especially like the one down the bottom right. I wonder what it would look like if you changed colour depending on distance from centre of circle (eg things in the midle of the circle darker and things outside brighter???)

Nice idea, I might do that :) but first i think I better rewrite the things using types, since the longer  leave it the more difficult it will become. At the moment I got a lot of other stuff to do for assignments I been leaving to the last minute that need to be in this week. Oh well maybe on the weekend.
Title: Re: Pompom - Amoeba things
Post by: Clyde on January 16, 2007
Dude if you've got assignments to do, get those done first matey their more important.

Looking forward to seeing what you conjur up next :)

Cheers,
Clyde :)