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

  • Context: Fortran 
  • Thread starter Thread starter w3390
  • Start date Start date
  • Tags Tags
    Fortran
Click For Summary
SUMMARY

The discussion focuses on integrating two Fortran programs to create a Hangman game. One program assembles the visual components of the game, while the other reads from a file containing 264 random 8-letter words. The user inputs a number to select a word, which is revealed progressively as letters are guessed. The main challenge is effectively using subroutines to manage the interaction between the visual and word-processing components without executing unnecessary code. The suggestion includes utilizing Fortran 90's masking feature for handling known and unknown letters.

PREREQUISITES
  • Understanding of Fortran programming, specifically Fortran 90 syntax
  • Familiarity with subroutines and their implementation in Fortran
  • Knowledge of file I/O operations in Fortran for reading word lists
  • Basic concepts of game development, particularly in text-based games
NEXT STEPS
  • Explore Fortran 90 subroutine structures and best practices
  • Learn about implementing masking techniques in Fortran for array manipulation
  • Research file handling in Fortran to efficiently read and manage word lists
  • Study game loop mechanics in text-based games to enhance user interaction
USEFUL FOR

Fortran developers, game programmers, and anyone interested in integrating multiple Fortran programs for interactive applications.

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.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 59 ·
2
Replies
59
Views
12K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
7K
  • · Replies 20 ·
Replies
20
Views
9K