123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|341|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> blobs

Sun, 12 Aug 2007, 05:23
spinal
first of all, this isn't my code, I rescued it from the old blitzcoder showcase.


It creates a really cool 2D metaball type effect.




If tried to get this to work in C on the DS, but no luck yet, no matter what I do, it doesn't work. To speed it up I tried dropping the palette and lookup table created here in to a const array and although it speeded up the execution, it did nothing to get the damn thing working.

Anyway, enjoy the blitz version.

-=-=-
Check out my excellent homepage!
Sun, 12 Aug 2007, 06:54
mike_g
Yeah thats a nice effect, I have seen pretty much the same thing coded onto a web page in javascript, which was quite impressive. I dunno how you would fix it for the DS tho.
Sun, 12 Aug 2007, 06:59
Jayenkai
What's up with the DS version, then? Any ideas?

If you need any extra speed, you might want to make Sin and Cos into lookup arrays instead of using the inbuilt maths. I don't know if it's any quicker on the DS, but it sure as hell was on an MS Smartphone!

-=-=-
''Load, Next List!''
Sun, 12 Aug 2007, 08:25
spinal
the sin/cos doesnt bother me right now, i just wand it to display properly.

the ds version crashes no$gba, it run is dsemume, but not properly. I haven't a clue whats wrong, I converted the code line by line, the c code should be exactly the same as tbe blitz.

give it a try yourself, I just modified the 8bitdraw example, just paste over that.

here is what I have so far. It doesn't work on hardware either.

main.c



8bit.h


8bit.c


-=-=-
Check out my excellent homepage!
Mon, 13 Aug 2007, 04:48
spinal
I found this

https://www.niksula.cs.hut.fi/~hkankaan/Homepages/metaballs.html

it says its better for finding the edges than the above method, but its in python. I dont know python but I will try to convert it to blitz first. I might be back to complain in an hour or so...

-=-=-
Check out my excellent homepage!
Mon, 13 Aug 2007, 04:58
Jayenkai
Good luck!
Mon, 13 Aug 2007, 05:22
spinal
Python doesn't look too complicated (at first glance).

|edit|

I haven't got very far, but from what I can tell, its the same as the blitz code at the top. I'm going to give up.

-=-=-
Check out my excellent homepage!
Tue, 14 Aug 2007, 13:54
JL235
Just out of curiosity, I've just done a straight port of your code to Java.

As I'm just replacing the pixels in the image with my own array rather then drawing to the surface of the image, it is over twice the speed of the Blitz version and three times faster if I disable the alpha component in the image.
Wed, 15 Aug 2007, 04:09
spinal
Java, eh.... how would I go about running that?

also, I tracked the emulator crash to the following line,
PA_Put8bitPixel(0,x,y,x);
Perhaps it doesn't like being called so often/quickly.
Looks like I'll have to find the 'proper' way to put a pixel on the ds.

-=-=-
Check out my excellent homepage!
Wed, 15 Aug 2007, 06:22
mike_g
It shouldent be too hard to port back to C again. The emulator shouldent crash tho no matter how many times you call PA_Put8bitPixel(), so theres probably something you are doing wrong with it. Perhaps drawing outside of the buffer? That could cause the program to crash.

Like diablo said its faster reading from, and drawing to an array then an image surface. I now tend to make a screen array, do all the drawing stuff to that, then to render just copy the array to the screen buffer.


Fri, 17 Aug 2007, 01:00
Afr0
The emulator shouldent crash tho no matter how many times you call PA_Put8bitPixel(), so theres probably something you are doing wrong with it.


Actually, yes. He might be looking at a buffer/memory overflow, or perhaps even stack overflow. To test this he should decrease the range of his for-loop, or maybe even while loop (to check if the cause could be elsewhere).

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Fri, 17 Aug 2007, 03:42
spinal
I got it working (mostly) I will post it later. The only think is I think the sin/cos are using radians, not degrees. I will have to try to remember how to convert them, deg*180/Pi or something like that.

-=-=-
Check out my excellent homepage!
Fri, 17 Aug 2007, 06:06
JL235
Is there not a maths library you could use? Most have a toRadians and toDegrees methods.
Fri, 17 Aug 2007, 06:44
Jayenkai


^ That's what I used, anyway!

-=-=-
''Load, Next List!''
Fri, 17 Aug 2007, 07:13
mike_g
Or you could cut out some of the extra maths:

|edit| Actually, I dident realise jays code made a look up table. That would be faster |edit|


Actually, yes. He might be looking at a buffer/memory overflow, or perhaps even stack overflow. To test this he should decrease the range of his for-loop, or maybe even while loop (to check if the cause could be elsewhere).

Sorry but I dont see how a write pixel function on its own can blow the stack.


Sun, 19 Aug 2007, 17:22
spinal
ok, here is the working C ds version, use the 8bit.c and 8bit.h from the post higher up.
remember this is for palib, so only the amr9 code is here.

|edit| the resolution is halved cos its quite slow.




hope someone finds it useful. |edit|


All I need to do now, is find a blitz version of the flurry screensaver...

-=-=-
Check out my excellent homepage!
Sun, 19 Aug 2007, 17:25
JL235
One cheat you can do is to only draw if the pixel variable is above a certain value. This means very dark pixels are skipped and adds a small speed boost. I tried it in my Java version, and it's not too bad.
Mon, 20 Aug 2007, 02:27
spinal
the next version is going to do that, also it will use sprites. I'm going to only render each point -15 to +15. I had it working a couple of days ago, but I killed it

-=-=-
Check out my excellent homepage!
Sun, 17 Oct 2010, 08:12
spinal
Here's a good question, If you take the fist code, remove all but three of the points, can anyone think of a good way to make each point a different colour?




-=-=-
Check out my excellent homepage!
Sun, 17 Oct 2010, 08:30
Jayenkai


All tweaks are done in the bottommost for x/y loop..

-=-=-
''Load, Next List!''
Sun, 17 Oct 2010, 08:43
spinal
Well, that was... fast! Many thanks Jay!

|edit| I assume adding a 4th colour would completely f*ck everything up?

-=-=-
Check out my excellent homepage!
Sun, 17 Oct 2010, 09:36
spinal
wait a second...

they don't blob together any more

-=-=-
Check out my excellent homepage!
Sun, 17 Oct 2010, 09:38
Jayenkai
Yeah, well, they're different colours! What you'd need to do is do "Red = Red full + bit of green + bit of blue", and so on. Then they'll "blob" a wee bit more..

-=-=-
''Load, Next List!''