LB Booster
« SIMON SAYS »

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



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  Notify Send Topic Print
 thread  Author  Topic: SIMON SAYS  (Read 267 times)
bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx SIMON SAYS
« Thread started on: May 9th, 2015, 08:20am »

this is try at simon says

senario :
- then computer shows a colorset
- repeet the colorset
- if you are right
- the computer add a color to the colorset

error :
- it isnt working right

Code:
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , mx , my , mb , true , false
global whois , human , comp , cmem$ , hmem$ , comptel
winx = WindowWidth
winy = WindowHeight
true = not( false )
comp = 1
cmem$ = str$( int( rnd(0) * 4 ) )
comptel = 1
whois = comp
dim p$( 3 )
nomainwin
p$(0)=rect$(0,0,winx/2,winy/2,"pink")
p$(1)=rect$(0,winy/2,winx/2,winy,"blue")
p$(2)=rect$(winx/2,0,winx,winy/2,"red")
p$(3)=rect$(winx/2,winy/2,winx,winy,"green")
open "simon says" for graphics as #m
  #m "trapclose [quit]"
  #m "when leftButtonDown [leftDown]"
  #m "when leftButtonUp [leftUp]"
  #m "setfocus"
  timer 500 , [tmr]
wait
[leftDown]
  mx = MouseX
  my = MouseY
  mb = true
wait
[leftUp]
  mb = false
wait
[tmr]
  if whois = human then
    if mb then
      for i = 0 to 3
        kl = hit( i , mx , my )
        call draw i , kl
        if kl then
          hmem$ = hmem$ + str$( i )
        end if
      next i
    else
      for i = 0 to 3
        call draw i , false
      next i
    end if
    if len( cmem$ ) = len( hmem$ ) then
      if cmem$ = hmem$ then
        comptel = 1
        whois = comp
      else
        timer 0
        notice chr$( 13 )+ "Score : " ; len( hmem$ )
        close #m
        end
      end if
    end if
    timer 500 , [tmr]
  else
    if comptel <= len( cmem$ ) then
      kl = val( mid$( cmem$ , comptel , 1 ) )
    else
      kl = int( rnd(0) * 4 )
      cmem$ = cmem$ + str$( kl )
      comptel = 0
      whois = human
    end if
    comptel = comptel + 1
    for i = 0 to 3
      if i = kl then
        call draw i , true
      else
        call draw i , false
      end if
    next i

  end if
wait
[quit]
  close #m
end


function rect$( a , b , c , d , kl$ )
''constructor of rect objects
  rect$ = str$( a ) + "  " ; b ; " " ; c ; "  " ; d _
  ; " " ; kl$
end function
function hit( i , x , y )
''look if x,y hit rect i
    x1 = val( word$( p$( i ) , 1 ) )
    y1 = val( word$( p$( i ) , 2 ) )
    x2 = val( word$( p$( i ) , 3 ) )
    y2 = val( word$( p$( i ) , 4 ) )
    uit = true
    if x < x1 or x > x2 then uit = false
    if y < y1 or y > y2 then uit = false
    hit = uit
end function
sub draw i , light
''draw rect i dark if not light
  kl$ = word$( p$( i ) , 5 )
  if not( light ) then
    kl$ = "dark" + kl$
  end if
  x1 = val( word$( p$( i ) , 1 ) )
  y1 = val( word$( p$( i ) , 2 ) )
  x2 = val( word$( p$( i ) , 3 ) )
  y2 = val( word$( p$( i ) , 4 ) )
  #m "goto " ; x1 ; " " ; y1
  #m "backcolor " ; kl$
  #m "down"
  #m "boxfilled " ; x2 ; " " ; y2
  #m "up"
end sub
 
User IP Logged

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

| |

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