Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
how to create a game using only crt? Posted by red3warlord on 11 Jan 2007 at 9:48 PM
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.
Report
Re: how to create a game using only crt? Posted by Phat Nat on 12 Jan 2007 at 3:34 PM
: 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)

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.


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:
+-+-+
|I|S|
+-+-+
| |O|
+-+-+

So we would make two arrays that are 2x2:
VAR
   Answer : Array[1..2,1..2] Of Char;
   Guess  : Array[1..2,1..2] Of Char;

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:
CONST
     Answer : Array[1..2,1..2] Of Char =
       (('I','S'),
        (' ','O'));


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

Report
Re: how to create a game using only crt? Posted by red3warlord on 16 Jan 2007 at 3:07 AM
: : 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)
:
:
: 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.
: 

:
: 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:
:
: +-+-+
: |I|S|
: +-+-+
: | |O|
: +-+-+
: 

: So we would make two arrays that are 2x2:
:
: VAR
:    Answer : Array[1..2,1..2] Of Char;
:    Guess  : Array[1..2,1..2] Of Char;
: 

: 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:
:
: CONST
:      Answer : Array[1..2,1..2] Of Char =
:        (('I','S'),
:         (' ','O'));
: 

:
: 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:
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.

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?
Report
Re: how to create a game using only crt? Posted by zibadian on 16 Jan 2007 at 1:51 PM
: : : 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)
: :
: :
: : 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.
: : 

: :
: : 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:
: :
: : +-+-+
: : |I|S|
: : +-+-+
: : | |O|
: : +-+-+
: : 

: : So we would make two arrays that are 2x2:
: :
: : VAR
: :    Answer : Array[1..2,1..2] Of Char;
: :    Guess  : Array[1..2,1..2] Of Char;
: : 

: : 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:
: :
: : CONST
: :      Answer : Array[1..2,1..2] Of Char =
: :        (('I','S'),
: :         (' ','O'));
: : 

: :
: : 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:
:
: 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.
: 

: 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:
  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.

Report
Re: how to create a game using only crt? Posted by red3warlord on 16 Jan 2007 at 9:04 PM
: : : : 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)
: : :
: : :
: : : 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.
: : : 

: : :
: : : 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:
: : :
: : : +-+-+
: : : |I|S|
: : : +-+-+
: : : | |O|
: : : +-+-+
: : : 

: : : So we would make two arrays that are 2x2:
: : :
: : : VAR
: : :    Answer : Array[1..2,1..2] Of Char;
: : :    Guess  : Array[1..2,1..2] Of Char;
: : : 

: : : 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:
: : :
: : : CONST
: : :      Answer : Array[1..2,1..2] Of Char =
: : :        (('I','S'),
: : :         (' ','O'));
: : : 

: : :
: : : 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:
: :
: : 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.
: : 

: : 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:
:
:   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.
: 

:
thank you for your evaluation....



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.