%%%%^^^^^^^%%%%%%%%%%%^^^^^^^^^^^^GUESSING GAME%%%%%%%%%%%^^^^^^^^^^^%%%%%%%%%%%%%%%%%%%%%
%%% By Codi
%%% DO not Copy
% Picking a color for the back ground
colorback (9)
Draw.FillBox (1, 1, maxx, maxy, 9)
var number : int
var guess : int
var numberOfGuesses : int := 0
var start : string
var lowscore : int := 100
var Smiley : int
var x, y : int
var theDateTime, theDate, theTime : string
var lvl : string
var name, fileName : string := "bestscore.t"
var score, fileNo : int
var timeRunning : int
var greeting : string
theDateTime := Time.Date
theDate := theDateTime (1 .. 9)
theTime := theDateTime (11 .. *)
put "Greetings Neigbour!! The date and time today is ", Time.Date
put "Hello, World!"
for i : 1 .. 10
delay (1)
Window.Hide (defWinID)
delay (1)
Window.Show (defWinID)
end for
put "How are you?"
get greeting
if greeting = "good" then
put "thats good i am fine too"
elsif greeting = "bad" then
cls
put " Aww I hope you are better soon"
end if
put "In this game you have to pick a number betwen 1,100 the program will then tell you to guess higher or lower until you get the number"
put "guessed. See how few of guesses it will take you."
loop
% Generating a Random Number
number := Rand.Int (1, 100)
numberOfGuesses := 0
%Asks if the user would like to play again or quit
put "Would you like to play a guessing game? i know you do so all you have to do is type Yes It is CaSe SeNsItIvE or Type No to Quit"
get start
if start = "No" then
quit
elsif start = "Yes" then
end if
cls
loop
locate (4, 1)
put "Please enter a number in the flashing space its about 1/2 a cm tall and 1/4 cm wide."
% Asks the user for a number to see if they get it or not
get guess
% This is the counter it adds one number everytime you make a guess
numberOfGuesses += 1
% this is when the guess is entered the program will tell you to guess higher or lower or you got it!
if guess > number then
put "GUESS LOWER THEN ", guess
elsif guess < number then
put "GUESS HIGHER THEN ", guess
elsif guess = number then
setscreen ("graphics")
for i : 1 .. 3
color (i)
put "Bravo"
end for
end if
exit when guess = number
end loop
% tells you how many guesses
colorback (black)
put "It took you ", numberOfGuesses, " guesses to guess the correct number."
if numberOfGuesses < 5 then
put "Excellent you spend way to much time on this! "
elsif numberOfGuesses > 5 and numberOfGuesses < 10 then
put "Great but there is still room for improvment!"
else
put "Mabye next time you wont suck so bad!"
end if
%getting the best score so far from file
open : fileNo, fileName, get
get : fileNo, name : * %the :*the :* is optional butreads the whole line for multiple names
get : fileNo, score
put " the best score so far is by ", name, " and its a score of ", score
close : fileNo
if numberOfGuesses < score then
put "Congrats you got a best score"
open : fileNo, fileName, put
put "enter your name"
get name
put : fileNo, name
put : fileNo, numberOfGuesses
close : fileNo
end if
timeRunning := Time.Elapsed div 1000
put "This program has ran ", timeRunning, " Seconds"
end loop
|