How to Create Flames Game in Python

In this tutorial, we will create a "How to Create Flames Game in Python". This tutorial will teach you how to program a Flames game. We will tackle and try to understand the concept of this program and learn to code this simple application. I will provide a sample program to demonstrate the actual coding of this tutorial.

This tutorial is simple and easy to understand; just follow the instructions I provide, and you can also do it yourself with ease. The program will try to show you the possible status between the two persons. I will do my best to provide you with the easiest method of creating this program, called "Flames Game". So, let's start with the coding.

Getting Started:

First you will have to download & install the Python IDLE's, here's the link for the Integrated Development And Learning Environment for Python https://www.python.org/downloads/.

Creating Main Function

This is the main function of the application. The following code will display a simple GUI in terminal console of flames game. To do this, simply copy and paste these blocks of code into the IDLE text editor.
  1. def eliminateCommonChars(listOne, listTwo) :
  2. for i in range(len(listOne)) :
  3. for j in range(len(listTwo)) :
  4. if listOne[i] == listTwo[j] :
  5. c = listOne[i]
  6. listOne.remove(c)
  7. listTwo.remove(c)
  8. listThree = listOne + ["*"] + listTwo
  9. return [listThree, True]
  10.  
  11. listThree = listOne + ["*"] + listTwo
  12. return [listThree, False]
  13.  
  14. if __name__ == "__main__" :
  15. print("\n\n=========== Flame Game ===========\n\n")
  16. playerOne = input("First Person Full Name : ")
  17. playerOne = playerOne.lower()
  18. playerOne.replace(" ", "")
  19. playerOneList = list(playerOne)
  20.  
  21. playerTwo = input("Second Person Full Name : ")
  22. playerTwo = playerTwo.lower()
  23. playerTwo.replace(" ", "")
  24. playerTwoList = list(playerTwo)
  25.  
  26. proceed = True
  27.  
  28. while proceed :
  29. retList = eliminateCommonChars(playerOneList, playerTwoList)
  30. conList = retList[0]
  31. proceed = retList[1]
  32. starIndex = conList.index("*")
  33.  
  34. playerOneList = conList[ : starIndex]
  35. playerTwoList = conList[starIndex + 1 : ]
  36.  
  37. theCount = len(playerOneList) + len(playerTwoList)
  38.  
  39.  
  40. res = ["Friends", "Lovers", "Affectionate", "Marriage", "Enemies", "Siblings"]
  41.  
  42. while len(res) > 1 :
  43. splitIndex = (theCount % len(res) - 1)
  44. if splitIndex >= 0 :
  45. right = res[splitIndex + 1 : ]
  46. left = res[ : splitIndex]
  47. res = right + left
  48. else :
  49. res = res[ : len(res) - 1]
  50.  
  51. # print final result
  52. print("Relationship Status :", res[0])

In the provided code, the first thing you will notice is that we create several functions that will handle some important tasks.

Next, we will acquire the names of the two persons with the use of input variables so that we can compare their compatibility later on. Lastly, we will match the two persons and randomize the proper compatibility for each of them.

Output:

The How to Create Flames Game in Python source code that I provide can be download below. Please kindly click the download button.

There you have it we successfully created How to Create Flames Game in Python. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!

More Tutorials for Python Language

Python Tutorials

Add new comment