200byteDemoChallenge!

BlitzMax Forums/BlitzMax Programming/200byteDemoChallenge!

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hey this stuff is cool.

I tried to implement realtime blobby objects in 256 bytes but alas I could not do it - this is considerably over, at 397 bytes
Const Z=512,S=256,W=511
Graphics 1024,768,32
P:TPixmap=CreatePixmap(Z,Z,6)
Local Q:Byte Ptr=P.pixels
H:TImage=CreateImage(Z,Z)
For Y=0To W
    For X=0To W
        A#=Abs(S-X)
        B#=Abs(S-Y)
        R#=Max(0,S-Sqr((A*A)+(B*B)))
        T=(R*R)/S+0.5
        Q[0]=T
        Q[1]=T
        Q[2]=T
        Q[3]=255
        Q:+4
    Next
Next
DrawPixmap P,0,0
GrabImage H,0,0
SetBlend 4
Repeat
    Cls
    DrawImage H,256,128
    DrawImage H,MouseX()-S,MouseY()-S
    Flip 1
Until KeyHit(27)

But it works - and it's interactive ;-D

It could've been smaller using SetColor and Plot, eliminating the pixmap, and then doing GrabImage, but strangely this resulted in a blank image - something to do with multiple backbuffer frames I think - ie the issue which needs a pixmap to be grabbed to fix the frame lag. If that worked I might shave off 50-100 bytes, but anyway.

Also even though I specify PF_RGBA8888 for the pixmap format, it gives me an ABGR format. Duh! So if the default format on your machine is not ABGR this will not look right.