Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

how to create a game using only crt?

red3warlordred3warlord Posts: 77Member
my instructor gives me an assignment of making a game using only crt. the problem is, i don't know if i will use procedure of function to execute the result of a certain action. what should i do?

the game my instructor wants me to do is a cross word puzzle.

Comments

  • Phat NatPhat Nat Posts: 757Member
    : my instructor gives me an assignment of making a game using only crt. the problem is, i don't know if i will use procedure of function to execute the result of a certain action. what should i do?
    :
    : the game my instructor wants me to do is a cross word puzzle.
    :

    Well, the CRT Unit contains these procedures/functions (as taken form TP7)

    [code]
    AssignCrt | Proc | Associates a text file with the CRT window.
    ClrEol | Proc | Clears all the characters from the cursor position
    | | to the end of the line.
    ClrScr | Proc | Clears the screen and returns the cursor to the
    | | upper left corner.
    Delay | Proc | Delays a specifed number of milliseconds.
    DelLine | Proc | Deletes the line containing the cursor.
    GotoXY | Proc | Moves the cursor to the given coordinates within
    | | the virtual screen.
    HighVideo | Proc | Selects high-intensity characters.
    InsLine | Proc | Inserts an empty line at the cursor position.
    KeyPressed | Func | Determines if a key has been pressed on the
    | | keyboard.
    LowVideo | Proc | Selects low-intensity characters.
    NormVideo | Proc | Selects the original text attribute read from the
    | | cursor location at startup.
    NoSound | Proc | Turns off the computer's internal speaker.
    ReadKey | Func | Reads a character from the keyboard.
    Sound | Proc | Starts the internal speaker.
    TextBackground | Proc | Selects the background color.
    TextColor | Proc | Selects the foreground character color.
    TextMode | Proc | Selects a specific text mode.
    WhereX | Func | Returns the X coordinate of the current cursor
    | | location.
    WhereY | Func | Returns the Y coordinate of the current cursor
    | | location.
    Window | Proc | Defines a text window on the screen.
    [/code]

    If you stick to these and the system procedures/functions, it should be what he wants.
    Do you have the crossword puzzle or do you have to create it?
    I would suggest that you make two arrays the same size (size depending on how large your crossword puzzle is.
    for example, let's say that we have only two words, "IS" and "SO"
    let's they cross at the "S", so we have a puzzle that is 2 high and 2 wide:
    [code]
    +-+-+
    |I|S|
    +-+-+
    | |O|
    +-+-+
    [/code]
    So we would make two arrays that are 2x2:
    [code]
    VAR
    Answer : Array[1..2,1..2] Of Char;
    Guess : Array[1..2,1..2] Of Char;
    [/code]
    The answer would contain the letters for "IS" & "SO" and guess would contain the letters that the user guesses.
    So:
    ANSWER[1,1] would be "I"
    ANSWER[1,2] would be "S"
    ANSWER[2,1] would be " "
    ANSWER[2,2] would be "O"
    and you could declare it like this:
    [code]
    CONST
    Answer : Array[1..2,1..2] Of Char =
    (('I','S'),
    (' ','O'));
    [/code]

    Then you would need to make the crossword on the screen. You could either try to draw lines between each letter (hard to do in ASCII) or just change the background color of those squares to a different color.
    Any characters that are just a space in the array don't get a different background color. This way it just shows where letters are on the screen.

    So where to start??? I would suggest that you make a CONST crossword (of whatever size you want). Then make a PROCEDURE called "DrawCrossword" or something like that. It would change the background color to WHITE then clears the screen to this color. Then it changes the BackgroundColor() to black and goes through the array, drawing a black space everytime a non-space character is found in ANSWER.
    If done right, you should see a crossword drawn on the screen that matches the letters in your ANSWER array.

    Get this working first and then move on from there. After that works, you can alter that procedure so that if they have filled a letter in GUESS, it shows that instead of a black space. For this, I would suggest making GUESS a CONST with some of the letters filled in so that you know if this is working right or not. Once this part works, then you can change it back to a VAR.

    Always go step-by-step. If you get this all working, then move on to moving the cursor through the crossword (possibly a procedure called MoveCursor), only allowing it to stop on actual boxes (not spaces). Then you can add on the ability to change the space to a letter.

    Finally, make a procedure that will show all the clues at the bottom (or side of the screen).

    Oh, yeah, and you probably want a Function/Procedure that checks if all the GUESSes match all the ANSWERs so that you can end the game when they answer it all right.

    If you are supposed to read the crossword from a file, then add that in afterwards. Otherwise, if you get here, you should be done.

    Hope this gives you a start,
    Phat Nat

  • red3warlordred3warlord Posts: 77Member
    : : my instructor gives me an assignment of making a game using only crt. the problem is, i don't know if i will use procedure of function to execute the result of a certain action. what should i do?
    : :
    : : the game my instructor wants me to do is a cross word puzzle.
    : :
    :
    : Well, the CRT Unit contains these procedures/functions (as taken form TP7)
    :
    : [code]
    : AssignCrt | Proc | Associates a text file with the CRT window.
    : ClrEol | Proc | Clears all the characters from the cursor position
    : | | to the end of the line.
    : ClrScr | Proc | Clears the screen and returns the cursor to the
    : | | upper left corner.
    : Delay | Proc | Delays a specifed number of milliseconds.
    : DelLine | Proc | Deletes the line containing the cursor.
    : GotoXY | Proc | Moves the cursor to the given coordinates within
    : | | the virtual screen.
    : HighVideo | Proc | Selects high-intensity characters.
    : InsLine | Proc | Inserts an empty line at the cursor position.
    : KeyPressed | Func | Determines if a key has been pressed on the
    : | | keyboard.
    : LowVideo | Proc | Selects low-intensity characters.
    : NormVideo | Proc | Selects the original text attribute read from the
    : | | cursor location at startup.
    : NoSound | Proc | Turns off the computer's internal speaker.
    : ReadKey | Func | Reads a character from the keyboard.
    : Sound | Proc | Starts the internal speaker.
    : TextBackground | Proc | Selects the background color.
    : TextColor | Proc | Selects the foreground character color.
    : TextMode | Proc | Selects a specific text mode.
    : WhereX | Func | Returns the X coordinate of the current cursor
    : | | location.
    : WhereY | Func | Returns the Y coordinate of the current cursor
    : | | location.
    : Window | Proc | Defines a text window on the screen.
    : [/code]
    :
    : If you stick to these and the system procedures/functions, it should be what he wants.
    : Do you have the crossword puzzle or do you have to create it?
    : I would suggest that you make two arrays the same size (size depending on how large your crossword puzzle is.
    : for example, let's say that we have only two words, "IS" and "SO"
    : let's they cross at the "S", so we have a puzzle that is 2 high and 2 wide:
    : [code]
    : +-+-+
    : |I|S|
    : +-+-+
    : | |O|
    : +-+-+
    : [/code]
    : So we would make two arrays that are 2x2:
    : [code]
    : VAR
    : Answer : Array[1..2,1..2] Of Char;
    : Guess : Array[1..2,1..2] Of Char;
    : [/code]
    : The answer would contain the letters for "IS" & "SO" and guess would contain the letters that the user guesses.
    : So:
    : ANSWER[1,1] would be "I"
    : ANSWER[1,2] would be "S"
    : ANSWER[2,1] would be " "
    : ANSWER[2,2] would be "O"
    : and you could declare it like this:
    : [code]
    : CONST
    : Answer : Array[1..2,1..2] Of Char =
    : (('I','S'),
    : (' ','O'));
    : [/code]
    :
    : Then you would need to make the crossword on the screen. You could either try to draw lines between each letter (hard to do in ASCII) or just change the background color of those squares to a different color.
    : Any characters that are just a space in the array don't get a different background color. This way it just shows where letters are on the screen.
    :
    : So where to start??? I would suggest that you make a CONST crossword (of whatever size you want). Then make a PROCEDURE called "DrawCrossword" or something like that. It would change the background color to WHITE then clears the screen to this color. Then it changes the BackgroundColor() to black and goes through the array, drawing a black space everytime a non-space character is found in ANSWER.
    : If done right, you should see a crossword drawn on the screen that matches the letters in your ANSWER array.
    :
    : Get this working first and then move on from there. After that works, you can alter that procedure so that if they have filled a letter in GUESS, it shows that instead of a black space. For this, I would suggest making GUESS a CONST with some of the letters filled in so that you know if this is working right or not. Once this part works, then you can change it back to a VAR.
    :
    : Always go step-by-step. If you get this all working, then move on to moving the cursor through the crossword (possibly a procedure called MoveCursor), only allowing it to stop on actual boxes (not spaces). Then you can add on the ability to change the space to a letter.
    :
    : Finally, make a procedure that will show all the clues at the bottom (or side of the screen).
    :
    : Oh, yeah, and you probably want a Function/Procedure that checks if all the GUESSes match all the ANSWERs so that you can end the game when they answer it all right.
    :
    : If you are supposed to read the crossword from a file, then add that in afterwards. Otherwise, if you get here, you should be done.
    :
    : Hope this gives you a start,
    : Phat Nat
    :
    :
    thanks for sharing me a cup of knowledge you have. in that way, you lessen down my worries and doubts. another things is that, it makes me ease....

    uhm... can i ask again a question? if you don't mind.....

    my instructor wanted me to make a program that can show the description of every planet in the solar system.

    this is my concept of the program:
    [code]
    var
    Num1 : integer;
    begin
    clrscr;
    {the outline of the program using ASCII code}
    write('enter number: 'Num1);
    readln;
    if (Num1 = 1) then
    {statements}...;
    if (Num1 = 2) then
    {statements}...;{uand so on until Num1 = 9};
    readln;
    end.
    [/code]
    as the program runs, i can do what i had programmed. the problem is, once i had entered a number and press "Enter" key, and repeat it once again, that's the time it closes the program.

    what can i add so that my program should run even you enter a number for several times?
  • zibadianzibadian Posts: 6,349Member
    : : : my instructor gives me an assignment of making a game using only crt. the problem is, i don't know if i will use procedure of function to execute the result of a certain action. what should i do?
    : : :
    : : : the game my instructor wants me to do is a cross word puzzle.
    : : :
    : :
    : : Well, the CRT Unit contains these procedures/functions (as taken form TP7)
    : :
    : : [code]
    : : AssignCrt | Proc | Associates a text file with the CRT window.
    : : ClrEol | Proc | Clears all the characters from the cursor position
    : : | | to the end of the line.
    : : ClrScr | Proc | Clears the screen and returns the cursor to the
    : : | | upper left corner.
    : : Delay | Proc | Delays a specifed number of milliseconds.
    : : DelLine | Proc | Deletes the line containing the cursor.
    : : GotoXY | Proc | Moves the cursor to the given coordinates within
    : : | | the virtual screen.
    : : HighVideo | Proc | Selects high-intensity characters.
    : : InsLine | Proc | Inserts an empty line at the cursor position.
    : : KeyPressed | Func | Determines if a key has been pressed on the
    : : | | keyboard.
    : : LowVideo | Proc | Selects low-intensity characters.
    : : NormVideo | Proc | Selects the original text attribute read from the
    : : | | cursor location at startup.
    : : NoSound | Proc | Turns off the computer's internal speaker.
    : : ReadKey | Func | Reads a character from the keyboard.
    : : Sound | Proc | Starts the internal speaker.
    : : TextBackground | Proc | Selects the background color.
    : : TextColor | Proc | Selects the foreground character color.
    : : TextMode | Proc | Selects a specific text mode.
    : : WhereX | Func | Returns the X coordinate of the current cursor
    : : | | location.
    : : WhereY | Func | Returns the Y coordinate of the current cursor
    : : | | location.
    : : Window | Proc | Defines a text window on the screen.
    : : [/code]
    : :
    : : If you stick to these and the system procedures/functions, it should be what he wants.
    : : Do you have the crossword puzzle or do you have to create it?
    : : I would suggest that you make two arrays the same size (size depending on how large your crossword puzzle is.
    : : for example, let's say that we have only two words, "IS" and "SO"
    : : let's they cross at the "S", so we have a puzzle that is 2 high and 2 wide:
    : : [code]
    : : +-+-+
    : : |I|S|
    : : +-+-+
    : : | |O|
    : : +-+-+
    : : [/code]
    : : So we would make two arrays that are 2x2:
    : : [code]
    : : VAR
    : : Answer : Array[1..2,1..2] Of Char;
    : : Guess : Array[1..2,1..2] Of Char;
    : : [/code]
    : : The answer would contain the letters for "IS" & "SO" and guess would contain the letters that the user guesses.
    : : So:
    : : ANSWER[1,1] would be "I"
    : : ANSWER[1,2] would be "S"
    : : ANSWER[2,1] would be " "
    : : ANSWER[2,2] would be "O"
    : : and you could declare it like this:
    : : [code]
    : : CONST
    : : Answer : Array[1..2,1..2] Of Char =
    : : (('I','S'),
    : : (' ','O'));
    : : [/code]
    : :
    : : Then you would need to make the crossword on the screen. You could either try to draw lines between each letter (hard to do in ASCII) or just change the background color of those squares to a different color.
    : : Any characters that are just a space in the array don't get a different background color. This way it just shows where letters are on the screen.
    : :
    : : So where to start??? I would suggest that you make a CONST crossword (of whatever size you want). Then make a PROCEDURE called "DrawCrossword" or something like that. It would change the background color to WHITE then clears the screen to this color. Then it changes the BackgroundColor() to black and goes through the array, drawing a black space everytime a non-space character is found in ANSWER.
    : : If done right, you should see a crossword drawn on the screen that matches the letters in your ANSWER array.
    : :
    : : Get this working first and then move on from there. After that works, you can alter that procedure so that if they have filled a letter in GUESS, it shows that instead of a black space. For this, I would suggest making GUESS a CONST with some of the letters filled in so that you know if this is working right or not. Once this part works, then you can change it back to a VAR.
    : :
    : : Always go step-by-step. If you get this all working, then move on to moving the cursor through the crossword (possibly a procedure called MoveCursor), only allowing it to stop on actual boxes (not spaces). Then you can add on the ability to change the space to a letter.
    : :
    : : Finally, make a procedure that will show all the clues at the bottom (or side of the screen).
    : :
    : : Oh, yeah, and you probably want a Function/Procedure that checks if all the GUESSes match all the ANSWERs so that you can end the game when they answer it all right.
    : :
    : : If you are supposed to read the crossword from a file, then add that in afterwards. Otherwise, if you get here, you should be done.
    : :
    : : Hope this gives you a start,
    : : Phat Nat
    : :
    : :
    : thanks for sharing me a cup of knowledge you have. in that way, you lessen down my worries and doubts. another things is that, it makes me ease....
    :
    : uhm... can i ask again a question? if you don't mind.....
    :
    : my instructor wanted me to make a program that can show the description of every planet in the solar system.
    :
    : this is my concept of the program:
    : [code]
    : var
    : Num1 : integer;
    : begin
    : clrscr;
    : {the outline of the program using ASCII code}
    : write('enter number: 'Num1);
    : readln;
    : if (Num1 = 1) then
    : {statements}...;
    : if (Num1 = 2) then
    : {statements}...;{uand so on until Num1 = 9};
    : readln;
    : end.
    : [/code]
    : as the program runs, i can do what i had programmed. the problem is, once i had entered a number and press "Enter" key, and repeat it once again, that's the time it closes the program.
    :
    : what can i add so that my program should run even you enter a number for several times?
    :
    Place the entire body of the program in a repeat-until loop:
    [code]
    repeat
    write('enter number: 'Num1);
    readln;
    if (Num1 = 1) then
    {statements}...;
    if (Num1 = 2) then
    {statements}...;{uand so on until Num1 = 9};
    until Num1 = 9;
    readln;
    end.
    [/code]
  • red3warlordred3warlord Posts: 77Member
    : : : : my instructor gives me an assignment of making a game using only crt. the problem is, i don't know if i will use procedure of function to execute the result of a certain action. what should i do?
    : : : :
    : : : : the game my instructor wants me to do is a cross word puzzle.
    : : : :
    : : :
    : : : Well, the CRT Unit contains these procedures/functions (as taken form TP7)
    : : :
    : : : [code]
    : : : AssignCrt | Proc | Associates a text file with the CRT window.
    : : : ClrEol | Proc | Clears all the characters from the cursor position
    : : : | | to the end of the line.
    : : : ClrScr | Proc | Clears the screen and returns the cursor to the
    : : : | | upper left corner.
    : : : Delay | Proc | Delays a specifed number of milliseconds.
    : : : DelLine | Proc | Deletes the line containing the cursor.
    : : : GotoXY | Proc | Moves the cursor to the given coordinates within
    : : : | | the virtual screen.
    : : : HighVideo | Proc | Selects high-intensity characters.
    : : : InsLine | Proc | Inserts an empty line at the cursor position.
    : : : KeyPressed | Func | Determines if a key has been pressed on the
    : : : | | keyboard.
    : : : LowVideo | Proc | Selects low-intensity characters.
    : : : NormVideo | Proc | Selects the original text attribute read from the
    : : : | | cursor location at startup.
    : : : NoSound | Proc | Turns off the computer's internal speaker.
    : : : ReadKey | Func | Reads a character from the keyboard.
    : : : Sound | Proc | Starts the internal speaker.
    : : : TextBackground | Proc | Selects the background color.
    : : : TextColor | Proc | Selects the foreground character color.
    : : : TextMode | Proc | Selects a specific text mode.
    : : : WhereX | Func | Returns the X coordinate of the current cursor
    : : : | | location.
    : : : WhereY | Func | Returns the Y coordinate of the current cursor
    : : : | | location.
    : : : Window | Proc | Defines a text window on the screen.
    : : : [/code]
    : : :
    : : : If you stick to these and the system procedures/functions, it should be what he wants.
    : : : Do you have the crossword puzzle or do you have to create it?
    : : : I would suggest that you make two arrays the same size (size depending on how large your crossword puzzle is.
    : : : for example, let's say that we have only two words, "IS" and "SO"
    : : : let's they cross at the "S", so we have a puzzle that is 2 high and 2 wide:
    : : : [code]
    : : : +-+-+
    : : : |I|S|
    : : : +-+-+
    : : : | |O|
    : : : +-+-+
    : : : [/code]
    : : : So we would make two arrays that are 2x2:
    : : : [code]
    : : : VAR
    : : : Answer : Array[1..2,1..2] Of Char;
    : : : Guess : Array[1..2,1..2] Of Char;
    : : : [/code]
    : : : The answer would contain the letters for "IS" & "SO" and guess would contain the letters that the user guesses.
    : : : So:
    : : : ANSWER[1,1] would be "I"
    : : : ANSWER[1,2] would be "S"
    : : : ANSWER[2,1] would be " "
    : : : ANSWER[2,2] would be "O"
    : : : and you could declare it like this:
    : : : [code]
    : : : CONST
    : : : Answer : Array[1..2,1..2] Of Char =
    : : : (('I','S'),
    : : : (' ','O'));
    : : : [/code]
    : : :
    : : : Then you would need to make the crossword on the screen. You could either try to draw lines between each letter (hard to do in ASCII) or just change the background color of those squares to a different color.
    : : : Any characters that are just a space in the array don't get a different background color. This way it just shows where letters are on the screen.
    : : :
    : : : So where to start??? I would suggest that you make a CONST crossword (of whatever size you want). Then make a PROCEDURE called "DrawCrossword" or something like that. It would change the background color to WHITE then clears the screen to this color. Then it changes the BackgroundColor() to black and goes through the array, drawing a black space everytime a non-space character is found in ANSWER.
    : : : If done right, you should see a crossword drawn on the screen that matches the letters in your ANSWER array.
    : : :
    : : : Get this working first and then move on from there. After that works, you can alter that procedure so that if they have filled a letter in GUESS, it shows that instead of a black space. For this, I would suggest making GUESS a CONST with some of the letters filled in so that you know if this is working right or not. Once this part works, then you can change it back to a VAR.
    : : :
    : : : Always go step-by-step. If you get this all working, then move on to moving the cursor through the crossword (possibly a procedure called MoveCursor), only allowing it to stop on actual boxes (not spaces). Then you can add on the ability to change the space to a letter.
    : : :
    : : : Finally, make a procedure that will show all the clues at the bottom (or side of the screen).
    : : :
    : : : Oh, yeah, and you probably want a Function/Procedure that checks if all the GUESSes match all the ANSWERs so that you can end the game when they answer it all right.
    : : :
    : : : If you are supposed to read the crossword from a file, then add that in afterwards. Otherwise, if you get here, you should be done.
    : : :
    : : : Hope this gives you a start,
    : : : Phat Nat
    : : :
    : : :
    : : thanks for sharing me a cup of knowledge you have. in that way, you lessen down my worries and doubts. another things is that, it makes me ease....
    : :
    : : uhm... can i ask again a question? if you don't mind.....
    : :
    : : my instructor wanted me to make a program that can show the description of every planet in the solar system.
    : :
    : : this is my concept of the program:
    : : [code]
    : : var
    : : Num1 : integer;
    : : begin
    : : clrscr;
    : : {the outline of the program using ASCII code}
    : : write('enter number: 'Num1);
    : : readln;
    : : if (Num1 = 1) then
    : : {statements}...;
    : : if (Num1 = 2) then
    : : {statements}...;{uand so on until Num1 = 9};
    : : readln;
    : : end.
    : : [/code]
    : : as the program runs, i can do what i had programmed. the problem is, once i had entered a number and press "Enter" key, and repeat it once again, that's the time it closes the program.
    : :
    : : what can i add so that my program should run even you enter a number for several times?
    : :
    : Place the entire body of the program in a repeat-until loop:
    : [code]
    : repeat
    : write('enter number: 'Num1);
    : readln;
    : if (Num1 = 1) then
    : {statements}...;
    : if (Num1 = 2) then
    : {statements}...;{uand so on until Num1 = 9};
    : until Num1 = 9;
    : readln;
    : end.
    : [/code]
    :
    thank you for your evaluation....
Sign In or Register to comment.