crossword!!

2

Comments

  • : [b][red]This message was edited by juice88 at 2004-12-22 8:37:46[/red][/b][hr]
    : : : : : [b][red]This message was edited by zibadian at 2004-11-19 12:49:51[/red][/b][hr]
    : : : : : : : : : : 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 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:
    : : : : : [code]
    : : : : : 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;
    : : : : : [/code]
    : : : : :
    : : : : :
    : : : : :
    : : : : That can be inserted any where in the loop:
    : : : : [code]
    : : : : GotoXY(1,2);
    : : : : write('Time left: ', 3-(TimeInMin-GameStart));
    : : : : [/code]
    : : : : 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:
    : : [code]
    : : 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);
    : : [/code]
    : : 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.
    [code]
    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;
    [/code]
  • : : :
    : : 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.
    : [code]
    : 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;
    : [/code]
    :

    thank you!!
    Can you help me to find out what mistakes are??
    [code]
    begin
    Answer:='Food';
    for i:=1 to Length(Answer) do
    begin
    repeat
    if Keypressed then
    begin
    GotoXY(8,34);
    write(3-(TimeInMin-GameStartTime));
    GotoXY(3,21);
    ch :=readkey;
    case ch of
    #8 :Delete(PlayerGuess,Length(PlayerGuess),1);
    #13 :InputFinished :=true;
    #0 : ch:=readkey;
    #1..#7,#9..#12,#14..#19:begin end;
    else PlayerGuess:=PlayerGuess+ch;
    end;
    if i=1 then { Go to the certain position then enter
    GotoXY(3,21); letter}
    write(ch);

    if i=2 then
    GotoXY(5,21);
    write(ch);

    if i=3 then
    GotoXY(8,21);
    write(ch);

    if i=4 then
    GotoXY(11,21);
    write(ch);
    end;
    until (PlayerGuess[i]=Answer[i]) or (TimeInMin >= GameStartTime+3) ;

    if InputFinshed then
    begin

    if PlayerGuess[1]=Answer[1] <--{ change colour in display }
    then
    GotoXY(1,2)
    TextColor(7);
    write('F');

    if PlayerGuess[2]=Answer[2]
    then
    GotoXY(1,5);
    TextColor(7);
    write('O');

    if PlayerGuess[3]=Answer[3]
    then
    GotoXY(3,5);
    TextColor(7);
    write('O');

    if PlayerGuess[4]=Answer[4]
    then
    GotoXY(3,6);
    TextColor(7);
    write('D');

    if PlayerGuess[i]=Answer[i]
    then
    write('Win');

    if PlayerGuess[i] <> Answer[i] <---{ Get hint }
    then
    Hint

    if Hint=4 <---{ no chance}
    then
    write('Loss');

    if TimeInMin = GameStartTime+3 {Times up}
    then
    write'Times up');

    end.
    [/code]

    The problem is the position of the user entered.
    I have creat certain boxes that the user can fill in the box.
    But how to set the coordinate in readkey ??



    :
  • [b][red]This message was edited by juice88 at 2004-12-31 23:54:41[/red][/b][hr]
    : : : :
    : : : 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.
    : : [code]
    : : 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;
    : : [/code]
    : :
    :
    : thank you!!
    : Can you help me to find out what mistakes are??
    : [code]
    : begin
    : Answer:='Food';
    : for i:=1 to Length(Answer) do
    : begin
    : repeat
    : if Keypressed then
    : begin
    : GotoXY(8,34);
    : write(3-(TimeInMin-GameStartTime));
    : GotoXY(3,21);
    : ch :=readkey;
    : case ch of
    : #8 :Delete(PlayerGuess,Length(PlayerGuess),1);
    : #13 :InputFinished :=true;
    : #0 : ch:=readkey;
    : #1..#7,#9..#12,#14..#19:begin end;
    : else PlayerGuess:=PlayerGuess+ch;
    : end;
    : if i=1 then { Go to the certain position then enter
    : GotoXY(3,21); letter}
    : write(ch);
    :
    : if i=2 then
    : GotoXY(5,21);
    : write(ch);
    :
    : if i=3 then
    : GotoXY(8,21);
    : write(ch);
    :
    : if i=4 then
    : GotoXY(11,21);
    : write(ch);
    : end;
    : until (PlayerGuess[i]=Answer[i]) or (TimeInMin >= GameStartTime+3) ;
    :
    : if InputFinshed then
    : begin
    :
    : if PlayerGuess[1]=Answer[1] <--{ change colour in display }
    : then
    : GotoXY(1,2)
    : TextColor(7);
    : write('F');
    :
    : if PlayerGuess[2]=Answer[2]
    : then
    : GotoXY(1,5);
    : TextColor(7);
    : write('O');
    :
    : if PlayerGuess[3]=Answer[3]
    : then
    : GotoXY(3,5);
    : TextColor(7);
    : write('O');
    :
    : if PlayerGuess[4]=Answer[4]
    : then
    : GotoXY(3,6);
    : TextColor(7);
    : write('D');
    :
    : if PlayerGuess[i]=Answer[i]
    : then
    : write('Win');
    :
    : if PlayerGuess[i] <> Answer[i] <---{ Get hint }
    : then
    : Hint
    :
    : if Hint=4 <---{ no chance}
    : then
    : write('Loss');
    :
    : if TimeInMin = GameStartTime+3 {Times up}
    : then
    : write'Times up');
    :
    : end.
    : [/code]
    :
    : The problem is the position of the user entered.
    : I have creat certain boxes that the user can fill in the box.
    : But how to set the coordinate in readkey ??
    :
    :
    :
    : :
    :
    Zibadian???
    Are you here??



  • : : : :
    : : : 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.
    : : [code]
    : : 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;
    : : [/code]
    : :
    :
    : thank you!!
    : Can you help me to find out what mistakes are??
    : [code]
    : begin
    : Answer:='Food';
    : for i:=1 to Length(Answer) do
    : begin
    : repeat
    : if Keypressed then
    : begin
    : GotoXY(8,34);
    : write(3-(TimeInMin-GameStartTime));
    : GotoXY(3,21);
    : ch :=readkey;
    : case ch of
    : #8 :Delete(PlayerGuess,Length(PlayerGuess),1);
    : #13 :InputFinished :=true;
    : #0 : ch:=readkey;
    : #1..#7,#9..#12,#14..#19:begin end;
    : else PlayerGuess:=PlayerGuess+ch;
    : end;
    : if i=1 then { Go to the certain position then enter
    : GotoXY(3,21); letter}
    : write(ch);
    :
    : if i=2 then
    : GotoXY(5,21);
    : write(ch);
    :
    : if i=3 then
    : GotoXY(8,21);
    : write(ch);
    :
    : if i=4 then
    : GotoXY(11,21);
    : write(ch);
    : end;
    : until (PlayerGuess[i]=Answer[i]) or (TimeInMin >= GameStartTime+3) ;
    :
    : if InputFinshed then
    : begin
    :
    : if PlayerGuess[1]=Answer[1] <--{ change colour in display }
    : then
    : GotoXY(1,2)
    : TextColor(7);
    : write('F');
    :
    : if PlayerGuess[2]=Answer[2]
    : then
    : GotoXY(1,5);
    : TextColor(7);
    : write('O');
    :
    : if PlayerGuess[3]=Answer[3]
    : then
    : GotoXY(3,5);
    : TextColor(7);
    : write('O');
    :
    : if PlayerGuess[4]=Answer[4]
    : then
    : GotoXY(3,6);
    : TextColor(7);
    : write('D');
    :
    : if PlayerGuess[i]=Answer[i]
    : then
    : write('Win');
    :
    : if PlayerGuess[i] <> Answer[i] <---{ Get hint }
    : then
    : Hint
    :
    : if Hint=4 <---{ no chance}
    : then
    : write('Loss');
    :
    : if TimeInMin = GameStartTime+3 {Times up}
    : then
    : write'Times up');
    :
    : end.
    : [/code]
    :
    : The problem is the position of the user entered.
    : I have creat certain boxes that the user can fill in the box.
    : But how to set the coordinate in readkey ??
    :
    :
    :
    : :
    :
    It is very annoying~
  • : : : : : 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 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.
    :
    :
    Here is a little function I write for you to handle the key presses:
    [code]
    function ReadText(var UserInput: string; const X, Y: integer): boolean;
    { This is a non-blocking user entry function
    Handles the following key-strokes:
    - Backspace: removes last character
    - Enter: Sets the result to true
    - ASCII Code 32 (space) and upwards are valid characters
    - Removes extended (multi-byte) keypresses
    Other features:
    - Reduces flickering by first checking if the user actually pressed a key
    - positions the input field at X, Y relative to top-left of the screen
    }
    begin
    ReadText := false; { Assume a non-enter key }
    if KeyPressed then { Check for key-press }
    begin
    ch := ReadKey; { Get the ASCII key code }
    case ch of
    #0..#7: ;
    #8: Delete(UserInput, Length(UserInput), 1);
    #9..#12: ;
    #13: ReadText := true;
    #14..#31: ;
    else UserInput := UserInput + ch;
    end;
    while KeyPressed do ReadKey; { Remove extended }
    GotoXY(X, Y); { Show the result at X, Y }
    write(UserInput);
    end;
    end;
    [/code]
    It is untested, but should work.
  • : : : : : : 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 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.
    : :
    : :
    : Here is a little function I write for you to handle the key presses:
    : [code]
    : function ReadText(var UserInput: string; const X, Y: integer): boolean;
    : { This is a non-blocking user entry function
    : Handles the following key-strokes:
    : - Backspace: removes last character
    : - Enter: Sets the result to true
    : - ASCII Code 32 (space) and upwards are valid characters
    : - Removes extended (multi-byte) keypresses
    : Other features:
    : - Reduces flickering by first checking if the user actually pressed a key
    : - positions the input field at X, Y relative to top-left of the screen
    : }
    : begin
    : ReadText := false; { Assume a non-enter key }
    : if KeyPressed then { Check for key-press }
    : begin
    : ch := ReadKey; { Get the ASCII key code }
    : case ch of
    : #0..#7: ;
    : #8: Delete(UserInput, Length(UserInput), 1);
    : #9..#12: ;
    : #13: ReadText := true;
    : #14..#31: ;
    : else UserInput := UserInput + ch;
    : end;
    : while KeyPressed do ReadKey; { Remove extended }
    : GotoXY(X, Y); { Show the result at X, Y }
    : write(UserInput);
    : end;
    : end;
    : [/code]
    : It is untested, but should work.
    :
    I have followed your function but why it can't work ??
    [code]
    function ReadText(var UserInput: string; const X, Y: integer): boolean;
    begin
    ReadText := false; { Assume a non-enter key }
    if KeyPressed then { Check for key-press }
    begin
    GotoXY(X,Y);
    ch := ReadKey; { Get the ASCII key code }
    case ch of
    #0..#7: ;
    #8: Delete(UserInput, Length(UserInput), 1);
    #9 :write('Answer is CLOCK TOWER. (Press ESC to exit)');
    #10..#12: ;
    #13: ReadText := true;
    #14..#26: ;
    #27 :exit; [press ESC then exit]
    #28..#31: ;
    else UserInput := UserInput + ch;
    end;
    while KeyPressed do ReadKey; { Remove extended }
    GotoXY(X, Y); { Show the result at X, Y }
    write(UserInput);
    end;
    end;

    begin
    ClrScr;
    Display;
    GameStartTime := TimeInMin;
    Answer:='LOCKTOWE';
    UserInput:= '';


    for i:=1 to Length(Answer) do
    begin
    repeat
    GotoXY(8,34);
    write(3-(TimeInMin-GameStartTime));

    if i=1 then
    ReadText(UserInput,12,21);

    if i=2 then
    ReadText(UserInput,18,21);

    if i=3 then
    ReadText(UserInput,24,21);

    if i=4 then
    ReadText(UserInput,30,21);

    if i=5 then
    ReadText(UserInput,6,25);

    if i=6 then
    ReadText(UserInput,12,25);

    if i=7 then
    ReadText(UserInput,18,25);

    if i=8 then
    ReadText(UserInput,24,25);


    until (UserInput[i]=Answer[i]) or (TimeInMin > GameStartTime+3);

    if TimeInMin=GameStartTime+3 then
    GotoXY(37,23);
    write('Time Up ! You are loss!');
    exitt(K);
    if K='k' then exit;

    end;

    if ReadText(UserInput,X,Y) then
    begin
    if UserInput[i] <> Answer[i] then
    Get_hint(hint);
    if hint=4 then exitt(K);
    if K='k' then exit;

    if UserInput[1]=Answer[1] then
    textcolor(14);
    GotoXY(11,13);
    write('L') ; {if the letter is right, then the same letter in the Display change color}


    if UserInput[2]=Answer[2] then
    textcolor(14);
    GotoXY(11,15);
    write('O');


    if UserInput[3]=Answer[3] then
    textcolor(14);
    GotoXY(17,15);
    write('C');


    if UserInput[4]=Answer[4] then
    textcolor(14);
    GotoXY(17,17);
    write('K');


    if UserInput[5]=Answer[5] then
    textcolor(14);
    GotoXY(17,9);
    write('T');


    if UserInput[6]=Answer[6] then
    textcolor(14);
    GotoXY(23,9);
    write('O');


    if UserInput[7]=Answer[7] then
    textcolor(14);
    GotoXY(23,11);
    write('W');


    if UserInput[8]=Answer[8] then
    textcolor(14);
    GotoXY(29,11);
    write('E');


    if UserInput=Answer then
    GotoXY(37,22);
    writeln('You are Win!!');
    exitt(K);
    if K='k' then exit;

    end;



    end.
    [/code]








  • : : : : : : 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 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.
    : :
    : :
    : Here is a little function I write for you to handle the key presses:
    : [code]
    : function ReadText(var UserInput: string; const X, Y: integer): boolean;
    : { This is a non-blocking user entry function
    : Handles the following key-strokes:
    : - Backspace: removes last character
    : - Enter: Sets the result to true
    : - ASCII Code 32 (space) and upwards are valid characters
    : - Removes extended (multi-byte) keypresses
    : Other features:
    : - Reduces flickering by first checking if the user actually pressed a key
    : - positions the input field at X, Y relative to top-left of the screen
    : }
    : begin
    : ReadText := false; { Assume a non-enter key }
    : if KeyPressed then { Check for key-press }
    : begin
    : ch := ReadKey; { Get the ASCII key code }
    : case ch of
    : #0..#7: ;
    : #8: Delete(UserInput, Length(UserInput), 1);
    : #9..#12: ;
    : #13: ReadText := true;
    : #14..#31: ;
    : else UserInput := UserInput + ch;
    : end;
    : while KeyPressed do ReadKey; { Remove extended }
    : GotoXY(X, Y); { Show the result at X, Y }
    : write(UserInput);
    : end;
    : end;
    : [/code]
    : It is untested, but should work.
    :
    Yes.I have found something not understand.
    This function is a boolean ,how can it write UserInput??
    It juct consider whether the function is true or false~
    What different between using function and procedure??

    How can I contact you expect in this forum ??

  • : : : : : : : 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 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.
    : : :
    : : :
    : : Here is a little function I write for you to handle the key presses:
    : : [code]
    : : function ReadText(var UserInput: string; const X, Y: integer): boolean;
    : : { This is a non-blocking user entry function
    : : Handles the following key-strokes:
    : : - Backspace: removes last character
    : : - Enter: Sets the result to true
    : : - ASCII Code 32 (space) and upwards are valid characters
    : : - Removes extended (multi-byte) keypresses
    : : Other features:
    : : - Reduces flickering by first checking if the user actually pressed a key
    : : - positions the input field at X, Y relative to top-left of the screen
    : : }
    : : begin
    : : ReadText := false; { Assume a non-enter key }
    : : if KeyPressed then { Check for key-press }
    : : begin
    : : ch := ReadKey; { Get the ASCII key code }
    : : case ch of
    : : #0..#7: ;
    : : #8: Delete(UserInput, Length(UserInput), 1);
    : : #9..#12: ;
    : : #13: ReadText := true;
    : : #14..#31: ;
    : : else UserInput := UserInput + ch;
    : : end;
    : : while KeyPressed do ReadKey; { Remove extended }
    : : GotoXY(X, Y); { Show the result at X, Y }
    : : write(UserInput);
    : : end;
    : : end;
    : : [/code]
    : : It is untested, but should work.
    : :
    : Yes.I have found something not understand.
    : This function is a boolean ,how can it write UserInput??
    : It juct consider whether the function is true or false~
    : What different between using function and procedure??
    :
    : How can I contact you expect in this forum ??
    :
    :
    The function also exports the UserInput parameter (it's a var parameter). The function returns true if the user presses ENTER. You can use this function like a readln if you place it in a repeat-until loop. Inside that loop, you can then perform other code, such as checking for time. Here is an example:
    [code]
    repeat
    until (ReadText(UserInput, 10, 10)) or (Now = EndTime);
    [/code]
    The difference between a function and a procedure is that a function returns a result, while a procedure doesn't. This allows functions to become a part of a larger statement, while procedures are single statements. KeyPressed() is also examples of a function. If KeyPressed was a procedure, I would have had to code the part of the ReadText() function as follows:
    [code]
    begin
    ReadText := false; { Assume a non-enter key }
    KeyPressed(SomeBool);
    if SomeBool then { Check for key-press }
    begin
    [/code]
    and add another temporary variable.
    The ways to contact me are on My Page here at this site.
  • : : : : : : : : 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 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.
    : : : :
    : : : :
    : : : Here is a little function I write for you to handle the key presses:
    : : : [code]
    : : : function ReadText(var UserInput: string; const X, Y: integer): boolean;
    : : : { This is a non-blocking user entry function
    : : : Handles the following key-strokes:
    : : : - Backspace: removes last character
    : : : - Enter: Sets the result to true
    : : : - ASCII Code 32 (space) and upwards are valid characters
    : : : - Removes extended (multi-byte) keypresses
    : : : Other features:
    : : : - Reduces flickering by first checking if the user actually pressed a key
    : : : - positions the input field at X, Y relative to top-left of the screen
    : : : }
    : : : begin
    : : : ReadText := false; { Assume a non-enter key }
    : : : if KeyPressed then { Check for key-press }
    : : : begin
    : : : ch := ReadKey; { Get the ASCII key code }
    : : : case ch of
    : : : #0..#7: ;
    : : : #8: Delete(UserInput, Length(UserInput), 1);
    : : : #9..#12: ;
    : : : #13: ReadText := true;
    : : : #14..#31: ;
    : : : else UserInput := UserInput + ch;
    : : : end;
    : : : while KeyPressed do ReadKey; { Remove extended }
    : : : GotoXY(X, Y); { Show the result at X, Y }
    : : : write(UserInput);
    : : : end;
    : : : end;
    : : : [/code]
    : : : It is untested, but should work.
    : : :

    : The function also exports the UserInput parameter (it's a var parameter). The function returns true if the user presses ENTER. You can use this function like a readln if you place it in a repeat-until loop. Inside that loop, you can then perform other code, such as checking for time. Here is an example:
    : [code]
    : repeat
    : until (ReadText(UserInput, 10, 10)) or (Now = EndTime);
    : [/code]

    But when I do it like this??
    [code]
    repeat
    ReadText(UserInput,10,10);
    until (ReadText(UserInput, 10, 10))

    if (ReadText(UserInput, 10, 10)) then
    begin
    if UserInput<> Answer then <--##
    writeln('Loss');
    else
    writeln('Win');
    end;
    end.
    [/code]

    the program just do the repeat loop.
    I think that it is because the UserInput can not be export
    ,so it can't check the answer.

  • : : : : : : : : : 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 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.
    : : : : :
    : : : : :
    : : : : Here is a little function I write for you to handle the key presses:
    : : : : [code]
    : : : : function ReadText(var UserInput: string; const X, Y: integer): boolean;
    : : : : { This is a non-blocking user entry function
    : : : : Handles the following key-strokes:
    : : : : - Backspace: removes last character
    : : : : - Enter: Sets the result to true
    : : : : - ASCII Code 32 (space) and upwards are valid characters
    : : : : - Removes extended (multi-byte) keypresses
    : : : : Other features:
    : : : : - Reduces flickering by first checking if the user actually pressed a key
    : : : : - positions the input field at X, Y relative to top-left of the screen
    : : : : }
    : : : : begin
    : : : : ReadText := false; { Assume a non-enter key }
    : : : : if KeyPressed then { Check for key-press }
    : : : : begin
    : : : : ch := ReadKey; { Get the ASCII key code }
    : : : : case ch of
    : : : : #0..#7: ;
    : : : : #8: Delete(UserInput, Length(UserInput), 1);
    : : : : #9..#12: ;
    : : : : #13: ReadText := true;
    : : : : #14..#31: ;
    : : : : else UserInput := UserInput + ch;
    : : : : end;
    : : : : while KeyPressed do ReadKey; { Remove extended }
    : : : : GotoXY(X, Y); { Show the result at X, Y }
    : : : : write(UserInput);
    : : : : end;
    : : : : end;
    : : : : [/code]
    : : : : It is untested, but should work.
    : : : :
    :
    : : The function also exports the UserInput parameter (it's a var parameter). The function returns true if the user presses ENTER. You can use this function like a readln if you place it in a repeat-until loop. Inside that loop, you can then perform other code, such as checking for time. Here is an example:
    : : [code]
    : : repeat
    : : until (ReadText(UserInput, 10, 10)) or (Now = EndTime);
    : : [/code]
    :
    : But when I do it like this??
    : [code]
    : repeat
    : ReadText(UserInput,10,10);
    : until (ReadText(UserInput, 10, 10))
    :
    : if (ReadText(UserInput, 10, 10)) then
    : begin
    : if UserInput<> Answer then <--##
    : writeln('Loss');
    : else
    : writeln('Win');
    : end;
    : end.
    : [/code]
    :
    : the program just do the repeat loop.
    : I think that it is because the UserInput can not be export
    : ,so it can't check the answer.
    :
    :
    UserInput is being exported, that's what the var before UserInput is for.
    The repeat until loop you created will not work, because it has a ReadText() inside it. This way the user might press enter for the inner ReadText() and still remain inside the loop. You can however show the time remaining in the loop, like this:
    [code]
    repeat
    GotoXY(1,1);
    Writeln(i);
    inc(i);
    until ReadText(UsderInput, 10, 10);
    if UserInput = Answer then
    Writeln('You win')
    else
    Writeln('You lose');
    [/code]
    You don't need to call ReadText() in the if-then, because the user doesn't have to enter his answer again. In fact your code will check the answer only if the user presses the enter again within a few milliseconds after the first time.
    Run this last code and you'll see what I mean.
  • : : : : : : : : : : 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 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.
    : : : : : :
    : : : : : :
    : : : : : Here is a little function I write for you to handle the key presses:
    : : : : : [code]
    : : : : : function ReadText(var UserInput: string; const X, Y: integer): boolean;
    : : : : : { This is a non-blocking user entry function
    : : : : : Handles the following key-strokes:
    : : : : : - Backspace: removes last character
    : : : : : - Enter: Sets the result to true
    : : : : : - ASCII Code 32 (space) and upwards are valid characters
    : : : : : - Removes extended (multi-byte) keypresses
    : : : : : Other features:
    : : : : : - Reduces flickering by first checking if the user actually pressed a key
    : : : : : - positions the input field at X, Y relative to top-left of the screen
    : : : : : }
    : : : : : begin
    : : : : : ReadText := false; { Assume a non-enter key }
    : : : : : if KeyPressed then { Check for key-press }
    : : : : : begin
    : : : : : ch := ReadKey; { Get the ASCII key code }
    : : : : : case ch of
    : : : : : #0..#7: ;
    : : : : : #8: Delete(UserInput, Length(UserInput), 1);
    : : : : : #9..#12: ;
    : : : : : #13: ReadText := true;
    : : : : : #14..#31: ;
    : : : : : else UserInput := UserInput + ch;
    : : : : : end;
    : : : : : while KeyPressed do ReadKey; { Remove extended }
    : : : : : GotoXY(X, Y); { Show the result at X, Y }
    : : : : : write(UserInput);
    : : : : : end;
    : : : : : end;
    : : : : : [/code]
    : : : : : It is untested, but should work.
    : : : : :
    : :
    : : : The function also exports the UserInput parameter (it's a var parameter). The function returns true if the user presses ENTER. You can use this function like a readln if you place it in a repeat-until loop. Inside that loop, you can then perform other code, such as checking for time. Here is an example:
    : : : [code]
    : : : repeat
    : : : until (ReadText(UserInput, 10, 10)) or (Now = EndTime);
    : : : [/code]
    : :
    : : But when I do it like this??
    : : [code]
    : : repeat
    : : ReadText(UserInput,10,10);
    : : until (ReadText(UserInput, 10, 10))
    : :
    : : if (ReadText(UserInput, 10, 10)) then
    : : begin
    : : if UserInput<> Answer then <--##
    : : writeln('Loss');
    : : else
    : : writeln('Win');
    : : end;
    : : end.
    : : [/code]
    : :
    : : the program just do the repeat loop.
    : : I think that it is because the UserInput can not be export
    : : ,so it can't check the answer.
    : :
    : :
    : UserInput is being exported, that's what the var before UserInput is for.
    : The repeat until loop you created will not work, because it has a ReadText() inside it. This way the user might press enter for the inner ReadText() and still remain inside the loop. You can however show the time remaining in the loop, like this:
    : [code]
    : repeat
    : GotoXY(1,1);
    : Writeln(i);
    : inc(i);
    : until ReadText(UsderInput, 10, 10);
    : if UserInput = Answer then
    : Writeln('You win')
    : else
    : Writeln('You lose');
    : [/code]
    : You don't need to call ReadText() in the if-then, because the user doesn't have to enter his answer again. In fact your code will check the answer only if the user presses the enter again within a few milliseconds after the first time.
    : Run this last code and you'll see what I mean.
    :

    Oh ~I see.
    Is it like this:
    [code]
    repeat
    : GotoXY(1,1);
    : Writeln(3-(TimeInMin-GameStartTime));
    : inc(3-(TimeInMin-GameStartTime)); <---what is inc??
    : until ReadText(UsderInput, 10, 10) <---But how to move to next question??
    : if UserInput[i] <> Answer[i] then
    begin
    Get_hint
    if hint>4 then
    Writeln('You lose')
    : else
    : Writeln('You lose');
    end;
    end.

  • : : : : : 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 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.
    :
    :
    Inc is short for increase, which should be explained in the help files.
    ReadText() is designed to get the whole answer in 1 loop, then you can check it and ask the user the next question.
  • [b][red]This message was edited by juice88 at 2005-1-6 7:45:47[/red][/b][hr]
    [b][red]This message was edited by juice88 at 2005-1-6 7:45:7[/red][/b][hr]
    : : : : : : 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 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.
    : :
    : :
    : Inc is short for increase, which should be explained in the help files.
    : ReadText() is designed to get the whole answer in 1 loop, then you can check it and ask the user the next question.


    But how the program know when should it increase??
    What is the use of this inc() comment in the crossword??

    NO~ I want to get each of the letter in loop,then i can check it one by one and move to next letter if the user entered is right.

    layout
    [code]
    ###########################################
    # # # # # # #
    # # # # # # #
    ###########################################
    [/code]
    There are 6 boxes, the user need to enter the first letter in the first box and press enter and then check it .If the letter is right ,then (GotoXY) move to next box and enter the second letter......Therefore the coordinateXY of each boxes are different .

    So how can the function work in this way??

    :





  • : 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~
    :

    To set the background colour in Pascal use this: textbackground(colour); {colour is where you have to put your colour which you want } and for text colour use this: textcolor(colour);

    Yes no.2 can be done in Pascal but I don't know how.

    Xaser-3



  • : : 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~
    : :
    :
    : To set the background colour in Pascal use this: textbackground(colour); {colour is where you have to put your colour which you want } and for text colour use this: textcolor(colour);
    :
    : Yes no.2 can be done in Pascal but I don't know how.
    :
    : Xaser-3
    :
    Have you read this post http://www.programmersheaven.com/c/MsgBoard/read.asp?Board=16&MsgID=281521&Setting=A0001F2002 ? It is basically the same answer you gave here.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories