:
This message was edited by juice88 at 2004-12-22 8:37:46
: : : : :
This message was edited by zibadian at 2004-11-19 12:49:51
: : : : : : : : : : i have some questions about crossword ~
: : : : : : : : : : \Please help me!
: : : : : : : : : :
: : : : : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : : : : :
: : : : : : : : : : 2) I want to know does pascal has this function??
: : : : : : : : : : if i input the right answer in the game
: : : : : : : : : : then the colour of text will change to another colour~~
: : : : : : : : : : How can do this??
: : : : : : : : : :
: : : : : : : : : : Suggest the simplest way to me~
: : : : : : : : : : THZ~
: : : : : : : : : :
: : : : : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : : : : :
: : : : : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : : : : :
: : : : : : : : THX~
: : : : : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : : : : :
: : : : : : : :
: : : : : : : :
: : : : : : : :
: : : : : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : : : : :
: : : : : : OK!The problem has been solved.
: : : : : :
: : : : : : 2)I think this method is not suitable in my idea.
: : : : : : My idea is like that:
: : : : : : I had set a display with many letters for the player to choose them.
: : : : : : If they choose a right letter, it will change colour.
: : : : : :
: : : : : : Any other method??
: : : : : :
: : : : : : 3)How to set a timer that count down 30 minutes.
: : : : : :
: : : : : :
: : : : : 2: You could change the color directly in the video memory, but that would require some assembly and an intricate knowledge of the video memory. The only true-Pascal way is to use TextColor(), TextBackround(), GotoXY() and write() to set it.
: : : : :
: : : : : 3: The only two ways to do this is to either use interrupts, or use a loop and GetTime(). Here is a sample code to illustrate the latter:
: : : : :
: : : : : function TimeInMin: Word;
: : : : : var
: : : : : Hour, Minutes, Seconds, HSeconds: word;
: : : : : begin
: : : : : GetTime(Hour, Minutes, Seconds, HSeconds);
: : : : : TimeInMin := Hour*60+Minutes;
: : : : : end;
: : : : :
: : : : : var
: : : : : GameFinished: boolean;
: : : : : { program part }
: : : : : GameStartTime := TimeInMin;
: : : : : GameFinished := false;
: : : : :
: : : : : repeat
: : : : :
: : : : : { Do Game }
: : : : : { Do not use read() or readln(), because those have their own waiting routine }
: : : : : { but readkey() and keypressed() instead }
: : : : : { If the player successfully finishes the game set the GameFinished to true }
: : : : : { If you want to let the player know how much time is left: }
: : : : : { write the following result somewhere: 30-(TimeInMin-GameStart) }
: : : : :
: : : : : until (TimeInMin = GameStartTime+30) or GameFinished;
: : : : :
: : : : : if GameFinished then
: : : : : PlayerHasWon
: : : : : else
: : : : : PlayerHasLost;
: : : : :
: : : : :
: : : : :
: : : : :
: : : : That can be inserted any where in the loop:
: : : :
: : : : GotoXY(1,2);
: : : : write('Time left: ', 3-(TimeInMin-GameStart));
: : : :
: : : : This code will cause flickering of the time left. A better way is to check if the time left is changed since the last writing of it, which involves a simple if-then and storing the value of time left after writing it.
: : : :
: : : I can't play the timer and main program at the same time ~
: : : Maybe some program formed
: : : Can you help me to see~?
: : : My program:
: : : repeat
: : : GotoXY(1,2);
: : : write('Time left: ', 3-(TimeInMin-GameStart));
: : :
: : : repeat
: : : ans 1
: : : until XXXXX
: : :
: : : repeat
: : : ans 2
: : : until XXXXX
: : :
: : : repeat
: : : ans 3
: : : until XXX
: : :
: : : until
: : : (TimeInMin = GameStartTime+3) or GameFinished;
: : : write('You are loss);
: : :
: : : it can't work~
: : :
: : :
: : :
: : There is only 1 repeat-until loop:
: :
: : repeat
: : GotoXY(1,2);
: : write('Time left: ', 3-(TimeInMin-GameStart));
: : ans 1
: : ans 2
: : ans 3
: : until
: : (TimeInMin = GameStartTime+3) or GameFinished;
: : write('You are loss);
: :
: : If you want to indicate a wrong answer, you need to add a boolean variable to the game. This variable can also be used to finish the loop.
: :
: I stil cant do this!!
: ><"
: I think you misunderstand my program~
: My program is check the letter of the answer one by one ,
: not check the complete answer one by one.
: By similiar
: if the answer is 'Food'
: The player first input the first letter of his answer
: then I check it .
: if his lettter is incorrect , he will input it again until the letter is 'F' ,then he can input the second letter.
: Therefore ,many repeat loop must be used , then how can I add the timer in it??
:
: Sorry, my expreesion is not clear,
: hope that you can solve my program.
:
:
:
The following code lets the user enter 1 letter at a time. This is repeated for the entire answer or the time runs out. I've left out some simple parts, or parts, which I already detailed previously.
for i := 1 to Length(Answer) do
begin
repeat
{ User enters letter }
until (UserEnteredLetter = Answer[i]) or (TimeInMin => GameStartTime+3);
if TimeInMin => GameStartTime+3 then
Break;
end;