Fortran How Can I Integrate Two Fortran Programs for a Game of Hangman?

  • Thread starter Thread starter w3390
  • Start date Start date
  • Tags Tags
    Fortran
AI Thread Summary
The discussion centers around integrating two separate Fortran programs for a hangman game. One program constructs the visual representation of the hangman, while the other reads a list of random 8-letter words and reveals them as the player guesses letters. The main challenge is effectively combining these programs using subroutines. The user seeks guidance on how to reference one subroutine without executing the entire code of the other. A suggestion is made to utilize Fortran90's masking feature for managing known and unknown letters, which could streamline the integration process. The focus is on achieving a seamless interaction between the visual and word components of the game.
w3390
Messages
341
Reaction score
0
Hello all,

I am attempting to make a fortran program that allows the user to play a game of hangman. So far I have written a complete program that assembles piece by piece the base, gallows, rope, body parts, etc.. I have another completely separate program that reads from a file 264 random 8-letter words. The user inputs a number that corresponds to the word on that line in the file and the program slowly reveals the word as letters are guessed. Initially I have the word show up as eight stars (********). As the user guesses correctly, the appropriate letters are revealed.

The part I am having trouble with is combining these two programs to work in tandem. I have been told that I should be using two subroutines, where one of the subroutines is the program that develops the picture and the other subroutine is used to analyze the players letter guess and only call the first subroutine if the users guess is incorrect.

My biggest issue is not knowing how to reference one of the subroutines without the CALL statement going through all the picture code or all of the word code.

Any help on how to integrate these two programs would be greatly appreciated.
 
Technology news on Phys.org
w3390 said:
Hello all,

I am attempting to make a fortran program that allows the user to play a game of hangman. So far I have written a complete program that assembles piece by piece the base, gallows, rope, body parts, etc.. I have another completely separate program that reads from a file 264 random 8-letter words. The user inputs a number that corresponds to the word on that line in the file and the program slowly reveals the word as letters are guessed. Initially I have the word show up as eight stars (********). As the user guesses correctly, the appropriate letters are revealed.

The part I am having trouble with is combining these two programs to work in tandem. I have been told that I should be using two subroutines, where one of the subroutines is the program that develops the picture and the other subroutine is used to analyze the players letter guess and only call the first subroutine if the users guess is incorrect.

My biggest issue is not knowing how to reference one of the subroutines without the CALL statement going through all the picture code or all of the word code.

Any help on how to integrate these two programs would be greatly appreciated.

If I understand it right, then I think you will have to go through both subroutines.
In fortran90 there is a mask which is used for array and vector functions.
Maybe you could apply a mask to known or unknown letters.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
59
Views
11K
Replies
8
Views
4K
Replies
4
Views
2K
Replies
2
Views
2K
Replies
6
Views
7K
Replies
20
Views
9K
Back
Top