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 / [DBP] - Amoeba

Author
Message
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Apr 2011 15:07
Took a little bit of thinking, but managed to get an ellipse to stretch/contract in the direction it's moving towards the cursor. It's like an amoeba inching it's way around. I used IanM's matrix1 plugin to do the flood fill on the ellipse. If you don't have the plugin you can simply remove the two fill commands and still be able to see the effect.


Version 1:


Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 26th Apr 2011 10:34
Not sure if it's supposed to do that, but occasionally the screen flashes. The whole screen becomes green for one frame (seemingly) randomly.

Nice effect though

Sven B

Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Apr 2011 19:34 Edited at: 26th Apr 2011 19:35
Yea I have noticed that, it has to do with the flood fill. It looks as though when suddenly changing the direction of movement, the lines don't match up in the first iteration and so the flood fill 'escapes' out. I'm looking to correct it. Here's an updated version, the flash hasn't been corrected in it yet, this is more of an updated work in progress.

Version 2:


Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 26th Apr 2011 21:24
Had to comment out the two sound commands, but then...


LOL!

It kind of startled me when it jumped at the cursor. Very nicely done.

Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Apr 2011 07:49
I made it after seeing your pic in the 20-liner bacteria thing. And soon as I get a handle on cubic splines, it'll look smoother.

Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 27th Apr 2011 08:17
If you need help on cubic interpolation, this snippet might help for 2d usage.

Basically, you just cubic interpolate each point separately. This pseudocode might help:



The cubic interpolation function is taken from this website http://paulbourke.net/miscellaneous/interpolation/


This image (also taken from that page) illustrates a cubic interpolation function over the interpolation variable (t in my function, mu in the website's function)


It's best to think of the vertical axis as "y [or x] position" and the horizontal axis as "time", NOT as y position over x position.

So in my video I linked to, I used two cubic interpolation functions, given the same interpolation variable. One for x position, and one for the y position.

Also note that you need four points to do true cubic interpolation. In my video, a minimum of three points are shown, but I'm actually storing at least four, all the time.
http://www.youtube.com/watch?v=xdMLNZXw7PY&t=2m50s


I figure I should elaborate, seeing as how I only posted "CUBIC INTERPOLATION" in caps in teh other thread xD


Tell me if there's a broken link to images in a thread I post, and I'll fix 'em.
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Apr 2011 13:11 Edited at: 27th Apr 2011 15:39
I believe I've used paul bourke's website before. I didn't get a chance to look over any of it yesterday, too many other things to do. But I should have some time this morning to read up on it.

Looked over it, it's pretty darn simple after looking at it! Made a quick demo using only 4 points to form an enclosed shape.


I'll convert this over to the amoeba shortly.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-03-29 08:28:45
Your offset time is: 2024-03-29 08:28:45