Microsoft Small Basic

Program Listing:
Embed this in your website
GraphicsWindow.Width=540
GraphicsWindow.Height=280
GraphicsWindow.CanResize="False"
GraphicsWindow.Title="Spanzuratoarea"
InitializareVieti()
InitializareCuvinte()
GraphicsWindow.KeyUp=Apasare

' subrutina se ocupa de afisarea numarului de vieti
Sub InitializareVieti
  vieti=6
  inima=ImageList.LoadImage("http://www.cnet.ro/wp-content/uploads/2012/07/heart.png")
  For i=1 To vieti
    sirinimi[i]=Shapes.AddImage(inima)
    Shapes.Move(sirinimi[i],10+90*(i-1),50)
  EndFor
  GraphicsWindow.BrushColor="DarkRed"
  GraphicsWindow.FontSize="20"
  cate=Shapes.AddText("Aveţi "+vieti+" vieţi.")
  Shapes.Move(cate,15,10)
EndSub

' subrutina se ocupa de alegerea unui cuvant
' si afisarile legate de cuvantul ales
Sub InitializareCuvinte
  varianta[1]="RINOCER"
  varianta[2]="PAPAGAL"
  varianta[3]="ELEFANT"
  varianta[4]="LEOPARD"
  varianta[5]="HIPOPOTAM"
  varianta[6]="VULTUR"
  varianta[7]="COLIBRI"
  varianta[8]="BALENA"
  varianta[9]="BROASCA"
  varianta[10]="LIBELULA"
  dim=Array.GetItemCount(varianta)
  cuvant=varianta[Math.GetRandomNumber(dim)]
  lungime=Text.GetLength(cuvant)
  indicatii=Shapes.AddText("Aveţi de ghicit un cuvânt de "+lungime+" litere.")
  Shapes.Move(indicatii,20,140)
  corecte=0
  GraphicsWindow.FontSize=43
  GraphicsWindow.FontName="Courier New"
  txtghicire=""
  For i=1 To lungime
    txtghicire=txtghicire+"_ "
    litere[i]=Text.GetSubText(cuvant,i,1)
    aflate[i]=0
  EndFor
  ghicire=Shapes.AddText(txtghicire)
  Shapes.Move(ghicire,20,200)
  litereposibile="QWERTYUIOPASDFGHJKLZXCVBNM"
  litereapasate=""
EndSub

' subrutina reactioneaza la apasarea unei taste (litere)
Sub Apasare
  litera=GraphicsWindow.LastKey
  If (vieti>0) And (corecte<lungime) And (Text.GetIndexOf(litereposibile,litera)<>0)  And (Text.GetIndexOf(litereapasate,litera)=0) Then
    litereapasate=Text.Append(litereapasate,litera)
    gasit=0
    For i=1 To lungime
      If litere[i]=litera And aflate[i]=0 Then
        aflate[i]=1
        gasit=1
        Sound.PlayClick()
        corecte=corecte+1
        txtghicire=""
        For j=1 To lungime
          If aflate[j]=1 Then
            txtghicire=txtghicire+litere[j]+" "
          Else
            txtghicire=txtghicire+"_ "
          EndIf
          Shapes.SetText(ghicire,txtghicire)
        EndFor
        If corecte = lungime Then
          Shapes.SetText(indicatii,"Aţi ghicit cuvântul! Bravo!!!")
          Sound.PlayChime()
        EndIf
      EndIf
    EndFor
    If gasit=0 Then
      Shapes.Animate(sirinimi[vieti],1000,50,1500)
      vieti=vieti-1
      Shapes.SetText(cate,"Mai aveţi "+vieti+" vieţi.")
      Sound.PlayChimes()
    EndIf
    If vieti=0 Then
      Shapes.SetText(indicatii,"Nu aţi reuşit să ghiciţi. Era cuvântul "+cuvant+".")
    EndIf
  EndIf
EndSub
Copyright (c) Microsoft Corporation. All rights reserved.