Author Topic: ASCII Plotball  (Read 4187 times)

0 Members and 1 Guest are viewing this topic.

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
ASCII Plotball
« on: July 09, 2006 »
Decided to see what sort of speed I could get doing lots of text in blitz so converted a plotball. Not sure what character font blitz uses by default, think it's actually the courier font. Anyway here's the code :)

Code: [Select]
; Globals for the 3d.
Global dots_in_ball = 1200 ; Number of points in the point table.
Global distance =250 ; Needed for perspective.
Global vx# ; X location.
Global vy# ; Y location.
Global vz# ; Z location.

; Arrays used by 3d code.
Dim points#(dots_in_ball, 2)
Graphics 640,480,0,2

SetBuffer BackBuffer()
rad#=100
long#=0
lat#=0
For t=1 To dots_in_ball
If long#>360 Then
long#=long#-360
lat#=lat#+8
  End If
x0#=rad#*(Sin(long#)*Sin(lat#))
y0#=rad#*(Sin(long#)*Cos(lat#))
z0#=(Cos(long#)*rad#)
long#=long#+8
  points#(t,0) = x0
points#(t,1) = y0
points#(t,2) = z0
Next

; Loop till esc is pressed.
While Not KeyDown(1)
Cls
threed()
Flip ; Flip the screen.
Wend
End

Function threed()
vx# = vx# + 0.5 ; X rotation speed of ball.
vy# = vy# + 0.5 ; Y rotation speed of ball.
vz# = vz# + 0.5 ; Z rotation speed of ball.

For n = 1 To dots_in_ball
x3d# = points#(n, 0)
y3d# = points#(n, 1)
z3d# = points#(n, 2)
       
ty# = ((y3d * Cos(vx#)) - (z3d * Sin(vx#)))
tz# = ((y3d * Sin(vx#)) + (z3d * Cos(vx#)))
tx# = ((x3d * Cos(vy#)) - (tz# * Sin(vy#)))
tz# = ((x3d * Sin(vy#)) + (tz# * Cos(vy#)))
ox# = tx#
tx# = ((tx# * Cos(vz#)) - (ty# * Sin(vz#)))
ty# = ((ox# * Sin(vz#)) + (ty# * Cos(vz#)))
nx  = Int(512 * (tx#) / (distance - (tz#)))+320
ny  = Int((512 * ty#) / (distance - (tz#)))+240
; Setup Color
If tz# <= 100 And tz# >= 75
red=255
grn=255
blu=255
EndIf
If tz# <= 75 And tz# >= 50
red=225
grn=225
blu=225
EndIf
If tz# <= 50 And tz# >= 25
red=200
grn=200
blu=200
EndIf
If tz# <= 25 And tz# >= 0
red=175
grn=175
blu=175
EndIf
If tz# <= 0 And tz# >= -25
red=150
grn=150
blu=150
EndIf
If tz# <= -25 And tz# >= -50
red=125
grn=125
blu=125
EndIf
If tz# <= -50 And tz# >= -75
red=100
grn=100
blu=100
EndIf
If tz# <= -75 And tz# >= -100
red=50
grn=50
blu=50
EndIf
Color red,grn,blu
Text nx,ny,Chr$(164),1,1
Next
End Function

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17394
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: ASCII Plotball
« Reply #1 on: July 09, 2006 »
That's pretty cool Tindragon.  :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17394
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: ASCII Plotball
« Reply #2 on: July 09, 2006 »
Looking at it again, it's using some extended chars as bobs, they are plotted just like sprites. I wonder how this would look if you eliminated the hidden characters and made it more of a textmode demo by making sure that the letters were plotted in standard rows and columns and not pixel perfect?
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: ASCII Plotball
« Reply #3 on: July 09, 2006 »
Neat Plotball TD. Although ever since installing Freebasic, I get the odd flickering now and again with proggies.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Re: ASCII Plotball
« Reply #4 on: July 10, 2006 »
Thats looks pretty cool, i quit like that effect. I must agree with shockwave though, ascii demos usually constrict columbs and rows, it wouldnt be that hard to do infact, if you do

nx = (nx / FontWidth()) * FontWidth()
ny = (ny / FontHeight()) * FontHeight()

but the trouble then is making it look good :)
Challenge Trophies Won:

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: ASCII Plotball
« Reply #5 on: July 10, 2006 »
I agree it's not restricted in the location it's draw like a true textmode demo, but it was more a test of how fast blitz could draw lots of characters. Besides in in the spirit by just using a text char ;)

As for the character set, well blitz uses a font for all text so I guess I could find out which is closest to the old dos font and load it in, wanted to actually use the smiley face that use to be in dos but it wasn't in the default font.


Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17394
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: ASCII Plotball
« Reply #6 on: July 10, 2006 »
Thats looks pretty cool, i quit like that effect. I must agree with shockwave though, ascii demos usually constrict columbs and rows,

but the trouble then is making it look good :)

This is the true art behind good Ascii demos and with very little tweaking this plotball could be a really cool ascii effect instead of a nice vector bobs effect.
Shockwave ^ Codigos
Challenge Trophies Won: