LB Booster
« Object Oriented Liberty BASIC? »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:53am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1 2 3  Notify Send Topic Print
 veryhotthread  Author  Topic: Object Oriented Liberty BASIC?  (Read 3296 times)
bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: Object Oriented Liberty BASIC?
« Reply #10 on: Jan 20th, 2015, 11:11am »

'include error ?
or wat else do i wrong ?
_math.bas Code:
''bluatigro 20 jan 2015 :
''_math.bas
global pi , golden.ratio
pi = atn( 1 ) * 4
golden.ratio = ( sqr( 5 ) - 1 ) / 2
global true , false
true = not( false )
end
function rad( deg )
  rad = deg * pi / 180
end function
 

_color.bas Code:
'include _math.bas
''bluatigro 20 jan 2015 : 
''_color.bas
global black$ , red$ , green$ , yellow$
global blue$ , magenta$ , cyan$ , white$
global gray$ , pink$ , purple$ , orange$
black$   = rgb$( 000 , 000 , 000 )
red$     = rgb$( 255 , 000 , 000 ) 
green$   = rgb$( 000 , 255 , 000 ) 
yellow$  = rgb$( 255 , 255 , 000 ) 
blue$    = rgb$( 000 , 000 , 255 ) 
magenta$ = rgb$( 255 , 000 , 255 ) 
cyan$    = rgb$( 000 , 255 , 255 ) 
white$   = rgb$( 255 , 255 , 255 ) 
gray$    = rgb$( 127 , 127 , 127 ) 
pink$    = rgb$( 255 , 127 , 127 ) 
purple$  = rgb$( 127 , 000 , 127 ) 
orange$  = rgb$( 255 , 127 , 000 ) 
end
function rgb$( r , g , b )
  r = r and 255
  g = g and 255
  b = b and 255
  rgb$ = str$( r ); " " ; g * 256 ; " " ; b * 256 ^ 2
end function
function red( clr$ )
  red = val( word$( clr$ , 1 ) ) 
end function
function green( clr )
  green = val( word$( clr$ , 2 ) )
end function
function blue( clr$ )
  blue = val( word$( clr$ , 3 ) ) 
end function
function klmix$( kl1$ , f , kl2$ )
  r1 = red( kl1$ )
  g1 = green( kl1$ )  
  b1 = blue( kl1$ )  
  r2 = red( kl2$ )
  g2 = green( kl2$ )
  b2 = blue( kl2$ )
  r = r1 + f * ( r2 - r1 )
  g = g1 + f * ( g2 - g1 )
  b = b1 + f * ( b2 - b1 )  
  klmix$ = rgb$( r , g , b )
end function
function rainbow$( deg )
  rainbow$ = rgb$( sin( rad( deg ) ) * 127 + 128 _
                 , sin( rad( deg + 120 ) ) * 127 + 128 _
                 , sin( rad( deg - 120 ) ) * 127 + 128 )
end function  
 

_sphere.bas Code:
'include _color.bas
''bluatigro 20 jan 1015
''_sphere.bas
WindowWidth = DisplayWitdh
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight
global height
sub sphere h$ , x , y , z , d , clr$
  if abs( height - y ) < d then
    dd = sqr( d ^ 2 - ( height - y ) ^ 2 + .001 ) * 2
    kl$ = mix$( clr$ , .5 - ( height - y ) / d / 2 , black$ )
    #h$ "goto " ; x + winx / 2 ;" "; winy / 2 - height - z / 4 
    #h$ "backcolor " ; kl$
    #h$ "color" ; kl$
    #h$ "down"
    #h$ "ellipsefilled "; dd ;" "; dd / 4 
    #h$ "up"
  end if
end sub                               
 

main Code:
'include "_sphere.bas"
nomainwin
open "sphere-test" for graphics as #m
  #m "trapclose [quit]"
  for height = 0-winy/2 to winy/2
    call sphere #m , 0 , 0 , 0 , 50 , red$
  next height
wait
[quit]
  close #m
end
 
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Object Oriented Liberty BASIC?
« Reply #11 on: Jan 20th, 2015, 11:24am »

on Jan 20th, 2015, 11:11am, bluatigro wrote:
or wat else do i wrong ?

Nothing "wrong" exactly, but you are hoping that 'include can be 'nested', i.e. that one included file can include another file, etc. Unfortunately it doesn't work like that in LBB, you can only use 'include in your 'main program':

Code:
nomainwin
open "sphere-test" for graphics as #m
  #m "trapclose [quit]"
  for height = 0-winy/2 to winy/2
    call sphere #m , 0 , 0 , 0 , 50 , red$
  next height
wait
[quit]
  close #m
end
'include _sphere.bas
'include _math.bas
'include _color.bas 

As far as I'm aware LB Workshop's include has the same limitation.

Richard
« Last Edit: Jan 20th, 2015, 1:01pm by Richard Russell » User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: Object Oriented Liberty BASIC?
« Reply #12 on: Jan 20th, 2015, 2:06pm »

i tryed this Code:
nomainwin
open "" for graphics as #m
  #m "trapclose [quit]"
  #m "fill black"
  for height = 0-winy/2 to winy/2
    call sphere 0 , 0 , 0 , 50 , red$
  next height
wait
[quit]
  close #m
end
'include _math.bas
'include _color.bas
'include _sphere.bas
 

Code:
''bluatigro 20 jan 1015
''_sphere.bas

  WindowWidth = DisplayWitdh
  WindowHeight = DisplayHeight
  global winx , winy
  winx = WindowWidth
  winy = WindowHeight
  global height

sub sphere x , y , z , d , clr$
  if abs( height - y ) < d then
    dd = sqr( d ^ 2 - ( height - y ) ^ 2 + .001 ) * 2
    kl$ = mix$( clr$ , .5 - ( height - y ) / d / 2 , black$ )
    #m "goto " ; x + winx / 2 ;" "; winy / 2 - height - z / 4 
    #m "backcolor " ; kl$
    #m "color" ; kl$
    #m "down"
    #m "ellipsefilled "; dd ;" "; dd / 4 
    #m "up"
  end if
end sub                               
 

_math.bas and _color.bas are not changed

error :
- where is my red sphere
- the window isnt fulscreen
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Object Oriented Liberty BASIC?
« Reply #13 on: Jan 20th, 2015, 4:42pm »

on Jan 20th, 2015, 2:06pm, bluatigro wrote:
- where is my red sphere
- the window isnt fulscreen

I think your problem is that the code is now in the wrong sequence. Your 'included' file _sphere.bas contains both initialisation code which must come before the 'open for graphics' (e.g. setting WindowWidth and WindowHeight) and code which must come after the open statement (e.g. sub sphere). That can't work!

You either need to transfer the initialisation code into the 'main program', or you need to split your included file into two parts (e.g. _sphereinit.bas and _spheresub.bas) so you can include them in different places:

Code:
nomainwin
'include _sphereinit.bas
open "" for graphics as #m
  #m "trapclose [quit]"
  #m "fill black"
  for height = 0-winy/2 to winy/2
    call sphere 0 , 0 , 0 , 50 , red$
  next height
wait
[quit]
  close #m
end
'include _spheresub.bas 

There's nothing 'magic' about 'include: the resulting 'merged' program must follow all the usual rules governing the order in which things are declared.

Richard.
User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: Object Oriented Liberty BASIC?
« Reply #14 on: Jan 23rd, 2015, 11:30am »


update :
- all global's are now in *_init.bas

error :
- same errors

Code:
'include _fullscreen_init.bas
'include _math_init.bas
'include _color_init.bas
'include _sphere_init.bas
nomainwin
open "" for graphics as #m
  #m "trapclose [quit]"
  #m "fill black"
  for height = 0-winy/2 to winy/2
    call sphere 0 , 0 , 0 , 50 , red$
  next height
wait
[quit]
  close #m
end
'include _math.bas
'include _color.bas
'include _sphere.bas
 
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Object Oriented Liberty BASIC?
« Reply #15 on: Jan 23rd, 2015, 11:39am »

on Jan 23rd, 2015, 11:30am, bluatigro wrote:
all global's are now in *_init.bas
same errors

As documented, LBB ignores 'include directives at the very start of the program (this is to maximise compatibility with LB Workshop). If your code is exactly as you listed, that will be the explanation. Add at least one line before the first include:

Code:
' the first line must not be an include
'include _fullscreen_init.bas
'include _math_init.bas
'include _color_init.bas
'include _sphere_init.bas
nomainwin
open "" for graphics as #m
  #m "trapclose [quit]"
  #m "fill black"
  for height = 0-winy/2 to winy/2
    call sphere 0 , 0 , 0 , 50 , red$
  next height
wait
[quit]
  close #m
end
'include _math.bas
'include _color.bas
'include _sphere.bas 

Richard.
« Last Edit: Jan 23rd, 2015, 11:41am by Richard Russell » User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: Object Oriented Liberty BASIC?
« Reply #16 on: Jan 24th, 2015, 1:41pm »

tryed Code:
''bluatigro 24 jan 2015
''sphere_test.bas
'include _fullscreen_init.bas
'include _math_init.bas
'include _color_init.bas
'include _sphere_init.bas
nomainwin
open "" for graphics as #m
  #m "trapclose [quit]"
  #m "fill " ; black$
  for height = 0-winy/2 to winy/2
    call sphere 0 , 0 , 0 , 50 , red$
  next height
wait
[quit]
  close #m
end
'include _math.bas
'include _color.bas
'include _sphere.bas
 


stil not working
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Object Oriented Liberty BASIC?
« Reply #17 on: Jan 24th, 2015, 2:28pm »

on Jan 24th, 2015, 1:41pm, bluatigro wrote:
stil not working

This works perfectly for me:

_math_init.bas:
Code:
global pi , golden.ratio
pi = atn( 1 ) * 4
golden.ratio = ( sqr( 5 ) - 1 ) / 2
global true , false
true = not( false ) 

_color_init.bas:
Code:
global black$ , red$ , green$ , yellow$
global blue$ , magenta$ , cyan$ , white$
global gray$ , pink$ , purple$ , orange$
black$   = rgb$( 000 , 000 , 000 )
red$     = rgb$( 255 , 000 , 000 ) 
green$   = rgb$( 000 , 255 , 000 ) 
yellow$  = rgb$( 255 , 255 , 000 ) 
blue$    = rgb$( 000 , 000 , 255 ) 
magenta$ = rgb$( 255 , 000 , 255 ) 
cyan$    = rgb$( 000 , 255 , 255 ) 
white$   = rgb$( 255 , 255 , 255 ) 
gray$    = rgb$( 127 , 127 , 127 ) 
pink$    = rgb$( 255 , 127 , 127 ) 
purple$  = rgb$( 127 , 000 , 127 ) 
orange$  = rgb$( 255 , 127 , 000 ) 

_sphere_init.bas:
Code:
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight
global height 

_math.bas:
Code:
function rad( deg )
  rad = deg * pi / 180
end function 

_color.bas:
Code:
function rgb$( r , g , b )
  r = r and 255
  g = g and 255
  b = b and 255
  rgb$ = str$( r ); " " ; g * 256 ; " " ; b * 256 ^ 2
end function
function red( clr$ )
  red = val( word$( clr$ , 1 ) ) 
end function
function green( clr$ )
  green = val( word$( clr$ , 2 ) )
end function
function blue( clr$ )
  blue = val( word$( clr$ , 3 ) ) 
end function
function klmix$( kl1$ , f , kl2$ )
  r1 = red( kl1$ )
  g1 = green( kl1$ )  
  b1 = blue( kl1$ )  
  r2 = red( kl2$ )
  g2 = green( kl2$ )
  b2 = blue( kl2$ )
  r = r1 + f * ( r2 - r1 )
  g = g1 + f * ( g2 - g1 )
  b = b1 + f * ( b2 - b1 )  
  klmix$ = rgb$( r , g , b )
end function
function rainbow$( deg )
  rainbow$ = rgb$( sin( rad( deg ) ) * 127 + 128 _
                 , sin( rad( deg + 120 ) ) * 127 + 128 _
                 , sin( rad( deg - 120 ) ) * 127 + 128 )
end function 

_sphere.bas:
Code:
sub sphere h$, x , y , z , d , clr$
  if abs( height - y ) < d then
    dd = sqr( d ^ 2 - ( height - y ) ^ 2 + .001 ) * 2
    kl$ = klmix$( clr$ , .5 - ( height - y ) / d / 2 , black$ )
    #h$ "goto " ; x + winx / 2 ;" "; winy / 2 - height - z / 4 
    #h$ "backcolor " ; kl$
    #h$ "color " ; kl$
    #h$ "down"
    #h$ "ellipsefilled "; dd ;" "; dd / 4 
    #h$ "up"
  end if
end sub 

Main Program:
Code:
''bluatigro 24 jan 2015
''sphere_test.bas
'include _math_init.bas
'include _color_init.bas
'include _sphere_init.bas
nomainwin
open "" for graphics as #m
  #m "trapclose [quit]"
  #m "fill " ; black$
  for height = 0-winy/2 to winy/2
    call sphere "#m", 0 , 0 , 0 , 50 , red$
  next height
wait
[quit]
  close #m
end
'include _math.bas
'include _color.bas
'include _sphere.bas 

« Last Edit: Jan 24th, 2015, 7:58pm by Richard Russell » User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: Object Oriented Liberty BASIC?
« Reply #18 on: Jan 29th, 2015, 08:44am »

update :
- _sphere.bas extended whit 'egg'

error ? :
- i got the same as you
- but i got a white screen whit nothing

_sphere.bas Code:
''bluatigro 29 jan 1015
''_sphere.bas

sub sphere x , y , z , d , clr$
  if abs( height - y ) < d then
    dd = sqr( d ^ 2 - ( height - y ) ^ 2 + .001 ) * 2
    kl$ = color.mix$( clr$ , .5 - ( height - y ) / d / 2 , black$ )
    #m "goto " ; x + winx / 2 ; " " ; winy / 2 - height - z / 4 
    #m "backcolor " ; kl$
    #m "color" ; kl$
    #m "down"
    #m "ellipsefilled "; dd ;" "; dd / 4 
    #m "up"
  end if
end sub   

sub egg x1 , y1 , z1 , d1 , x2 , y2 , z2 , d2 , dm , kl$ , no
  af = sqr( ( x1 - x2 ) ^ 2 _
  + ( y1 - y2 ) ^ 2 + ( z1 - z2 ) ^ 2 + 1 )
  dx = ( x2 - x1 ) / af
  dy = ( y2 - y1 ) / af
  dz = ( z2 - z1 ) / af
  dd = ( d2 - d1 ) / af
  dh = ( d1 + d2 ) / 2
  if no < 2 then no = af
  if no > af then no = af
  for i = 0 to af step af / no
    call sphere x1 + dx * i _
    , y1 + dy * i , z1 + dz * i _
    , d1 + dd * i + sin( i * pi / af ) _
    * ( dm - dh ) , kl$
  next i
end sub                            
 
User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: Object Oriented Liberty BASIC?
« Reply #19 on: Feb 6th, 2015, 10:17am »

i tested the stuff in 1 file

i got a black screen whit nothing

Code:
''bluatigro 6 feb 2015
''sphere_test_2.bas

  WindowWidth = DisplayWidth
  WindowHeight = DisplayHeight
  global winx , winy
  winx = WindowWidth
  winy = WindowHeight

  global pi , golden.ratio
  pi = atn( 1 ) * 4
  golden.ratio = ( sqr( 5 ) - 1 ) / 2
  global true , false
  true = not( false )

  global black$ , red$ , green$ , yellow$
  global blue$ , magenta$ , cyan$ , white$
  global gray$ , pink$ , purple$ , orange$

  black$   = rgb$( 000 , 000 , 000 )
  red$     = rgb$( 255 , 000 , 000 ) 
  green$   = rgb$( 000 , 255 , 000 ) 
  yellow$  = rgb$( 255 , 255 , 000 ) 
  blue$    = rgb$( 000 , 000 , 255 ) 
  magenta$ = rgb$( 255 , 000 , 255 ) 
  cyan$    = rgb$( 000 , 255 , 255 ) 
  white$   = rgb$( 255 , 255 , 255 ) 
  gray$    = rgb$( 127 , 127 , 127 ) 
  pink$    = rgb$( 255 , 127 , 127 ) 
  purple$  = rgb$( 127 , 000 , 127 ) 
  orange$  = rgb$( 255 , 127 , 000 ) 

  global height

nomainwin
open "" for graphics as #m
  #m "trapclose [quit]"
  #m "fill " ; black$
  for height = 0-winy/2 to winy/2
    call sphere 0 , 0 , 0 , 50 , red$
  next height
wait
[quit]
  close #m
end

''math

function rad( deg )
  rad = deg * pi / 180
end function

function range( l , h )
  range = rnd(0) * ( h - l ) + l
end sub

function nr$( no , max )
  nr$ = right$( "00000000" ; no , max )
end function

''color

function rgb$( r , g , b )
  r = r and 255
  g = g and 255
  b = b and 255
  rgb$ = str$( r ); " " ; g * 256 ; " " ; b * 256 ^ 2
end function

function color.red( clr$ )
  color.red = val( word$( clr$ , 1 ) ) 
end function

function color.green( clr$ )
  color.green = val( word$( clr$ , 2 ) )
end function

function color.blue( clr$ )
  color.blue = val( word$( clr$ , 3 ) ) 
end function

function color.mix$( kl1$ , f , kl2$ )
  r1 = color.red( kl1$ )
  g1 = color.green( kl1$ )  
  b1 = color.blue( kl1$ )  
  r2 = color.red( kl2$ )
  g2 = color.green( kl2$ )
  b2 = color.blue( kl2$ )
  r = r1 + f * ( r2 - r1 )
  g = g1 + f * ( g2 - g1 )
  b = b1 + f * ( b2 - b1 )  
  klmix$ = rgb$( r , g , b )
end function

function rainbow$( deg )
  rainbow$ = rgb$( sin( rad( deg ) ) * 127 + 128 _
                 , sin( rad( deg + 120 ) ) * 127 + 128 _
                 , sin( rad( deg - 120 ) ) * 127 + 128 )
end function  

''sphere

sub sphere x , y , z , d , clr$
  if abs( height - y ) < d then
    dd = sqr( d ^ 2 - ( height - y ) ^ 2 + .001 ) * 2
    kl$ = color.mix$( clr$ , .5 - ( height - y ) / d / 2 , black$ )
    #m "goto " ; x + winx / 2 ; " " ; winy / 2 - height - z / 4 
    #m "backcolor " ; kl$
    #m "color" ; kl$
    #m "down"
    #m "ellipsefilled "; dd ;" "; dd / 4 
    #m "up"
  end if
end sub   

sub egg x1 , y1 , z1 , d1 , x2 , y2 , z2 , d2 , dm , kl$ , no
  af = sqr( ( x1 - x2 ) ^ 2 _
  + ( y1 - y2 ) ^ 2 + ( z1 - z2 ) ^ 2 + 1 )
  dx = ( x2 - x1 ) / af
  dy = ( y2 - y1 ) / af
  dz = ( z2 - z1 ) / af
  dd = ( d2 - d1 ) / af
  dh = ( d1 + d2 ) / 2
  if no < 2 then no = af
  if no > af then no = af
  for i = 0 to af step af / no
    call sphere x1 + dx * i _
    , y1 + dy * i , z1 + dz * i _
    , d1 + dd * i + sin( i * pi / af ) _
    * ( dm - dh ) , kl$
  next i
end sub                            
 
« Last Edit: Feb 6th, 2015, 10:18am by bluatigro » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Object Oriented Liberty BASIC?
« Reply #20 on: Feb 6th, 2015, 11:01am »

on Feb 6th, 2015, 10:17am, bluatigro wrote:
i got a black screen whit nothing

Two mistakes:

Code:
  klmix$ = rgb$( r , g , b )
should be:
  color.mix$ = rgb$( r , g , b ) 

and:

Code:
    #m "color" ; kl$
should be:
    #m "color " ; kl$ 

Richard.
User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: Object Oriented Liberty BASIC?
« Reply #21 on: Feb 6th, 2015, 12:36pm »

@ richard :
- i changed the include *.bas to

error :
- i got a smal white screen

Code:
''bluatigro 6 feb 2015
''_color.bas

function rgb$( r , g , b )
''create a color-object$
  r = r and 255
  g = g and 255
  b = b and 255
  rgb$ = str$( r ); " " ; g * 256 ; " " ; b * 256 ^ 2
end function

function color.red( clr$ )
''get red part of color-object$
  color.red = val( word$( clr$ , 1 ) ) 
end function

function color.green( clr )
''get green part of color-object$
  color.green = val( word$( clr$ , 2 ) )
end function

function color.blue( clr$ )
''get blue part of color-object$
  color.blue = val( word$( clr$ , 3 ) ) 
end function

function color.mix$( kl1$ , f , kl2$ )
''mix 2 color-object$ into 1 new
  r1 = color.red( kl1$ )
  g1 = color.green( kl1$ )  
  b1 = color.blue( kl1$ )  
  r2 = color.red( kl2$ )
  g2 = color.green( kl2$ )
  b2 = color.blue( kl2$ )
  r = r1 + f * ( r2 - r1 )
  g = g1 + f * ( g2 - g1 )
  b = b1 + f * ( b2 - b1 )  
  color.mix$ = rgb$( r , g , b )
end function

function rainbow$( deg )
  rainbow$ = rgb$( sin( rad( deg ) ) * 127 + 128 _
                 , sin( rad( deg + 120 ) ) * 127 + 128 _
                 , sin( rad( deg - 120 ) ) * 127 + 128 )
end function  
 

Code:
''bluatigro 6 feb 2015
''_sphere.bas

sub sphere x , y , z , d , clr$
  if abs( height - y ) < d then
    dd = sqr( d ^ 2 - ( height - y ) ^ 2 + .001 ) * 2
    kl$ = color.mix$( clr$ , .5 - ( height - y ) / d / 2 , black$ )
    #m "goto " ; x + winx / 2 ; " " ; winy / 2 - height - z / 4 
    #m "backcolor " ; kl$
    #m "color " ; kl$
    #m "down"
    #m "ellipsefilled "; dd ; " " ; dd / 4 
    #m "up"
  end if
end sub   

sub egg x1 , y1 , z1 , d1 , x2 , y2 , z2 , d2 , dm , kl$ , no
  af = sqr( ( x1 - x2 ) ^ 2 _
  + ( y1 - y2 ) ^ 2 + ( z1 - z2 ) ^ 2 + 1 )
  dx = ( x2 - x1 ) / af
  dy = ( y2 - y1 ) / af
  dz = ( z2 - z1 ) / af
  dd = ( d2 - d1 ) / af
  dh = ( d1 + d2 ) / 2
  if no < 2 then no = af
  if no > af then no = af
  for i = 0 to af step af / no
    call sphere x1 + dx * i _
    , y1 + dy * i , z1 + dz * i _
    , d1 + dd * i + sin( i * pi / af ) _
    * ( dm - dh ) , kl$
  next i
end sub                            
 

Code:
''bluatigro 6 feb 2015
''sphere_test_2.bas
'include _fullscreen_init.bas
'include _math_init.bas
'include _color_init.bas
global height
nomainwin
open "" for graphics as #m
  #m "trapclose [quit]"
  #m "fill " ; black$
  for height = 0-winy/2 to winy/2
    call sphere 0 , 0 , 0 , 50 , red$
  next height
wait
[quit]
  close #m
end
'include _math.bas
'include _color.bas
'include _sphere.bas
 
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Object Oriented Liberty BASIC?
« Reply #22 on: Feb 6th, 2015, 1:28pm »

on Feb 6th, 2015, 12:36pm, bluatigro wrote:
error : - i got a smal white screen

The beta version of LBB you have contains File... Insert and File... Compare so I suggest you replace each 'include directive with the file itself, and then compare the merged result with the working version.

Generally, I would recommend only using 'include with modules that have been thoroughly tested and are known to work. Otherwise it's too difficult to debug a program using includes.

Richard.
User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: Object Oriented Liberty BASIC?
« Reply #23 on: Feb 8th, 2015, 09:05am »


in the begining it was 1 file
but i splitted it later
because i want to write in parts
so i dont have to write it twice or more
i want to extend this farder whit more parts
[ see 3d line cubes ]
and i can only post 10K here

in the future my files wil be bigger if i dont use include
User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: Object Oriented Liberty BASIC?
« Reply #24 on: Feb 8th, 2015, 10:03am »

@ richard :
- i tryed it

i got rid of al the errors

working Code:
''bluatigro 8 feb 2015
''sphere_test_3.bas

''bluatigro 8 feb 2015
''_fullscreen_init.bas

  WindowWidth = DisplayWidth
  WindowHeight = DisplayHeight
  global winx , winy
  winx = WindowWidth
  winy = WindowHeight

''bluatigro 8 feb 2015
''_math_init.bas

  global pi , golden.ratio
  pi = atn( 1 ) * 4
  golden.ratio = ( sqr( 5 ) - 1 ) / 2
  global true , false
  true = not( false )

''bluatigro 8 feb 2015
''_color_init.bas

  global black$ , red$ , green$ , yellow$
  global blue$ , magenta$ , cyan$ , white$
  global gray$ , pink$ , purple$ , orange$

  black$   = rgb$( 000 , 000 , 000 )
  red$     = rgb$( 255 , 000 , 000 ) 
  green$   = rgb$( 000 , 255 , 000 ) 
  yellow$  = rgb$( 255 , 255 , 000 ) 
  blue$    = rgb$( 000 , 000 , 255 ) 
  magenta$ = rgb$( 255 , 000 , 255 ) 
  cyan$    = rgb$( 000 , 255 , 255 ) 
  white$   = rgb$( 255 , 255 , 255 ) 
  gray$    = rgb$( 127 , 127 , 127 ) 
  pink$    = rgb$( 255 , 127 , 127 ) 
  purple$  = rgb$( 127 , 000 , 127 ) 
  orange$  = rgb$( 255 , 127 , 000 ) 

global height
nomainwin
open "" for graphics as #m
  #m "trapclose [quit]"
  #m "fill " ; black$
  for height = 0-winy/2 to winy/2
    call sphere 0 , 0 , 0 , 50 , red$
  next height
wait
[quit]
  close #m
end

''bluatigro 8 feb 2015
''_math.bas

function rad( deg )
''calculate radians outof degrees
  rad = deg * pi / 180
end function

function range( low , high )
''get a random double between low and high
  range = rnd(0) * ( high - low ) + low
end sub

function nr$( no , max )
''format a number into a string
  nr$ = right$( "0000000000" ; no , max )
end function

''bluatigro 8 feb 2015
''_color.bas

function rgb$( r , g , b )
''create a color-object$
  r = r and 255
  g = g and 255
  b = b and 255
  rgb$ = str$( r ); " " ; g * 256 ; " " ; b * 256 ^ 2
end function

function color.red( clr$ )
''get red part of color-object$
  color.red = val( word$( clr$ , 1 ) ) 
end function

function color.green( clr$ )
''get green part of color-object$
  color.green = val( word$( clr$ , 2 ) )
end function

function color.blue( clr$ )
''get blue part of color-object$
  color.blue = val( word$( clr$ , 3 ) ) 
end function

function color.mix$( kl1$ , f , kl2$ )
''mix 2 color-object$ into 1 new
  r1 = color.red( kl1$ )
  g1 = color.green( kl1$ )  
  b1 = color.blue( kl1$ )  
  r2 = color.red( kl2$ )
  g2 = color.green( kl2$ )
  b2 = color.blue( kl2$ )
  r = r1 + f * ( r2 - r1 )
  g = g1 + f * ( g2 - g1 )
  b = b1 + f * ( b2 - b1 )  
  color.mix$ = rgb$( r , g , b )
end function

function rainbow$( deg )
  rainbow$ = rgb$( sin( rad( deg ) ) * 127 + 128 _
                 , sin( rad( deg + 120 ) ) * 127 + 128 _
                 , sin( rad( deg - 120 ) ) * 127 + 128 )
end function  

''bluatigro 8 feb 2015
''_sphere.bas

sub sphere x , y , z , d , clr$
  if abs( height - y ) < d then
    dd = sqr( d ^ 2 - ( height - y ) ^ 2 + .001 ) * 2
    kl$ = color.mix$( clr$ , .5 - ( height - y ) / d / 2 , black$ )
    #m "goto " ; x + winx / 2 ; " " ; winy / 2 - height - z / 4 
    #m "backcolor " ; kl$
    #m "color " ; kl$
    #m "down"
    #m "ellipsefilled "; dd ; " " ; dd / 4 
    #m "up"
  end if
end sub   

sub egg x1 , y1 , z1 , d1 , x2 , y2 , z2 , d2 , dm , kl$ , no
  af = sqr( ( x1 - x2 ) ^ 2 _
  + ( y1 - y2 ) ^ 2 + ( z1 - z2 ) ^ 2 + 1 )
  dx = ( x2 - x1 ) / af
  dy = ( y2 - y1 ) / af
  dz = ( z2 - z1 ) / af
  dd = ( d2 - d1 ) / af
  dh = ( d1 + d2 ) / 2
  if no < 2 then no = af
  if no > af then no = af
  for i = 0 to af step af / no
    call sphere x1 + dx * i _
    , y1 + dy * i , z1 + dz * i _
    , d1 + dd * i + sin( i * pi / af ) _
    * ( dm - dh ) , kl$
  next i
end sub                            
 


but when i split it it does not work . why ?
User IP Logged

Pages: 1 2 3  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls