SOKUBAN

Vragen en suggesties over het programmeren van spelletjes, sprites en dergelijke in Liberty BASIC

Moderator: anthonio

SOKUBAN

Berichtdoor bluatigro » di dec 06, 2011 1:01 pm

poging tot SOKUBAN

doel spel :
duw alle zakken [ groene cirkels ]
naar de eindes [ blauwe recthoeken ]

ERROR :
de speler laat n reeks player$ achter
dat zouden empty$ moeten zijn
Ik heb een wijziging aangebracht zodat dit niet optreedt. Gordon


toekomst :
kijken of alle zakken op de eides zijb
verre toekomst :
meer levels [ op disk ]
Code: Selecteer alles
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , there$ , maxx , maxy , px , py , cut$
global player$ , bag$ , wall$ , empty$
winx = WindowWidth
winy = WindowHeight
maxx = 20
maxy = 20
cut$ = "|"
player$ = "@"
bag$ = "$"
wall$ = "#"
empty$ = ""
dim maze$( maxx , maxy )
while q$ <> "end"
  read q$
  for x = 1 to len( q$ )
    maze$( x , y ) = mid$( q$ , x , 1 )
    if mid$( q$ , x , 1 ) = "." then
      there$ = push$( there$ , str$(index(x,y)) , 0 )
    end if
    if mid$( q$ , x , 1 ) = player$ then
      px = x
      py = y
    end if
  next x
  y = y + 1
wend
data "    ######"
data "    ##   #"
data "    ##$  #"
data "  ####  $##"
data "  ##  $ $ #"
data "#### # ## #   ######"
data "##   # ## #####  ..#"
data "## $  $          ..#"
data "###### ### #@##  ..#"
data "    ##     #########"
data "    ########"
data "end"
nomainwin
open "SOKUBAN" for graphics as #m
  #m "trapclose [quit]"
  #m "when characterInput [key]"
  #m "setfocus"
  call drawmaze
wait
[key]
  select case right$( Inkey$ , 1 )
    case chr$( _VK_UP )
      dx = 0
      dy = -1
    case chr$( _VK_DOWN )
      dx = 0
      dy = 1
    case chr$( _VK_LEFT )
      dx = -1
      dy = 0
    case chr$( _VK_RIGHT )
      dx = 1
      dy = 0
    case else
      dx = 0
      dy = 0
  end select
  if abs( dx ) <> abs( dy ) then
    if maze$( px + dx , py + dy ) <> wall$ then
      if maze$( px + dx , py + dy ) = bag$ then
        if maze$( px + 2 * dx , py + 2 * dy ) <> wall$ _
        and maze$( px + 2 * dx , py + 2 * dy ) <> bag$ then
          maze$( px + 2 * dx , py + 2 * dy ) = bag$
          maze$( px + dx , py + dy ) = player$
          maze$( px , py ) = empty$
          px = px + dx
          py = py + dy
        end if
      else
        maze$( px + dx , py + dy ) = player$
        maze$( px , py ) = empty$
        px = px + dx
        py = py + dy
      end if
    end if
  end if
  call drawmaze
wait
sub drawmaze
  for x = 0 to 20
    for y = 0 to 20
      q$ = maze$( x , y )
      select case q$
        case "#"
          #m "backcolor darkred"
          #m "goto " ; x * winx / (maxx+2) ; " " ; y * winy / (maxy+2)
          #m "down"
          #m "boxfilled " ; ( x + 1 ) * winx / (maxx+2) ; " " ; ( y + 1 ) * winy / (maxy+2)
          #m "up"
        case "$"
          #m "backcolor green"
          #m "goto " ; ( x + .5 ) * winx / (maxx+2) ; " " ; ( y +  .5 ) * winy / (maxy+2)
          #m "down"
          #m "circlefilled " ; winy / ( maxy + 2 ) / 2
          #m "up"
        case "."
          #m "backcolor blue"
          #m "goto " ; x * winx / (maxx+2) + 10 ; " " ; y * winy / (maxy+2) + 10
          #m "down"
          #m "boxfilled " ; ( x + 1 ) * winx / (maxx+2) - 10 _
          ; " " ;           ( y + 1 ) * winy / (maxy+2) - 10
          #m "up"
        case "@"
          #m "backcolor 255 127 127"
          #m "goto " ; ( x + .5 ) * winx / (maxx+2) ; " " ; ( y + .5 ) * winy / (maxy+2)
          #m "down"
          #m "circlefilled " ; winy / ( maxy + 2 ) / 2
          #m "up"
       case ""
          #m "backcolor 255 255 255" :#m "color white"
          #m "goto " ; ( x + .5 ) * winx / (maxx+2) ; " " ; ( y + .5 ) * winy / (maxy+2)
          #m "down"
          #m "circlefilled " ; (winy / ( maxy + 2 ) / 2)
          #m "up"
        case else
      end select
    next y
  next x
end sub
[quit]
  close #m
end
function index( x , y )
  index = x + 20 * y
end function
''                                 stack stuff
function push$( stack$ , object$ , l )
''store object$ on left side stack
  if l <> 0 then '   <<<<<<<<<<<<<<<<<<<<,,
    push$ = object$ + cut$ + stack$
  else
    'push$ =stack$ +object$ +cut$
    push$ = stack$ + cut$ + object$    '   <<<<<<<<<<<<<<<<
  end if
end function

function pop$( stack$ )
''delete last object$
  i = instr( stack$ , cut$ )
  if stack$ = "" then pop$ = ""
''get right side of stack
  pop$ = mid$( stack$ , i + 1 , len( stack$ ) -i )
end function

function top$( stack$)
''read last object$
  i = instr( stack$ , cut$ )
  if stack$ = "" then
    top$ = ""
  else
    top$ = mid$( stack$ , 1 , i - 1 ) '   <<<<<<<<
  end if
end function

function element( stack$ , e$ )
  fl = 0
  i  = 1
  do
    jf$ = word$( stack$ , i , cut$ )
    if jf$ = e$ then fl = true
    i = i + 1
  loop until jf$ = ""
  element = fl
end function



'function element( stack$, e$)
 ' fl =0
 ' i  =1
 ' while val( word$( stack$, i, cut$)) <>0
    'if word$( stack$, i ) =e$ then f1 =not( 0)
'    if word$( stack$, i ) =e$ then fl =not( 0)
'    i =i +1
'  wend
'  element =fl
'end function
bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm

Re: SOKUBAN

Berichtdoor bluatigro » ma dec 12, 2011 11:42 am

error opgelost
nu alleen nog controle op alle zakken op doel
en levels op disk
Code: Selecteer alles
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , there$ , maxx , maxy , px , py , cut$
global player$ , bag$ , wall$ , empty$
winx = WindowWidth
winy = WindowHeight
maxx = 20
maxy = 20
cut$ = "|"
player$ = "@"
bag$ = "$"
wall$ = "#"
empty$ = ""
dim maze$( maxx , maxy )
call resetlevel
nomainwin
open "SOKUBAN" for graphics as #m
  #m "trapclose [quit]"
  #m "when characterInput [key]"
  #m "setfocus"
  call drawmaze
wait
[key]
  select case right$( Inkey$ , 1 )
    case chr$( _VK_UP )
      dx = 0
      dy = -1
    case chr$( _VK_DOWN )
      dx = 0
      dy = 1
    case chr$( _VK_LEFT )
      dx = -1
      dy = 0
    case chr$( _VK_RIGHT )
      dx = 1
      dy = 0
    case chr$( _VK_ESCAPE )
      close #m
      end
    case "r"
      dx = 0
      dy = 0
      call resetlevel
    case else
      dx = 0
      dy = 0
  end select
  if abs( dx ) <> abs( dy ) then
    if maze$( px + dx , py + dy ) <> wall$ then
      if maze$( px + dx , py + dy ) = bag$ then
        if maze$( px + 2 * dx , py + 2 * dy ) <> wall$ _
        and maze$( px + 2 * dx , py + 2 * dy ) <> bag$ then
          maze$( px + 2 * dx , py + 2 * dy ) = bag$
          maze$( px + dx , py + dy ) = player$
          maze$( px , py ) = empty$
          px = px + dx
          py = py + dy
        end if
      else
        maze$( px + dx , py + dy ) = player$
        maze$( px , py ) = empty$
        px = px + dx
        py = py + dy
      end if
    end if
  end if
  call drawmaze
wait
sub drawmaze
  #m "cls"
  for x = 0 to 20
    for y = 0 to 20
      q$ = maze$( x , y )
      select case q$
        case wall$
          #m "backcolor darkred"
          #m "goto " ; x * winx / (maxx+2) ; " " ; y * winy / (maxy+2)
          #m "down"
          #m "boxfilled " ; ( x + 1 ) * winx / (maxx+2) ; " " ; ( y + 1 ) * winy / (maxy+2)
          #m "up"
        case bag$
          #m "backcolor green"
          #m "goto " ; ( x + .5 ) * winx / (maxx+2) ; " " ; ( y +  .5 ) * winy / (maxy+2)
          #m "down"
          #m "circlefilled " ; winy / ( maxy + 2 ) / 2
          #m "up"
        case "."
          #m "backcolor blue"
          #m "goto " ; x * winx / (maxx+2) + 10 ; " " ; y * winy / (maxy+2) + 10
          #m "down"
          #m "boxfilled " ; ( x + 1 ) * winx / (maxx+2) - 10 _
          ; " " ;           ( y + 1 ) * winy / (maxy+2) - 10
          #m "up"
        case player$
          #m "backcolor 255 127 127"
          #m "goto " ; ( x + .5 ) * winx / (maxx+2) ; " " ; ( y + .5 ) * winy / (maxy+2)
          #m "down"
          #m "circlefilled " ; winy / ( maxy + 2 ) / 2
          #m "up"
        case else
      end select
    next y
  next x
end sub
sub resetlevel
  restore
  while q$ <> "end"
    read q$
    for x = 1 to len( q$ )
      maze$( x , y ) = mid$( q$ , x , 1 )
      if mid$( q$ , x , 1 ) = "." then
        there$ = push$( there$ , str$(index(x,y)) , 0 )
      end if
      if mid$( q$ , x , 1 ) = player$ then
        px = x
        py = y
      end if
    next x
    y = y + 1
  wend
  data "    ######"
  data "    ##   #"
  data "    ##$  #"
  data "  ####  $##"
  data "  ##  $ $ #"
  data "#### # ## #   ######"
  data "##   # ## #####  ..#"
  data "## $  $          ..#"
  data "###### ### #@##  ..#"
  data "    ##     #########"
  data "    ########"
  data "end"
end sub
[quit]
  close #m
end
function index( x , y )
  index = x + 20 * y
end function
''                                 stack stuff
function push$( stack$ , object$ , l )
''store object$ on left side stack
  if l <> 0 then '   <<<<<<<<<<<<<<<<<<<<,,
    push$ = object$ + cut$ + stack$
  else
    'push$ =stack$ +object$ +cut$
    push$ = stack$ + cut$ + object$    '   <<<<<<<<<<<<<<<<
  end if
end function

function pop$( stack$ )
''delete last object$
  i = instr( stack$ , cut$ )
  if stack$ = "" then pop$ = ""
''get right side of stack
  pop$ = mid$( stack$ , i + 1 , len( stack$ ) -i )
end function

function top$( stack$)
''read last object$
  i = instr( stack$ , cut$ )
  if stack$ = "" then
    top$ = ""
  else
    top$ = mid$( stack$ , 1 , i - 1 ) '   <<<<<<<<
  end if
end function

function element( stack$ , e$ )
  fl = 0
  i  = 1
  do
    jf$ = word$( stack$ , i , cut$ )
    if jf$ = e$ then fl = true
    i = i + 1
  loop until jf$ = ""
  element = fl
end function

''function element( stack$, e$)
 ' fl =0
 ' i  =1
 ' while val( word$( stack$, i, cut$)) <>0
    'if word$( stack$, i ) =e$ then f1 =not( 0)
'    if word$( stack$, i ) =e$ then fl =not( 0)
'    i =i +1
'  wend
'  element =fl
'end function
bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm

Re: SOKUBAN

Berichtdoor bluatigro » ma dec 12, 2011 1:08 pm

update :
t zou nu zakken-op-doel moeten hekennen
error :
dat doet t dus niet
Code: Selecteer alles
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , there$ , maxx , maxy , px , py , cut$
global player$ , bag$ , wall$ , empty$ , level , points , point
winx = WindowWidth
winy = WindowHeight
maxx = 20
maxy = 20
cut$ = "|"
player$ = "@"
bag$ = "$"
wall$ = "#"
empty$ = ""
dim maze$( maxx , maxy ) , m$( maxy )
call resetlevel
nomainwin
open "SOKUBAN" for graphics as #m
  #m "trapclose [quit]"
  #m "when characterInput [key]"
  #m "setfocus"
  call drawmaze
wait
[key]
  select case right$( Inkey$ , 1 )
    case chr$( _VK_UP )
      dx = 0
      dy = -1
    case chr$( _VK_DOWN )
      dx = 0
      dy = 1
    case chr$( _VK_LEFT )
      dx = -1
      dy = 0
    case chr$( _VK_RIGHT )
      dx = 1
      dy = 0
    case chr$( _VK_ESCAPE )
      close #m
      end
    case "r"
      dx = 0
      dy = 0
      call resetlevel
    case else
      dx = 0
      dy = 0
  end select
  if abs( dx ) <> abs( dy ) then
    if maze$( px + dx , py + dy ) <> wall$ then
      if maze$( px + dx , py + dy ) = bag$ then
        if maze$( px + 2 * dx , py + 2 * dy ) <> wall$ _
        and maze$( px + 2 * dx , py + 2 * dy ) <> bag$ then
          maze$( px + 2 * dx , py + 2 * dy ) = bag$
          maze$( px + dx , py + dy ) = player$
          maze$( px , py ) = empty$
          px = px + dx
          py = py + dy
        end if
      else
        maze$( px + dx , py + dy ) = player$
        maze$( px , py ) = empty$
        px = px + dx
        py = py + dy
      end if
    end if
  end if
  p = 1
  fl = true
  while word$( target$ , p ) <> ""
    q = val( word$( target$ , p ) )
    qy = int( q / maxx )
    qx = q - qy * maxx
    if maze$( qx , qy ) <> bag$ then fl = false
  wend
  if fl then
    ''points = points + point
    notice chr$( 13 ) + "Level " ; level ; " solved ." + chr$( 13 ) _
    + "Points = " ; points
    ''level = level + 1
    call resetlevel
  end if
  call drawmaze
wait
sub drawmaze
  #m "cls"
  for x = 0 to maxx
    for y = 0 to maxy
      q$ = maze$( x , y )
      select case q$
        case wall$
          #m "backcolor darkred"
          #m "goto " ; x * winx / (maxx+2) ; " " ; y * winy / (maxy+2)
          #m "down"
          #m "boxfilled " ; ( x + 1 ) * winx / (maxx+2) ; " " ; ( y + 1 ) * winy / (maxy+2)
          #m "up"
        case bag$
          #m "backcolor green"
          #m "goto " ; ( x + .5 ) * winx / (maxx+2) ; " " ; ( y +  .5 ) * winy / (maxy+2)
          #m "down"
          #m "circlefilled " ; winy / ( maxy + 2 ) / 2
          #m "up"
        case "."
          #m "backcolor blue"
          #m "goto " ; x * winx / (maxx+2) + 10 ; " " ; y * winy / (maxy+2) + 10
          #m "down"
          #m "boxfilled " ; ( x + 1 ) * winx / (maxx+2) - 10 _
          ; " " ;           ( y + 1 ) * winy / (maxy+2) - 10
          #m "up"
        case player$
          #m "backcolor 255 127 127"
          #m "goto " ; ( x + .5 ) * winx / (maxx+2) ; " " ; ( y + .5 ) * winy / (maxy+2)
          #m "down"
          #m "circlefilled " ; winy / ( maxy + 2 ) / 2
          #m "up"
        case else
      end select
    next y
  next x
end sub
function nr$( x )
  nr$ = right$( "000" + str$( x ) , 3 )
end function
sub resetlevel
  if level = 0 then
    restore
  else
    open DefaultDir$ + "\sokuban" + nr$( level ) + ".txt" for input as #sok
      t = 0
      while not( eof( #sok ) )
        q$ = input$( #sok , lof( #sok ) )
        m$( t ) = q$
        t = t + 1
      wend
    close #sok
  end if
  point = 0
  while q$ <> "end"
    if level = 0 then
      read q$
    else
      q$ = m$( y )
    end if
    for x = 1 to len( q$ )
      maze$( x , y ) = mid$( q$ , x , 1 )
      if mid$( q$ , x , 1 ) = "." then
        there$ = push$( there$ , str$(index(x,y)) , 0 )
        point = point + 1
      end if
      if mid$( q$ , x , 1 ) = player$ then
        px = x
        py = y
      end if
    next x
    y = y + 1
  wend
  data "    ######"
  data "    ##   #"
  data "    ##$  #"
  data "  ####  $##"
  data "  ##  $ $ #"
  data "#### # ## #   ######"
  data "##   # ## #####  ..#"
  data "## $  $          ..#"
  data "###### ### #@##  ..#"
  data "    ##     #########"
  data "    ########"
  data "end"
end sub

[quit]
  close #m
end
function index( x , y )
  index = x + maxx * y
end function
''                                 stack stuff
function push$( stack$ , object$ , l )
''store object$ on left side stack
  if l <> 0 then '   <<<<<<<<<<<<<<<<<<<<,,
    push$ = object$ + cut$ + stack$
  else
    'push$ =stack$ +object$ +cut$
    push$ = stack$ + cut$ + object$    '   <<<<<<<<<<<<<<<<
  end if
end function

function pop$( stack$ )
''delete last object$
  i = instr( stack$ , cut$ )
  if stack$ = "" then pop$ = ""
''get right side of stack
  pop$ = mid$( stack$ , i + 1 , len( stack$ ) -i )
end function

function top$( stack$)
''read last object$
  i = instr( stack$ , cut$ )
  if stack$ = "" then
    top$ = ""
  else
    top$ = mid$( stack$ , 1 , i - 1 ) '   <<<<<<<<
  end if
end function

function element( stack$ , e$ )
  fl = 0
  i  = 1
  do
    jf$ = word$( stack$ , i , cut$ )
    if jf$ = e$ then fl = true
    i = i + 1
  loop until jf$ = ""
  element = fl
end function



'function element( stack$, e$)
 ' fl =0
 ' i  =1
 ' while val( word$( stack$, i, cut$)) <>0
    'if word$( stack$, i ) =e$ then f1 =not( 0)
'    if word$( stack$, i ) =e$ then fl =not( 0)
'    i =i +1
'  wend
'  element =fl
'end function
bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm

Re: SOKUBAN

Berichtdoor bluatigro » ma dec 12, 2011 1:09 pm

update :
t zou nu zakken-op-doel moeten hekennen
error :
dat doet t dus niet
Code: Selecteer alles
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , there$ , maxx , maxy , px , py , cut$
global player$ , bag$ , wall$ , empty$ , level , points , point
winx = WindowWidth
winy = WindowHeight
maxx = 20
maxy = 20
cut$ = "|"
player$ = "@"
bag$ = "$"
wall$ = "#"
empty$ = ""
dim maze$( maxx , maxy ) , m$( maxy )
call resetlevel
nomainwin
open "SOKUBAN" for graphics as #m
  #m "trapclose [quit]"
  #m "when characterInput [key]"
  #m "setfocus"
  call drawmaze
wait
[key]
  select case right$( Inkey$ , 1 )
    case chr$( _VK_UP )
      dx = 0
      dy = -1
    case chr$( _VK_DOWN )
      dx = 0
      dy = 1
    case chr$( _VK_LEFT )
      dx = -1
      dy = 0
    case chr$( _VK_RIGHT )
      dx = 1
      dy = 0
    case chr$( _VK_ESCAPE )
      close #m
      end
    case "r"
      dx = 0
      dy = 0
      call resetlevel
    case else
      dx = 0
      dy = 0
  end select
  if abs( dx ) <> abs( dy ) then
    if maze$( px + dx , py + dy ) <> wall$ then
      if maze$( px + dx , py + dy ) = bag$ then
        if maze$( px + 2 * dx , py + 2 * dy ) <> wall$ _
        and maze$( px + 2 * dx , py + 2 * dy ) <> bag$ then
          maze$( px + 2 * dx , py + 2 * dy ) = bag$
          maze$( px + dx , py + dy ) = player$
          maze$( px , py ) = empty$
          px = px + dx
          py = py + dy
        end if
      else
        maze$( px + dx , py + dy ) = player$
        maze$( px , py ) = empty$
        px = px + dx
        py = py + dy
      end if
    end if
  end if
  p = 1
  fl = true
  while word$( target$ , p ) <> ""
    q = val( word$( target$ , p ) )
    qy = int( q / maxx )
    qx = q - qy * maxx
    if maze$( qx , qy ) <> bag$ then fl = false
  wend
  if fl then
    ''points = points + point
    notice chr$( 13 ) + "Level " ; level ; " solved ." + chr$( 13 ) _
    + "Points = " ; points
    ''level = level + 1
    call resetlevel
  end if
  call drawmaze
wait
sub drawmaze
  #m "cls"
  for x = 0 to maxx
    for y = 0 to maxy
      q$ = maze$( x , y )
      select case q$
        case wall$
          #m "backcolor darkred"
          #m "goto " ; x * winx / (maxx+2) ; " " ; y * winy / (maxy+2)
          #m "down"
          #m "boxfilled " ; ( x + 1 ) * winx / (maxx+2) ; " " ; ( y + 1 ) * winy / (maxy+2)
          #m "up"
        case bag$
          #m "backcolor green"
          #m "goto " ; ( x + .5 ) * winx / (maxx+2) ; " " ; ( y +  .5 ) * winy / (maxy+2)
          #m "down"
          #m "circlefilled " ; winy / ( maxy + 2 ) / 2
          #m "up"
        case "."
          #m "backcolor blue"
          #m "goto " ; x * winx / (maxx+2) + 10 ; " " ; y * winy / (maxy+2) + 10
          #m "down"
          #m "boxfilled " ; ( x + 1 ) * winx / (maxx+2) - 10 _
          ; " " ;           ( y + 1 ) * winy / (maxy+2) - 10
          #m "up"
        case player$
          #m "backcolor 255 127 127"
          #m "goto " ; ( x + .5 ) * winx / (maxx+2) ; " " ; ( y + .5 ) * winy / (maxy+2)
          #m "down"
          #m "circlefilled " ; winy / ( maxy + 2 ) / 2
          #m "up"
        case else
      end select
    next y
  next x
end sub
function nr$( x )
  nr$ = right$( "000" + str$( x ) , 3 )
end function
sub resetlevel
  if level = 0 then
    restore
  else
    open DefaultDir$ + "\sokuban" + nr$( level ) + ".txt" for input as #sok
      t = 0
      while not( eof( #sok ) )
        q$ = input$( #sok , lof( #sok ) )
        m$( t ) = q$
        t = t + 1
      wend
    close #sok
  end if
  point = 0
  while q$ <> "end"
    if level = 0 then
      read q$
    else
      q$ = m$( y )
    end if
    for x = 1 to len( q$ )
      maze$( x , y ) = mid$( q$ , x , 1 )
      if mid$( q$ , x , 1 ) = "." then
        there$ = push$( there$ , str$(index(x,y)) , 0 )
        point = point + 1
      end if
      if mid$( q$ , x , 1 ) = player$ then
        px = x
        py = y
      end if
    next x
    y = y + 1
  wend
  data "    ######"
  data "    ##   #"
  data "    ##$  #"
  data "  ####  $##"
  data "  ##  $ $ #"
  data "#### # ## #   ######"
  data "##   # ## #####  ..#"
  data "## $  $          ..#"
  data "###### ### #@##  ..#"
  data "    ##     #########"
  data "    ########"
  data "end"
end sub

[quit]
  close #m
end
function index( x , y )
  index = x + maxx * y
end function
''                                 stack stuff
function push$( stack$ , object$ , l )
''store object$ on left side stack
  if l <> 0 then '   <<<<<<<<<<<<<<<<<<<<,,
    push$ = object$ + cut$ + stack$
  else
    'push$ =stack$ +object$ +cut$
    push$ = stack$ + cut$ + object$    '   <<<<<<<<<<<<<<<<
  end if
end function

function pop$( stack$ )
''delete last object$
  i = instr( stack$ , cut$ )
  if stack$ = "" then pop$ = ""
''get right side of stack
  pop$ = mid$( stack$ , i + 1 , len( stack$ ) -i )
end function

function top$( stack$)
''read last object$
  i = instr( stack$ , cut$ )
  if stack$ = "" then
    top$ = ""
  else
    top$ = mid$( stack$ , 1 , i - 1 ) '   <<<<<<<<
  end if
end function

function element( stack$ , e$ )
  fl = 0
  i  = 1
  do
    jf$ = word$( stack$ , i , cut$ )
    if jf$ = e$ then fl = true
    i = i + 1
  loop until jf$ = ""
  element = fl
end function



'function element( stack$, e$)
 ' fl =0
 ' i  =1
 ' while val( word$( stack$, i, cut$)) <>0
    'if word$( stack$, i ) =e$ then f1 =not( 0)
'    if word$( stack$, i ) =e$ then fl =not( 0)
'    i =i +1
'  wend
'  element =fl
'end function
bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm


Keer terug naar Games

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers. en 1 gast

cron