+ 1

RPG Game

I'm a beginner. Just started learning python a few weeks ago but haven't actively done anything. My first project (no where near done. at all.) I was wondering how i could have the game file save to my computer. so i could open different characters. <code> import math import time print("""This is pain V 0.01. By Kody Noe A long term side project. Caps do matter. If told to type somthing as 'Example' don't type it as 'example' or it won't work """) #Jaida's Worm (Wormfish) WF= 'Wormfish' #Character things charName = input("{}: What is your name, adventurer?".format(WF)) charHealth = 100 charMana = 100 charGold = 100 charInventory = 0 charHealthMax = 100 charHealthMin = 0 charInv= {"Health Potion" : 0 , "Mana Potion" : 0 ,} #Potion things HealthPotion = charHealth + 25 ManaPotion = charMana + 25 #Progiest things ProgiestPotionsMax = 3 ProgiestManaPotionCount = 3 ProgiestHealthPotionCount = 3 ProgiestShop= "Health Potion: {} | Mana Potion: {}".format(ProgiestHealthPotionCount,ProgiestManaPotionCount, ) Progiest = print("Progiest: Welcome to the town of TinSpire, {} , How may I help you?".format(charName)) userAnswer = input("""Options: Shop Talk Leave {} : """.format(charName)) if userAnswer == 'Shop': print("Progiest: Welcome to my shop!") print("{}".format(ProgiestShop)) input("Would you like to buy something? ('Yes' or 'No')") if 'Yes': input("Type 'Health Potion' or 'Mana Potion' ") if ' Health Potion': input("Buy one Health Potion for 20 gold? ('Yes' or 'No')") if 'Yes': print("Bought one Health Potion for 20 gold") if userAnswer == 'Talk': print("Progiest: What would you like to talk about?") if userAnswer == 'Leave': print("Progiest: Goodbye {}".format(charName)) </code>

24th May 2017, 8:14 PM
Kody Noe
Kody Noe - avatar
2 Réponses
+ 11
First of all you should learn about classes and object oriented programming. It is ideally fitted to RPG games - you define a class called Character which you can later call each time a game character is created. They can share similar attributes (Strength, Power, Mana, Health, etc.) and skills (Attack, Defend, Jump, Run, etc.). It will be fun just learning about it :) As for file saving, that is quite simple. You just have to think of its syntax, it should carry all the variables and data you will need later. There are many ways to do that, but I recommend you 'pickle' module. It takes care of file handling and data formatting for you. You just pickle and unpickle stuff when needed.
24th May 2017, 9:03 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
0
it's me. I want to release it to my friends eventually. so I'll have to research on how to make saving the game via main menu is simple.
25th May 2017, 10:52 AM
Dustyn Noe
Dustyn Noe - avatar