oude monitor

Algemene discussies en vragen omtrent Liberty BASIC programma's. Stuur zoveel mogelijk delen van listings (snippets) in als je hulp wilt.

Moderators: anthonio, Abcott

oude monitor

Berichtdoor bluatigro » vr okt 03, 2014 10:28 am

dit is een probeersel van n monitor oude style
Code: Selecteer alles
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , linelen , cursorx , cursory , state
global human , comp , size , input$ , cursor
dim p$( 80 , 25 )
winx = WindowWidth
winy = WindowHeight
linelen = 80
human = 0
comp = 1
size = int( winx / linelen )
nomainwin
open "monitor 1.0" for graphics as #m
  #m "trapclose [quit]"
  #m "when characterInput [key]"
  #m "font Courier_new " ; size ; " bold"
  #m "color green"
  #m "backcolor darkgreen"
  #m "fill darkgreen"
  #m "setfocus"
  timer 250 , [tmr]
wait
[tmr]
  cursor = 1 - cursor
  if cursor then
    #m "backcolor green"
  else
    #m "backcolor darkgreen"
  end if
  #m "goto ";cursorx*size;" ";cursory*size*1.2+size
  #m "down"
  #m "\ "
  #m "up"
wait
sub letter a$
  #m "goto ";cursorx*size;" ";cursory*size*1.2+size
  #m "color green"
  #m "backcolor darkgreen"
  #m "down"
  #m "\";a$
  #m "up"
  p$(cursorx,cursory)=a$
  cursorx = cursorx + 1
  if cursorx > linelen then
    cursorx = 0
    cursory = cursory + 1
    if cursory > 25 then
      call shiftscreen
      cursury = 25
    end if
  end if
end sub
sub write a$
  for i = 1 to len( a$ )
    call letter mid$( a$ , i , 1 )
  next i
end sub
sub shiftscreen
  for y = 0 to 24
    for x = 0 to 80
      p$(x,y)=p$(x,y+1)
      #m "goto ";x*size;" ";y*size*1.2+size
      #m "down"
      #m "\";p$(x,y)
      #m "up"
    next x
  next y
end sub
[key]
  key$ = right$( Inkey$ , 1 )
  if key$ = chr$( 27 ) then
    close #m
    end
  end if
  if state = human then
    input$ = ""
    if key$ = chr$( 13 ) then
      call letter " "
      for i = 0 to cursorx - 1
        input$ = input$ + p$(cursory,i)
      next i
      state = comp
    end if
    if ( key$ >= "a" _
     and key$ <= "z" ) _
    or ( key$ >= "A" _
     and key$ <= "Z" ) _
    or   key$ = " " then
      call letter key$
    end if
  end if
  if state = comp then
    cursorx = 0
    cursory = cursory + 1
    call write "o.k."
    state = human
    cursorx = 0
    cursory = cursory + 1
  end if
wait
[quit]
  close #m
end

t werk [ nog ] niet goed
de computer print 2 x o.k.
bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm

Keer terug naar Liberty BASIC Code

Wie is er online

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

cron