Dark Bit Factory & Gravity
GENERAL => Challenges & Competitions => Topic started by: Tetra on June 10, 2006
-
Heres my second entry.
It generates 3 images and moves them about the screen without clearing the background. Exactly 20 lines too :D
Nothing fancy.
Download code and exe: www.tetrahedron.me.uk/snakeBob.rar (http://www.tetrahedron.me.uk/snakeBob.rar)
Old Revision: ( new further down )
Graphics 640,480,32,2
Image = CreateImage(32,32,4)
bgImg = CreateImage(640,480)
For x = 0 To 32 * 32
h = Sqr(((x Mod 32)-16)*((x Mod 32)-16)+((x/32)-16)*((x/32)-16))
If (h < 16) Then WritePixel( x Mod 32, x / 32, (255 - (Sqr(((x Mod 32)-4)*((x Mod 32)-4)+((x/32)-4)*((x/32)-4))*7))   , ImageBuffer(image,0) )
If (h < 16) Then WritePixel( x Mod 32, x / 32, (255 - (Sqr(((x Mod 32)-4)*((x Mod 32)-4)+((x/32)-4)*((x/32)-4))*7))Shl 8, ImageBuffer(image,1) )
If (h < 16) Then WritePixel( x Mod 32, x / 32, (255 - (Sqr(((x Mod 32)-4)*((x Mod 32)-4)+((x/32)-4)*((x/32)-4))*7))Shl 16, ImageBuffer(image,2) )
Next
While Not KeyDown( 1 )
DrawImage( bgImg, 0, 0 )
i# = (i# + 2.4) Mod 360
j# = (j# + 1) Mod 360
DrawImage( Image, (Sin(i   ) * 300)+304, (Cos(j   ) * 200)+224, 0 )
DrawImage( Image, (Cos(i + 120) * 300)+304, (Sin(j + 120) * 200)+224, 1 )
DrawImage( Image, (Sin(i + 240) * 300)+304, (Cos(j + 240) * 200)+224, 2 )
Flip
GrabImage( bgImg, 0,0 )
Cls
Wend
(http://www.tetrahedron.me.uk/snakebobss.png)
:||
-
Nice one !
:||
-
Tetra, since your grabbing the previous buffer and drawing it over the top of the last you dont really need the cls ;)
Now you have 1 more line to fill ;D
-
Nice one Daf :)
-
Thanxs for pointing that out TD :)
Graphics 640,480,32,2
Image = CreateImage(32,32,4)
bgImg = CreateImage(640,480)
For x = 0 To 32 * 32
h = Sqr(((x Mod 32)-16)*((x Mod 32)-16)+((x/32)-16)*((x/32)-16))
If (h < 16) Then WritePixel( x Mod 32, x / 32, (255 - (Sqr(((x Mod 32)-4)*((x Mod 32)-4)+((x/32)-4)*((x/32)-4))*7))   , ImageBuffer(image,0) )
If (h < 16) Then WritePixel( x Mod 32, x / 32, (255 - (Sqr(((x Mod 32)-4)*((x Mod 32)-4)+((x/32)-4)*((x/32)-4))*7))Shl 8, ImageBuffer(image,1) )
If (h < 16) Then WritePixel( x Mod 32, x / 32, (255 - (Sqr(((x Mod 32)-4)*((x Mod 32)-4)+((x/32)-4)*((x/32)-4))*7))Shl 16, ImageBuffer(image,2) )
Next
While Not KeyDown( 1 )
DrawImage( bgImg, 0, 0 )
i# = (i# + 2.4) Mod 360
j# = (j# + 1) Mod 360
DrawImage( Image, (Sin(i   ) * 300)+304, (Cos(j   ) * 200)+224, 0 )
DrawImage( Image, (Cos(i +Â 90) * 300)+304, (Sin(j + 270) * 200)+224, 1Â )
DrawImage( Image, (Sin(i + 180) * 300)+304, (Cos(j +Â 90) * 200)+224, 2Â )
DrawImage( Image, (Sin(i + 270) * 300)+304, (Cos(j + 180) * 200)+224, Rnd(2) )
Flip
GrabImage( bgImg, 0,0 )
Wend
-
Hey Tetra, I think you've more spare lines ;)
Graphics 640,480,32,2
Image = CreateImage(32,32,4)
For x = 0 To 32 * 32
h = Sqr(((x Mod 32)-16)*((x Mod 32)-16)+((x/32)-16)*((x/32)-16))
If (h < 16) Then WritePixel( x Mod 32, x / 32, (255 - (Sqr(((x Mod 32)-4)*((x Mod 32)-4)+((x/32)-4)*((x/32)-4))*7))   , ImageBuffer(image,0) )
If (h < 16) Then WritePixel( x Mod 32, x / 32, (255 - (Sqr(((x Mod 32)-4)*((x Mod 32)-4)+((x/32)-4)*((x/32)-4))*7))Shl 8, ImageBuffer(image,1) )
If (h < 16) Then WritePixel( x Mod 32, x / 32, (255 - (Sqr(((x Mod 32)-4)*((x Mod 32)-4)+((x/32)-4)*((x/32)-4))*7))Shl 16, ImageBuffer(image,2) )
Next
While Not KeyDown( 1 )
i# = (i# + 2.4) Mod 360
j# = (j# + 1) Mod 360
DrawImage( Image, (Sin(i   ) * 300)+304, (Cos(j   ) * 200)+224, 0 )
DrawImage( Image, (Cos(i +Â 90) * 300)+304, (Sin(j + 270) * 200)+224, 1Â )
DrawImage( Image, (Sin(i + 180) * 300)+304, (Cos(j +Â 90) * 200)+224, 2Â )
DrawImage( Image, (Sin(i + 270) * 300)+304, (Cos(j + 180) * 200)+224, Rnd(2) )
Flip
Wend
-
You know, what I really love about this one is the code to generate the bobs :) Really nice.
-
\o/ Tnx Rbraz ;D
Tnx Shockwave, You gave me an Idea :), so I changed them a little.
Its now a big mess of colors lol but heres the revision:-
Download Code and Exe: www.tetrahc.me.uk/snakeBob.rar (http://www.tetrahc.me.uk/snakeBob.rar)
Graphics 640,480,32,2
Image = CreateImage(32,32,5)
For x = 0 To 32 * 32
h = Sqr(((x Mod 32)-16)*((x Mod 32)-16)+((x/32)-16)*((x/32)-16))
If (h < 16) Then WritePixel( x Mod 32, x / 32, (255 - (Sqr(((x Mod 32)- 4)*((x Mod 32)- 4)+((x/32)- 4)*((x/32)- 4))*7)), ImageBuffer(image,0) )
If (h < 16)And( x Mod 2 = 0 )Then WritePixel( x Mod 32, x / 32, (255 - (Sqr(((x Mod 32)-16)*((x Mod 32)-16)+((x/32)-16)*((x/32)-16))*7))Shl 8 + 255 Shl 16, ImageBuffer(image,1) )
If (h < 16) Then WritePixel( x Mod 32, x / 32, (   (Sqr(((x Mod 32)-28)*((x Mod 32)-28)+((x/32)-28)*((x/32)-28))*7))Shl 16 + 255 Shl 8, ImageBuffer(image,2) )
If (h < 16) Then WritePixel( x Mod 32, x / 32, (255 - (Sqr(((x Mod 32)-28)*((x Mod 32)-28)+((x/32)-28)*((x/32)-28))*7))Shl 16, ImageBuffer(image,3) )
If (h < 16)And( x Mod 2 = 0 )And( (x/32) Mod 2 = 0 ) Then WritePixel( x Mod 32, x / 32, (255 - (h * 8))Shl 16 + (255 - (h * 8)) Shl 8+ (255 - (h * 8)) , ImageBuffer(image,4) )
Next
While Not KeyDown( 1 )
i# = (i# + 2.4) Mod 360
j# = (j# + 1) Mod 360
DrawImage( Image, ((Sin(i   ) * 300)+504) Mod 640, ((Cos(j   ) * 200)+124) Mod 480, 0 )
DrawImage( Image, ((Cos(j +Â 90) * 300)+304) Mod 640, ((Sin(i + 270) * 200)+224) Mod 480, 1 )
DrawImage( Image, ((Cos(i + 180) * 300)+104) Mod 640, ((Sin(j +Â 90) * 200)+324) Mod 480, 2 )
DrawImage( Image, ((Sin(j + 270) * 300)+404) Mod 640, ((Cos(i + 180) * 200)+424) Mod 480, 3 )
DrawImage( Image, ((Cos(j + 370) * 300)+404) Mod 640, ((Sin(i + 180) * 200)+524) Mod 480, 4 )
Flip
Wend
-
:|| Nice :||