Author Topic: DoodleBot (PulsarLua)  (Read 4090 times)

Rick3137

  • Guest
DoodleBot (PulsarLua)
« on: May 14, 2016, 01:15:13 PM »
   I plan to make a new series of Graphics on several Basic Dialects, using multistage fractals.
 They are a lot more easier to make than games.

Code: [Select]
   
time1 = timerticks()
time2 = 0
win = openwindow ("Fractal Test",-1,-1,800,600)
setactivewindow (win)

textsize(2)
backcolor (100,140,180,255)

--cls()   
Pi2=6.28318 ; Type = 3 ; Count = 0 ; Count2 = 0
 Ang1 = Pi2/Type ; Ang = 0 ; x = 490 ; y = 580
 red = 100 ; green = 0 ; blue = 255
 color (255,0,0,255)

 function SetColor( clr )
         if( clr == 0 ) then
          red = 0 ; green = 0 ; blue = 0
         end
         if( clr == 1 ) then
          red = 255 ; green = 200 ; blue = 200
         end
         if( clr == 2 ) then
          red = 255 ; green = 0 ; blue = 0
         end
         if( clr == 3 ) then
          red = 255 ; green = 200 ; blue = 0
         end
         if( clr == 4 ) then
          red = 255 ; green = 255 ; blue = 0
         end
         if( clr == 5 ) then
          red = 0 ; green = 255 ; blue = 0
         end
         if( clr == 6 ) then
          red = 0 ; green = 0 ; blue = 255
         end
         if( clr == 7 ) then
          red = 255 ; green = 0 ; blue = 255
         end
         if( clr == 8 ) then
          red = 200 ; green = 200 ; blue = 200
         end
         if( clr == 9 ) then
          red = 255 ; green = 255 ; blue = 255
         end
         if( clr == 10 ) then
          red = 100 ; green = 100 ; blue = 100
         end
          if( clr == 11 ) then
          red = 200 ; green = 180 ; blue = 160
         end
          if( clr == 12 ) then
          red = 200 ; green = 0 ; blue = 0
         end
          if( clr == 13 ) then
          red = 200 ; green = 160 ; blue = 0
         end
          if( clr == 14 ) then
          red = 200 ; green = 200 ; blue = 0
         end
          if( clr == 15 ) then
          red = 0 ; green = 200 ; blue = 0
         end
          if( clr == 16 ) then
          red = 0 ; green = 0 ; blue = 200
         end
          if( clr == 17 ) then
          red = 200 ; green = 0 ; blue = 200
         end
          if( clr == 18 ) then
          red = 150 ; green = 0 ; blue = 0
         end
          if( clr == 19 ) then
          red = 0 ; green = 150 ; blue = 0
         end
          if( clr == 20 ) then
          red = 0 ; green = 0 ; blue = 150
         end
          if( clr == 21 ) then
          red = 100 ; green = 0 ; blue = 0
         end
          if( clr == 22 ) then
          red = 0 ; green = 100 ; blue = 0
         end
         if( clr == 23 ) then
          red = 0 ; green = 0 ; blue = 100  -- Jesus Is Comming
         end
         color (red, green, blue,255)     
   
 end

 function RotateLeft()
      Ang = Ang + Ang1
      if Ang > Pi2 then
      Ang = Ang - Pi2
  end
   
 end
 function MoveSteps ( distance )
        dx = cos(Ang) * distance
        dy = sin(Ang) * distance
        x2 = x + dx
        y2 = y - dy
        line( x,y,x2,y2)
        x = x2 ; y = y2
 end   
 function Fractal(size)
         local    cnt = 0
          Ang1 = Pi2/Type
          Count = Count + 1
          while cnt < 3
          do                 
             MoveSteps ( size )
             RotateLeft()
             cnt = cnt + 1
               if size > 10 then
                  Fractal(size/2)
               end
               
          end
 end

  x = 400 ; y = 290 ; Ang = 0     
  Count2 = 0
  color (red, green, blue,0)
   while ( Count2 < 20)
     do         
      Fractal(250)
      Count2 = Count2 + 1 ;   Ang = Count * 9
      SetColor( Count2 ) 
      end
 time2 = timerticks() - time1
drawtext("Press any key to exit ..",10,0)
drawtext( time2,10,30 )
drawtext(" ms. Drawing time ",60,30)
sync()

key=inkey()
closewindow(win)             -- This ends the program.
closeapplication()






Rick3137

  • Guest
Re: DoodleBot EGSL version
« Reply #1 on: May 14, 2016, 01:29:22 PM »
     This is the EGSL version of the fractal. I was surprised to discover that EGSL is faster than PulsarLua.
      The EGSL setup program does not work as good as the Pulsarlua setup, but Windows10 allows you to do your own setup. You can right click on any file and tell the computer what program to use to run this type of file. You can change this setting as often as you want.

Code: [Select]

      --  This program written by       Rick3137
      --   http://rb23.yolasite.com/
time1 = timerticks()
time2 = 0

Pi2=6.28318 ; Type = 3 ; Count = 0 ; Count2 = 0
 Ang1 = Pi2/Type ; Ang = 0 ; x = 490 ; y = 580
 red = 100 ; green = 0 ; blue = 255
 color (255,0,0)


 function SetColor( clr )
         if clr == 0  then
          red = 0 ; green = 0 ; blue = 0
         end
         if clr == 1  then
          red = 255 ; green = 200 ; blue = 200
         end
         if clr == 2  then
          red = 255 ; green = 0 ; blue = 0
         end
         if clr == 3  then
          red = 255 ; green = 200 ; blue = 0
         end
         if clr == 4  then
          red = 255 ; green = 255 ; blue = 0
         end
         if clr == 5  then
          red = 0 ; green = 255 ; blue = 0
         end
         if clr == 6  then
          red = 0 ; green = 0 ; blue = 255
         end
         if clr == 7  then
          red = 255 ; green = 0 ; blue = 255
         end
         if clr == 8  then
          red = 200 ; green = 200 ; blue = 200
         end
         if clr == 9  then
          red = 255 ; green = 255 ; blue = 255
         end
         if clr == 10  then
          red = 100 ; green = 100 ; blue = 100
         end
          if clr == 11  then
          red = 200 ; green = 180 ; blue = 160
         end
          if clr == 12  then
          red = 200 ; green = 0 ; blue = 0
         end
          if clr == 13  then
          red = 200 ; green = 160 ; blue = 0
         end
          if clr == 14  then
          red = 200 ; green = 200 ; blue = 0
         end
          if clr == 15  then
          red = 0 ; green = 200 ; blue = 0
         end
          if clr == 16  then
          red = 0 ; green = 0 ; blue = 200
         end
          if clr == 17  then
          red = 200 ; green = 0 ; blue = 200
         end
          if clr == 18  then
          red = 150 ; green = 0 ; blue = 0
         end
          if clr == 19  then
          red = 0 ; green = 150 ; blue = 0
         end
          if clr == 20  then
          red = 0 ; green = 0 ; blue = 150
         end
          if clr == 21  then
          red = 100 ; green = 0 ; blue = 0
         end
          if clr == 22  then
          red = 0 ; green = 100 ; blue = 0
         end
         if clr == 23  then
          red = 0 ; green = 0 ; blue = 100  -- Jesus Is Comming
         end
         color (red, green, blue)

 end
 function RotateLeft()
      Ang = Ang + Ang1
      if Ang > Pi2 then
      Ang = Ang - Pi2
  end

 end

  function MoveSteps ( distance )
        dx = cos(Ang) * distance
        dy = sin(Ang) * distance
        x2 = x + dx
        y2 = y - dy
        line( x,y,x2,y2)
        x = x2 ; y = y2
 end

function Fractal(size)
         local    cnt = 0
          Ang1 = Pi2/Type
          Count = Count + 1
          while cnt < 3
          do
             MoveSteps ( size )
             RotateLeft()
             cnt = cnt + 1
               if size > 10 then
                  Fractal(size/2)
               end

          end
 end



      -- Starts Program
      screen (1200,700,32," Fractal Speed Test ")


      color (100,0,200)
      backcolor (0,0,20)
      clearscreen()
      redraw()

      time1 = timerticks()
      x = 400 ; y = 290 ; Ang = 0
      Count2 = 0
      color (red, green, blue)
   while ( Count2 < 20)
     do
      Fractal(250)
      Count2 = Count2 + 1 ;   Ang = Count * 9
      SetColor( Count2 )
     end
    time2 = timerticks() - time1

    drawtext(10,10,"Press any key to exit ..")
    drawtext( 10,20,time1 )
    drawtext( 10,40,time2)
    drawtext(60,40," ms. Drawing time ")
    redraw()
    inkey()
      closewindow()     -- This ends the program.





















Rick3137

  • Guest
Re: DoodleBot (Small Basic)
« Reply #2 on: May 14, 2016, 02:10:20 PM »
   This is the Small Basic version. I'm still on a learning curve with this dialect.

    I tried to post this on the Small Basic website, but failed the spam bot test. It might be that stroke I had awhile back that made me a little bit unstable. I got a double dose of Religion since then and this life does not seem all that important.
    There's just a few years left to work with here, and my mind tends to drift to things of greater importance, but I still have time for Basic.

 
Code: [Select]
     

    red = rgb(255,0,0) :blue = rgb(0,0,255):green = rgb(0,255,0):violet = rgb(255,0,255):yellow = rgb(255,255,0):bluegreen = rgb(0,255,255)
    red2 = rgb(255,0,0):blue2 = rgb(255,0,0):green2 = rgb(255,0,0):violet2 = rgb(255,0,0):yellow2 = rgb(255,0,0):bluegreen2 = rgb(255,0,0)
    black = rgb(0,0,0):white = rgb(255,255,255)

   view 20,20,800,600
   color 10

   cls   
     Pi2=6.28318 : Type = 3 : Count = 0 : Count2 = 0
     Ang1 = Pi2/Type : Ang = 0 : x = 150 : y = 500
 
   color (rgb(255,0,0))

 func SetColor( clr )
         if( clr = 0 ) then
          red = 0 : green = 0 : blue = 0
         end if
         if( clr = 1 ) then
          red = 255 : green = 200 : blue = 200
         end if
         if( clr = 2 ) then
          red = 255 : green = 0 : blue = 0
         end if
         if( clr = 3 ) then
          red = 255 : green = 200 : blue = 0
         end if
         if( clr = 4 ) then
          red = 255 : green = 255 : blue = 0
         end if
         if( clr = 5 ) then
          red = 0 : green = 255 : blue = 0
         end if
         if( clr = 6 ) then
          red = 0 : green = 0 : blue = 255
         end if
         if( clr = 7 ) then
          red = 255 : green = 0 : blue = 255
         end if
         if( clr = 8 ) then
          red = 200 : green = 200 : blue = 200
         end if
         if( clr = 9 ) then
          red = 255 : green = 255 : blue = 255
         end if
         if( clr = 10 ) then
          red = 100 : green = 100 : blue = 100
         end if
          if( clr = 11 ) then
          red = 200 : green = 180 : blue = 160
         end if
          if( clr = 12 ) then
          red = 200 : green = 0 : blue = 0
         end if
          if( clr = 13 ) then
          red = 200 : green = 160 : blue = 0
         end if
          if( clr = 14 ) then
          red = 200 : green = 200 : blue = 0
         end if
          if( clr = 15 ) then
          red = 0 : green = 200 : blue = 0
         end if
          if( clr = 16 ) then
          red = 0 : green = 0 : blue = 200
         end if
          if( clr = 17 ) then
          red = 200 : green = 0 : blue = 200
         end if
          if( clr = 18 ) then
          red = 150 : green = 0 : blue = 0
         end if
          if( clr = 19 ) then
          red = 0 : green = 150 : blue = 0
         end if
          if( clr = 20 ) then
          red = 0 : green = 0 : blue = 150
         end if
          if( clr = 21 ) then
          red = 100 : green = 0 : blue = 0
         end if
          if( clr = 22 ) then
          red = 0 : green = 100 : blue = 0
         end if
         if( clr = 23 ) then
          red = 0 : green = 0 : blue = 100 
         end if
         color ( rgb(red, green, blue))     
   
 end
 func RotateLeft()
      Ang = Ang + Ang1
      if Ang > Pi2 then
      Ang = Ang - Pi2
  end if
   
 end
 
 func MoveSteps ( distance )
        dx = cos(Ang) * distance
        dy = sin(Ang) * distance
        x2 = x + dx
        y2 = y - dy
        line x,y,x2,y2
        x = x2 : y = y2
 end function
   
 func Fractal(size)
         local  cnt = 0
          Ang1 = Pi2/Type
          Count = Count + 1
          while cnt < 3
                         
             MoveSteps ( size )
             RotateLeft()
             cnt = cnt + 1
               if size > 10 then
                  Fractal(size/2)
               end if
               
          wend
 end
 
  x = 400 : y = 290 : Ang = 0     
  Count2 = 0

 color (blue)
 while ( Count2 < 20)       
     Fractal(250)
     Count2 = Count2 + 1 :   Ang = Count2 * 9
     SetColor( Count2 )
     
  wend
 
 ?"Press any key to exit .."
 
    repeat : until (inkey$ <> "" )
 end






 
 
« Last Edit: May 14, 2016, 04:14:44 PM by Rick3137 »

B+

  • Guest
Re: DoodleBot (PulsarLua)
« Reply #3 on: May 14, 2016, 04:54:43 PM »
Hi Rick,

If Small Basic does not want this, SmallBASIC at http://smallbasic.sourceforge.net/ might as it seems to work great with in SmallBASIC version 0.12.2

I can post it for you and tell Chris you are having trouble getting in, if the above link is where you are trying to post (and not at site of MS dialect also called Small Basic but spelled/capitalized different).
« Last Edit: May 15, 2016, 01:07:35 AM by B+ »

Rick3137

  • Guest
Re: DoodleBot (PulsarLua)
« Reply #4 on: May 14, 2016, 06:41:11 PM »
      Yes, I could use a little help getting into that website.. I guess I need to study on centering my graphics. Different computer screens have a center point at a different coordinate.
      I think that the newest version works faster than what I had been using.
« Last Edit: May 14, 2016, 06:43:30 PM by Rick3137 »

B+

  • Guest
Re: DoodleBot (PulsarLua)
« Reply #5 on: May 14, 2016, 07:51:27 PM »
      Yes, I could use a little help getting into that website.. I guess I need to study on centering my graphics. Different computer screens have a center point at a different coordinate.
      I think that the newest version works faster than what I had been using.

Yes, and my snapshot may have made the centering look worse than it is (not bad for someone new to SmallBASIC).

SmallBASIC is a little different with screens, you only get one choice that is xmax by ymax pixels big (best to use the editor and output screen in a maximized Window in Windows).

xmax and ymax are built in constants like ScreenWidth and ScreenHeight always available to your program.

So the center of the screen is simply xmax/2, ymax/2
I use constants cx=xmax/2 : cy=ymax/2 because I use them so much.

I try to write programs pretending I don't know what xmax and ymax are, so they will fit any SmallBASIC's user screen.

Rick, check your messages.
« Last Edit: May 14, 2016, 08:08:47 PM by B+ »