Author Topic: Wierd accident :)  (Read 2412 times)

0 Members and 1 Guest are viewing this topic.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Wierd accident :)
« on: July 26, 2006 »
This was half made by accident.
I was trying to procedurally generate some patterns to use as textures, I made two loops, x and y and plotted if x and y = 1 and up popped a serpinski triangle! :)

Code: [Select]
' ACCIDENTAL SERPINSKI TRIANGLE!
' By Shockwave^DBF
'--------------------------------------------------------------------------

            OPTION STATIC
            OPTION EXPLICIT
           
'-------------------------------------------------------------------------
' Includes.
'-------------------------------------------------------------------------
            #define PTC_WIN
            #Include Once "tinyptc.bi"

'-------------------------------------------------------------------------
' Open Screen;
'-------------------------------------------------------------------------

        If( ptc_open( "EHHH??!", 256, 256 ) = 0 ) Then
        End -1
        End If
   
        Dim Shared As uInteger Buffer( 256 * 256 ):' Screen Buffer.


'-------------------------------------------------------------------------
'Please ditch the defs below, they are for the shit fps counter.
'Benchmark reading when nothing is happening is;
'
'-------------------------------------------------------------------------
        declare sub millisecs()
        DIM SHARED AS DOUBLE oldtime,newtime
        dim shared ticks,t as integer
       
'-------------------------------------------------------------------------
' Main Loop;
'-------------------------------------------------------------------------
dim x,y,cc as integer
    DO
       
       
        for y=0 to 255
        cc=Y*256
        for x=0 to 255
            if (x and y) = 1 then
            buffer(cc+x) = &hffffff
            end if
        next
        next
   
   
    millisecs()
    ptc_update@buffer(0)
   
    ticks=ticks+1 :' <-- Ditch this (FPS Counter)
   
    LOOP UNTIL INKEY$ = CHR$(27)
   

'-------------------------------------------------------------------------
' Shit FPS Counter, discard.
'-------------------------------------------------------------------------

SUB Millisecs()
    dim as double t   
    t=timer
if  t-oldtime >=1 then
    newtime = ticks
    ticks=0
    oldtime=timer
    print "FPS:"+str( (newtime) )               
end if   
end sub

The pseudo code is mighty simple if you want to convert this into any other language;

Code: [Select]
        for y=0 to 255       
        for x=0 to 255
            if (x and y) = 1 then plot x,y
        next
        next
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Wierd accident :)
« Reply #1 on: July 26, 2006 »
I was expecting something more along the lines of this classic texture;

Code: [Select]
        for y=0 to 255       
        for x=0 to 255         
            buffer (cc+x) = x xor y         
        next
next
Shockwave ^ Codigos
Challenge Trophies Won: