Author Topic: Short Intro Challenge - snakeBob  (Read 4881 times)

0 Members and 1 Guest are viewing this topic.

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Short Intro Challenge - snakeBob
« 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

Old Revision: ( new further down )
Code: [Select]
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



 :||
« Last Edit: June 11, 2006 by Tetra »
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Short Intro Challenge - snakeBob
« Reply #1 on: June 10, 2006 »
Nice one !

 :||
Challenge Trophies Won:

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: Short Intro Challenge - snakeBob
« Reply #2 on: June 11, 2006 »
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

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Short Intro Challenge - snakeBob
« Reply #3 on: June 11, 2006 »
Nice one Daf :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Re: Short Intro Challenge - snakeBob
« Reply #4 on: June 11, 2006 »
Thanxs for pointing that out TD :)

Code: [Select]
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
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Short Intro Challenge - snakeBob
« Reply #5 on: June 11, 2006 »
Hey Tetra, I think you've more spare lines  ;)

Code: [Select]
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
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Short Intro Challenge - snakeBob
« Reply #6 on: June 11, 2006 »
You know, what I really love about this one is the code to generate the bobs :) Really nice.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Re: Short Intro Challenge - snakeBob
« Reply #7 on: June 11, 2006 »
\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

Code: [Select]
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
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Short Intro Challenge - snakeBob
« Reply #8 on: June 11, 2006 »
 :|| Nice  :||
Shockwave ^ Codigos
Challenge Trophies Won: