Liberty BASIC Community Forum
« Search Results »

Welcome Guest. Please Login or Register.
Oct 30th, 2014, 10:57pm


Rules|Home|Help|Search|Recent Posts|Notification

--Liberty BASIC Resources--
Yahoo Code Repository (source must be included)
Liberty BASIC Community WikiSpace
Liberty Labs
Bay Six Software Forum
Liberty BASIC Home Page

Official Liberty BASIC Support
Liberty BASIC Programmer's Encyclopedia
Liberty BASIC 5 Handbook
Liberty BASIC on Rosetta Code

Search Results

Total results: 10


 1   Game and Graphic Programming / Re: fast 3d point graphics  on: Today at 10:10am
Started by bluatigro | Post by bluatigro
update :
- even more speed
- now user can choise "speeds"

Code:
''bluatigro 29-okt-2014
''point world 3D
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , pi , max
max = 500
dim p( max , 2 ) , s( 10 ) , c( 10 )
winx = WindowWidth
winy = WindowHeight
pi = atn( 1 ) * 4
for i = 1 to 5
  s( i ) = sin( rad( i ) )
  c( i ) = cos( rad( i ) )
next i
nomainwin
open "3D point world 1.0" for graphics as #m
  #m "trapclose [quit]"
  #m "goto 0 0"
  #m "backcolor black"
  #m "down"
  #m "boxfilled 2 4"
  #m "up"
  #m "getbmp point 0 0 2 4"
  x$ = "3"
  prompt "speed x = "; x$
  x = val( x$ )
  y$ = "4"
  prompt "speed y = "; y$
  y = val( y$ )
  z$ = "5"
  prompt "speed z = "; z$
  z = val( z$ )
  for i = 0 to max
    #m "addsprite spr" ; i ; " point"
    #m "spritescale spr" ; i ; " 200"
    p( i , 0 ) = sin( rad( i * 360 / max * x ) ) * 300
    p( i , 1 ) = sin( rad( i * 360 / max * y ) ) * 300
    p( i , 2 ) = sin( rad( i * 360 / max * z ) ) * 300
  next i
  #m "setfocus"
  #m "when characterInput [key]"
  timer 40 , [tmr]
wait
[key]
  key$ = Inkey$
  if key$ = chr$( 27 ) then
    close #m
    end
  end if
wait
[tmr]
  scan
  for i = 0 to max
    x = p( i , 0 )
    y = p( i , 1 )
    z = p( i , 2 )
    call rotate x , z , 5
    call rotate y , z , 4
    call rotate x , y , 3
    p( i , 0 ) = x
    p( i , 1 ) = y
    p( i , 2 ) = z
    #m "spritexy spr" ; i ; " " _
    ; int( winx / 2 + p( i , 0 ) ) ; " " _
    ; int( winy / 2 - p( i , 1 ) )
  next i
  #m "drawsprites"
wait
[quit]
  close #m
end
sub rotate byref k , byref l , deg
  s = s( deg )
  c = c( deg )
  hk = k * c - l * s
  hl = k * s + l * c
  k = hk
  l = hl
end sub
function rad( deg )
  rad = deg * pi / 180
end function
 

 
  Reply Quote Notify of replies

 2   General Board / Re: Shoutcast  on: Yesterday at 3:09pm
Started by ardentcrest | Post by Chris Iverson
Not gonna say it can't be done, but it's work that no one here has done.

I don't know if there's an open-source library available for managing SHOUTcast streams, but if not, then you'd have to do the work of implementing the protocol yourself. I don't know what it would entail, so I'm not going to say it's impossible, but it would likely be complicated.
 
  Reply Quote Notify of replies

 3   Game and Graphic Programming / Re: fast 3d point graphics  on: Yesterday at 07:25am
Started by bluatigro | Post by bluatigro
thus is even better :
Code:
''bluatigro 29-okt-2014
''point world 3D
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , pi , max
max = 500
dim p( max , 2 )
winx = WindowWidth
winy = WindowHeight
pi = atn( 1 ) * 4
nomainwin
open "3D point world 1.0" for graphics as #m
  #m "trapclose [quit]"
  #m "goto 0 0"
  #m "backcolor black"
  #m "down"
  #m "boxfilled 2 4"
  #m "up"
  #m "getbmp point 0 0 2 4"
  prompt "scene [ 0 , 1 ] = " ; q$
  scene = val( q$ )
  for i = 0 to max
    #m "addsprite spr" ; i ; " point"
    #m "spritescale spr" ; i ; " 200"
    if scene = 1 then
      p( i , 0 ) = sin( rad( i * 360 / max * 2 ) ) * 300
      p( i , 1 ) = sin( rad( i * 360 / max * 3 ) ) * 300
      p( i , 2 ) = sin( rad( i * 360 / max * 5 ) ) * 300
    else
      for t = 0 to 2
        p( i , t ) = range( -300 , 300 )
      next t
    end if
  next i
  #m "setfocus"
  #m "when characterInput [key]"
  timer 40 , [tmr]
wait
[key]
  key$ = Inkey$
  if key$ = chr$( 27 ) then
    close #m
    end
  end if
wait
[tmr]
  scan
  for i = 0 to max
    x = p( i , 0 )
    y = p( i , 1 )
    z = p( i , 2 )
    call rotate x , z , 5
    call rotate y , z , 4
    call rotate x , y , 3
    p( i , 0 ) = x
    p( i , 1 ) = y
    p( i , 2 ) = z
    #m "spritexy spr" ; i ; " " _
    ; winx / 2 + p( i , 0 ) ; " " _
    ; winy / 2 - p( i , 1 )
  next i
  #m "drawsprites"
wait
[quit]
  close #m
end
sub rotate byref k , byref l , deg
  s = sin( rad( deg ) )
  c = cos( rad( deg ) )
  hk = k * c - l * s
  hl = k * s + l * c
  k = hk
  l = hl
end sub
function rad( deg )
  rad = deg * pi / 180
end function
function range( l , h )
  range = rnd(0) * ( h - l ) + l
end function
 

 
  Reply Quote Notify of replies

 4   Game and Graphic Programming / fast 3d point graphics  on: Yesterday at 07:07am
Started by bluatigro | Post by bluatigro
this is a try at fast 3d point graphics
i used sprites for points
because they are faster
Code:
''bluatigro 29-okt-2014
''point world 3D
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , pi , max
max = 500
dim p( max , 2 )
winx = WindowWidth
winy = WindowHeight
pi = atn( 1 ) * 4
nomainwin
open "3D point world 1.0" for graphics as #m
  #m "trapclose [quit]"
  #m "goto 0 0"
  #m "backcolor black"
  #m "down"
  #m "boxfilled 2 4"
  #m "up"
  #m "getbmp point 0 0 2 4"
  for i = 0 to max
    #m "addsprite spr" ; i ; " point"
    #m "spritescale spr" ; i ; " 200"
    p( i , 0 ) = sin( rad( i * 360 / max * 2 ) ) * 300
    p( i , 1 ) = sin( rad( i * 360 / max * 3 ) ) * 300
    p( i , 2 ) = sin( rad( i * 360 / max * 5 ) ) * 300
  next i
  #m "setfocus"
  #m "when characterInput [key]"
  timer 40 , [tmr]
wait
[key]
  key$ = Inkey$
  if key$ = chr$( 27 ) then
    close #m
    end
  end if
wait
[tmr]
  scan
  for i = 0 to max
    x = p( i , 0 )
    z = p( i , 2 )
    call rotate x , z , 5
    p( i , 0 ) = x
    p( i , 2 ) = z
    #m "spritexy spr" ; i ; " " _
    ; winx / 2 + p( i , 0 ) ; " " _
    ; winy / 2 - p( i , 1 )
  next i
  #m "drawsprites"
wait
[quit]
  close #m
end
sub rotate byref k , byref l , deg
  s = sin( rad( deg ) )
  c = cos( rad( deg ) )
  hk = k * c - l * s
  hl = k * s + l * c
  k = hk
  l = hl
end sub
function rad( deg )
  rad = deg * pi / 180
end function
function range( l , h )
  range = rnd(0) * ( h - l ) + l
end function
 

 
  Reply Quote Notify of replies

 5   General Board / Re: Shoutcast  on: Oct 28th, 2014, 5:36pm
Started by ardentcrest | Post by ardentcrest
So It can't be Done
 
  Reply Quote Notify of replies

 6   Liberty BASIC Code / Re: AI : cat,bird,grain cros river puzle  on: Oct 28th, 2014, 07:48am
Started by bluatigro | Post by Rod
Same strategy, all possible decisions against a rule table, surviving decisions spawn another choice.


Code:
direction$="<"
dim option$(2000) 'tree list
dim option(2000,5)'left monks left canibals right monks right canibals status
option(1,1)=3 'monks
option(1,2)=3 'canibals
option(1,3)=0
option(1,4)=0
option(1,5)=1  '0=tested 1=to test
optnum=1
nextopt=2
lmonk=1
lcani=2
rmonk=3
rcani=4
status=5


[move]

if direction$="<" then direction$=">" else direction$="<"

    for opt=1 to nextopt-1

        if option(opt,status)=1 then

            [select]
            if direction$=">" then

                'left to right
                'run all movement options left set to right set
                for n= 1 to 5
                    select case n
                    case 1
                    take$="MM"
                    ml=-2
                    mr=2
                    cl=0
                    cr=0
                    case 2
                    take$="MC"
                    ml=-1
                    mr=1
                    cl=-1
                    cr=1
                    case 3
                    take$="CC"
                    ml=0
                    mr=0
                    cl=-2
                    cr=2
                    case 4
                    take$="M"
                    ml=-1
                    mr=1
                    cl=0
                    cr=0
                    case 5
                    take$="C"
                    ml=0
                    mr=0
                    cl=-1
                    cr=1
                    end select

                    'now check if the remaining combination is valid
                       select case allowed(opt,take$,direction$)

                        case 1
                        'if it is valid create a new option
                        option(nextopt,lmonk)=option(opt,lmonk)+ml
                        option(nextopt,lcani)=option(opt,lcani)+cl
                        option(nextopt,rmonk)=option(opt,rmonk)+mr
                        option(nextopt,rcani)=option(opt,rcani)+cr
                        option(nextopt,status)=1
                        option$(nextopt)=option$(opt)+str$(nextopt)+","
                        gosub [printit]


                        case 2
                        'if we have achieved success stop
                        option(nextopt,lmonk)=option(opt,lmonk)+ml
                        option(nextopt,lcani)=option(opt,lcani)+cl
                        option(nextopt,rmonk)=option(opt,rmonk)+mr
                        option(nextopt,rcani)=option(opt,rcani)+cr
                        option(nextopt,status)=1
                        option$(nextopt)=option$(opt)+str$(nextopt)+","
                        gosub [printit]
                        print "Success"
                        end

                        'case else
                        'gosub [printit]

                    end select
                next

            else

                'right to left
                'run all movement options right set to left set

                for n= 1 to 5
                    select case n
                    case 1
                    take$="MM"
                    mr=-2
                    ml=2
                    cl=0
                    cr=0
                    case 2
                    take$="MC"
                    mr=-1
                    ml=1
                    cr=-1
                    cl=1
                    case 3
                    take$="CC"
                    mr=0
                    ml=0
                    cr=-2
                    cl=2
                    case 4
                    take$="M"
                    mr=-1
                    ml=1
                    cl=0
                    cr=0
                    case 5
                    take$="C"
                    ml=0
                    mr=0
                    cr=-1
                    cl=1

                    end select



                    'now check if the remaining combination is valid

                    select case allowed(opt,take$,direction$)

                        case 1
                        'if it is valid create a new option
                        option(nextopt,lmonk)=option(opt,lmonk)+ml
                        option(nextopt,lcani)=option(opt,lcani)+cl
                        option(nextopt,rmonk)=option(opt,rmonk)+mr
                        option(nextopt,rcani)=option(opt,rcani)+cr
                        option(nextopt,status)=1
                        option$(nextopt)=option$(opt)+str$(nextopt)+","
                        gosub [printit]

                        case 2
                        'if we have achieved success stop
                        option(nextopt,lmonk)=option(opt,lmonk)+ml
                        option(nextopt,lcani)=option(opt,lcani)+cl
                        option(nextopt,rmonk)=option(opt,rmonk)+mr
                        option(nextopt,rcani)=option(opt,rcani)+cr
                        option(nextopt,status)=1
                        option$(nextopt)=option$(opt)+str$(nextopt)+","
                        gosub [printit]
                        print "Success"
                        end
                    end select



                next

            end if

            option(opt,status)=0

        end if

    next

goto [move]

[printit]
    print nextopt;" ";option(opt,lmonk);"/";option(opt,lcani),direction$;
    print " Take ";take$,
    print option(nextopt,rmonk);"/";option(nextopt,rcani);" ";option$(nextopt)
    nextopt=nextopt+1
    return



function allowed(o,t$,d$) '0=not allowed, 1=allowed, 2=game over
    if d$=">" then
    select case
    case t$="MM"
        ml=option(o,1)-2
        mr=option(o,3)+2
        cl=option(o,2)
        cr=option(o,4)
    case t$="MC" or t$="CM"
        ml=option(o,1)-1
        cl=option(o,2)-1
        mr=option(o,3)+1
        cr=option(o,4)+1
    case t$="CC"
        ml=option(o,1)
        mr=option(o,3)
        cl=option(o,2)-2
        cr=option(o,4)+2
    case t$="M"
        ml=option(o,1)-1
        mr=option(o,3)+1
        cl=option(o,2)
        cr=option(o,4)
    case t$="C"
        ml=option(o,1)
        mr=option(o,3)
        cl=option(o,2)-1
        cr=option(o,4)+1
    end select
    else
        select case
    case t$="MM"
        ml=option(o,1)+2
        mr=option(o,3)-2
        cl=option(o,2)
        cr=option(o,4)
    case t$="MC" or t$="CM"
        ml=option(o,1)+1
        cl=option(o,2)+1
        mr=option(o,3)-1
        cr=option(o,4)-1
    case t$="CC"
        ml=option(o,1)
        mr=option(o,3)
        cl=option(o,2)+2
        cr=option(o,4)-2
    case t$="M"
        ml=option(o,1)+1
        mr=option(o,3)-1
        cl=option(o,2)
        cr=option(o,4)
    case t$="C"
        ml=option(o,1)
        mr=option(o,3)
        cl=option(o,2)+1
        cr=option(o,4)-1
    end select

    end if
    allowed=1
    if ml<0 or cl<0 or mr<0 or cr<0 or (ml>0 and ml<cl) or (mr>0 and mr<cr) then allowed=0
    if mr=0 and cr=0 then allowed=0
    if ml=0 and cl=0 then allowed=2
end function

 

 
  Reply Quote Notify of replies

 7   Liberty BASIC Code / Re: AI : cat,bird,grain cros river puzle  on: Oct 26th, 2014, 12:30pm
Started by bluatigro | Post by bluatigro
try at the monk-canibal puzle

Code:
''bluatigro 26 okt 2014

''3 monks and 3 canibals want to cros a river
''problems :
''1:
''there may not be more canibals then monks at any time
''or any place otherwise the canibals eat the monks
''2:
''in the boot fit only 2 persons




global monkl , monkr , caniball , canibalr , tel
dim p( 3 , 3 )
p( 0 , 0 ) = 1
monkl = 3
monkr = 0
caniball = 3
canibalr = 0
tel = 0
while ( morkr <> 3 or canibalr <> 3 )  and tel < 10000
  tel = tel + 1
  dice = int( rnd(0) * 5 )
  select case tel mod 5
    case 0
      call move 0 , 1 , boot
    case 1
      call move 1 , 0 , boot
    case 2
      call move 0 , 2 , boot
    case 3
      call move 2 , 0 , boot
    case else
      call move 1 , 1 , boot
  end select
  boot = 1 - boot
wend
if monkr = 3 and canibalr = 3 then
  print "puzle solved !!"
else
  print "end program ."
end if
end
sub move monks , canibals , boot
  if boot = 0 then
  ''boot is left
    ml = monkl - morks
    cl = caniball - canibals
    mr = monkr + monks
    cr = canibalr + canibals
  else
  ''boot is right
    mr = monkr - morks
    cr = canibalr - canibals
    ml = monkl + monks
    cl = caniball + canibals
  end if
  if cl <= ml and cr <= mr _
  and m1 >= 0 and mr >= 0 _
  and cl >= 0 and cr >= 0 _
  and ml <= 3 and mr <= 3 _
  and c1 <= 3 and cr <= 3 then
    if p( mr , cr ) = 0 then
      monkl = ml
      caniball = cl
      monkr = mr
      canibalr = cr
      print "M = " ; monkl ; " | C = " ; caniball _
      ; "  ~~~~~  M = " ; monkr ; " | C = " ; canibalr
      if boot = 0 then
        print "Monk = " ; monks ; " | Canibal = " ; canibals ; " =>"
      else
        print "Monk = " ; monks ; " | Canibal = " ; canibals ; " <="
      end if
      p( mr , cr ) = 1
    end if
  end if
end sub
 

 
  Reply Quote Notify of replies

 8   Novice / Re: A combobox problem  on: Oct 26th, 2014, 11:27am
Started by fox | Post by fox
Yes, Rod: your suggestion is ok. I will use only combobox: also because so I can "economize" space on display in addition to not have the problem I described.
Thanks a lot again and bye
fox
 
  Reply Quote Notify of replies

 9   Novice / Re: A combobox problem  on: Oct 26th, 2014, 11:08am
Started by fox | Post by Rod
The combobox fires an event only when the user changes selection. Otherwise it just continues to display the last selection. Why do you need the textboxes? Why not just use comboboxes?

 
  Reply Quote Notify of replies

 10   Liberty BASIC Code / Re: AI : cat,bird,grain cros river puzle  on: Oct 26th, 2014, 10:54am
Started by bluatigro | Post by bluatigro

and this puzle was simple

try this one :
3 monks and 3 canibals want to cros a river
problems :
1:
there may not be more canibals then monks at any time
or any place otherwise the canibals eat the monks
2:
in the boot fit only 2 persons

 
  Reply Quote Notify of replies


Rules|Home|Help|Search|Recent Posts|Notification



Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls