View.Set ("graphics;nocursor;offscreenonly")
var players : int := 2
var counter, wrong : int := 0
var points : array 1 .. players of int
for i : 1 .. players
points (i) := 0
end for
var file : int
var list : string
var filename : string := "Wordlist.txt"
open : file, filename, get
loop
exit when eof (file)
get : file, list
counter += 1
end loop
close : file
var RANDOM_WORD : array 1 .. counter of string
var junkword : string
open : file, filename, get
for i : 1 .. counter
get : file, junkword
RANDOM_WORD (i) := junkword
end for
close : file
var guess : string
var word : string := Str.Upper (RANDOM_WORD (Rand.Int (1, counter)))
var save : array 1 .. length (word) of string
var col : int := white
var font : int := Font.New ("Serif:30")
var X, Y : int := 0
var picID : int
var turn : int := 1
var ch : char
var keys : array char of boolean
picID := Pic.New (0, 0, maxx, maxy)
Pic.Save (picID, "save.bmp")
View.SetTransparentColour (black)
procedure Refresh
Draw.FillBox (0, 0, maxx, maxy, 11)
Draw.FillBox (150, 35, maxx - 213, maxy - 85, blue)
Draw.FillBox (150, maxy - 85, maxx - 213, maxy - 35, yellow)
Font.Draw ("THE WORD IS " + word, 225, maxy - 10, defFontID, black)
%Font.Draw ("STARTS WITH " + word (1), 225, maxy - 10, defFontID, black)
Font.Draw ("LINGO", 235, maxy - 75, font, brightred)
for i : 1 .. players
Font.Draw ("P" + intstr (i) + ": ", 15, maxy div 2 + 100 - 35 * i,
font, black)
Font.Draw (intstr (points (i)), 90, maxy div 2 + 100 - 35 * i, font,
brightred)
end for
Pic.Draw (picID, 0, 0, picMerge)
Font.Draw ("~~~RULES~~~", 480, 300, defFontID, black)
Font.Draw ("Lingo is simple, ", 460, 280, defFontID, black)
Font.Draw ("Object is to guess a ", 450, 270, defFontID, black)
Font.Draw ("5 Letter Word", 460, 260, defFontID, black)
Font.Draw ("Correct Letter", 445, 230, defFontID, black)
Font.Draw ("turns green", 455, 220, defFontID, green)
Font.Draw ("Wrong Position", 445, 200, defFontID, black)
Font.Draw ("turns red", 460, 190, defFontID, brightred)
Font.Draw ("Isn't In The Word", 445, 170, defFontID, black)
Font.Draw ("turns white", 465, 160, defFontID, white)
Font.Draw ("ENTER to enter a word", 445, 130, defFontID, black)
for i : 0 .. 10 by 2
Draw.Line (150, 35 + X, maxx - 213, 35 + X, white)
Draw.Line (150 + X, 35, 150 + X, maxy - 85, white)
X += 55
end for
Draw.Box (150, 35, maxx - 213, maxy - 35, black)
View.Update
end Refresh
procedure Letter (frequency, duration, clr : int)
Music.Sound (frequency, duration)
Music.SoundOff
Font.Draw (ch, 175 + X, maxy - 125 - Y, font, clr)
end Letter
loop
Refresh
X := 0
for i : 1 .. length (word)
ch := Str.Upper (getchar)
save (i) := ch
if ch = word (i) then
Letter (200, 10, brightgreen)
col := brightgreen
else
Letter (50, 1, white)
col := white
end if
for x : 1 .. 5
if ch = word (x) and col not= brightgreen then
Letter (100, 100, brightred)
end if
end for
%Font.Draw (ch, 175 + X, maxy - 125 - Y, font, col)
X += 50
View.Update
end for
picID := Pic.New (0, 0, maxx, maxy)
Pic.Save (picID, "save.bmp")
loop
Input.KeyDown (keys)
exit when keys (KEY_ENTER)
end loop
X := 0
Y += 55
% for i : 1 .. counter
% if save (1) + save (2) + save (3) + save (4) + save (5) not=
% RANDOM_WORD (i) then
% break
% end if
% end for
if save (1) + save (2) + save (3) + save (4) + save (5) = word then
points (turn) += 1
turn += 1
cls
Y := 0
picID := Pic.New (0, 0, maxx, maxy)
Pic.Save (picID, "save.bmp")
word := Str.Upper (RANDOM_WORD (Rand.Int (1, counter)))
elsif save (1) + save (2) + save (3) + save (4) + save (5) not= word then
wrong += 1
end if
if wrong = 5 then
Font.Draw ("The word was " + word, maxx div 2 - 100, 10, defFontID,
black)
View.Update
Input.Pause
cls
turn += 1
wrong := 0
Y := 0
picID := Pic.New (0, 0, maxx, maxy)
Pic.Save (picID, "save.bmp")
word := Str.Upper (RANDOM_WORD (Rand.Int (1, counter)))
end if
if turn > players then
turn := 1
end if
View.Update
end loop
|