Little word guessing game

Post Reply
Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Little word guessing game

Post by Henko »

There's a quiz on Dutch tele which ends in the task of guessing a 12 letter word by "buying" as few as possible letters.
In this code snippet, select letters from the lower buttons. They will move in the proper position in the upper buttons. Try to guess the word as soon as possible.
My wife loves this game. Of course the amount of avalable words should be extended.

Code: Select all

graphics ! graphics clear ! draw color 0,0,1
option base 1 ! randomize ! set buttons font size 40
dim words$(70),org$(12),hash$(12),fill$(12),ind(12)
nw=25 ! indata(nw)
for i=1 to 12
  button "hash"&i text "" at 55*i,200 size 45,45
  button "fill"&i text "" at 55*i,100 size 45,45
  next i
button "gw" text "try word" at 270,300 size 200,60

do
  word$=words$(1+rnd(nw))
  for i=1 to 12 ! org$(i)=mid$(word$,i,1) ! ind(i)=i ! next i
  for k=1 to 30 
    i=1+rnd(12) ! j=1+rnd(12)
    tt=ind(i) ! ind(i)=ind(j) ! ind(j)=tt
    next k
  for i=1 to 12
    button "hash"&i text org$(ind(i))
    button "fill"&i text ""
    next i
  for i=1 to 12
    do slowdown
      for k=1 to 12
        if button_pressed("hash"&k) then break
        next k
      if button_pressed("gw") then
        input "type word:": w$ ! graphics
        w$=lowstr$(w$)
        if w$=word$ then
          draw text "guessed in "&(i-1)&" turns!" at 50,400
          pause 3 ! graphics clear
          go to volgende
          end if
        end if
      until k<13
    button "hash"&k text ""
    pl=ind(k) ! button "fill"&pl text org$(pl)
    next i
volgende: 
  until forever
end

def indata(nw)
for i=1 to nw ! read .words$(i) ! next i
data "sinisterness","ostentations","torridnesses","interstitial"
data "serenenesses","essentialist","rottennesses","ostentatious"
data "rottenstones","intersterile","restaurateur","rootednesses"
data "totalitarian","irradiations","reinsertions","detestations"
data "rootlessness","otiosenesses","terrestrials","reassertions"
data "teetotalists","territorials","stationeries","testosterone"
data "totalisators"
end def
IMG_1420.PNG
IMG_1420.PNG (1.57 MiB) Viewed 1771 times

User avatar
Dav
Posts: 279
Joined: Tue Dec 30, 2014 5:12 pm
My devices: iPad Mini, iPod Touch.
Location: North Carolina, USA
Contact:

Re: Little word guessing game

Post by Dav »

Nice. Makes me see how limited my vocabulary is. :D

- Dav

Post Reply