| | |
Python Game: Norbert Quest
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
For now, the Official Game is still some ways away, so this 10 level cap will be good. For the official game, there'll be an unlimited amount of levels and Higher damaging, more expensive weapons so the battles don't take hours (And trust me, they take hours if you're Level 100, I tried it). The TNL (to next level) of each level will be tnl+level*50, so for the first level, you'd have a 50 tnl, second level 150, third level 300 (It goes up from 0 by the previous TNL added to 50 times the level, so you can imagine it'll get really hard as you level up). And after it all works well, I'll work on a new function called 'Locations' (certain locations [such as a mansion or a circus or something with new enemies] will open up as you level up). It'll keep people playing (since it'll now save and they won't have to restart from level 1 every time) the game like it's a hobby instead of a 'minigame' if you will. Man it sure took long to type this. I wonder if you read it all. If you did, I'll give you a reputation, just ask me for one
.
. •
•
Join Date: May 2008
Posts: 630
Reputation:
Solved Threads: 101
Just as a side note, you could make the game a lot easier (potentially faster too) if you would let the user select things by number.
For example when selecting "battle" "shop" or "exit" if the menu was:
The user could enter '1', '2' or '3' instead of having to type out the whole word.
The same could be applied to the battle sequence.
But even better, might be some way to more automate the battle...something like 'auto-attack' that would keep attacking until the monster was dead or you died. (Maybe you could work out a way for the player to make some input into the battle while it was in-progress?)
In my sample play, I don't believe I have ever been killed by a monster. Especially not after I upgraded my weapons.
Oh...another usability item...when you open the shop, it would be nice to tell them which weapon they're using and how much money they have so they would know what they could afford and which weapons would be an upgrade to the weapon they have.
For example when selecting "battle" "shop" or "exit" if the menu was:
Python Syntax (Toggle Plain Text)
Available options: 1 - Battle 2 - Shop 3 - Exit What would you like to do?
The same could be applied to the battle sequence.
But even better, might be some way to more automate the battle...something like 'auto-attack' that would keep attacking until the monster was dead or you died. (Maybe you could work out a way for the player to make some input into the battle while it was in-progress?)
In my sample play, I don't believe I have ever been killed by a monster. Especially not after I upgraded my weapons.
Oh...another usability item...when you open the shop, it would be nice to tell them which weapon they're using and how much money they have so they would know what they could afford and which weapons would be an upgrade to the weapon they have.
The basic weapons are gonna need to be pimped out because the enemy's HP is gonna sky rocket was past your at the later levels. And there'll be new weapons with the new locations, and there'll be monsters with higher level then you (for example, a monster with your level + 5 or 10 so they're harder to kill and you'd need weapon upgrades.
Oh yeah and the numbers thing. I've thought about it before but I forgot to put them in. The game also needs attack spells or healing spells during a battle, and it needs armor, which I've already got an idea for(Armor = 25, defence = random.randrange(10)+Armor or another number, EnemyAttack - defence = EnemyAttack).
Oh yeah and the numbers thing. I've thought about it before but I forgot to put them in. The game also needs attack spells or healing spells during a battle, and it needs armor, which I've already got an idea for(Armor = 25, defence = random.randrange(10)+Armor or another number, EnemyAttack - defence = EnemyAttack).
Last edited by Norbert X; Mar 4th, 2009 at 4:34 pm.
I simply find this thread amazing, almost 200,000 views. It is now the top viewed python thread, beating second by almost 50 000 views. Im dumfounded how this works.. some google search i think must be leading here. Or norbert has 200 000 friends
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Check out my Site | and join us on IRC | Python Specific IRC
•
•
•
•
I simply find this thread amazing, almost 200,000 views. It is now the top viewed python thread, beating second by almost 50 000 views. Im dumfounded how this works.. some google search i think must be leading here. Or norbert has 200 000 friends
I've check a bunch of google searches and if you search Python Game, Python Quest, Norbert Quest, or anything else similar to this (Including Python Levels) all leads here to Daniweb.com/NorbertQ. It's usually the first thing listed, or close to the top.
EDIT: Ugh nevermind that last one, and the first one. It's been overshadowed by Monty Python and the Quest for the Holy Grail Game searches. Other's are good though.
Last edited by Norbert X; Mar 4th, 2009 at 9:06 pm. Reason: Mistake in Searching
I need help. I couldn't really figure out that self thing you told me so I put self.variable in all the variables and it won't work. Here's the latest NorbertQuest (by the way I need a better name still):
I keep getting this error:
Python Syntax (Toggle Plain Text)
class NorbertQuest(object): import self import random self.w = 0 self.level = 1 self.m = random.randrange(50)+1+level*5 self.cost = 0 self.xp = 0 self.health = 150 self.ehealth = 100 self.money = 0 def Shop(): self.weapon1 = "Steel Knuckles" self.weapon2 = "Knife" self.weapon3 = "Sword" self.weapon4 = "Gun" self.weapon5 = "Rocket Launcher" print \ """ What'll it be? 1 - Steel Knuckles 20$ 2 - Knife 30$ 3 - Sword 100$ 4 - Gun 300$ 5 - Rocket Launcher 1000$ Type exit to quit. """ self.z = input("Which weapon do you want?") if self.z == 1: self.cost = 20 if self.money >= self.cost: print"You have bought",self.weapon1 self.money = self.money - self.cost self.w = 1 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == 2: self.cost = 30 if self.money >= self.cost: print"You have bought",self.weapon2 self.money = self.money - self.cost self.w = 2 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == 3: self.cost = 100 if money >= self.cost: print"You have bought",self.weapon3 self.money = self.money - self.cost self.w = 3 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == 4: self.cost = 300 if money >= self.cost: print"You have bought",self.weapon4 self.money = self.money - self.cost self.w = 4 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == 5: self.cost = 1000 if self.money >= self.cost: print"You have bought",self.weapon5 self.money = self.money - self.cost self.w = 5 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == "exit": self.mode = "restart" def eAttack(): self.attacke = random.randrange(10)+self.level*10 return self.attacke def HP(): self.e = self.eAttack() self.health = self.health - self.e print"Your HP is",self.health def nAttack(): self.attack = random.randrange(10)+level*5 if self.w == 1: self.attack = random.randrange(10)+20+level*5 elif self.w == 2: self.attack = random.randrange(10)+35+level*5 elif self.w == 3: self.attack = random.randrange(10)+55+level*5 elif self.w == 4: self.attack = random.randrange(10)+80+level*5 elif self.w == 5: self.attack = random.randrange(10)+110+level*5 return self.attack tnls = [100, 250, 450, 650, 900, 1200, 1550, 1950, 2400, 2900] def LVL(): if 1 <= level <= len(tnls): tnl = tnls[level-1] if tnl <= xp: level += 1 if level > len(tnls): level = 100 xp = 0 print("Your new level is %d! Congratulations!" % level) if level == 100: print("Congratulations, you beat the Demo!") def EnemyHP(): self.n = self.nAttack() self.ehealth = self.ehealth - self.n print "Monster's HP is",ehealth self.monster = "Giant Python!" while True: print \ """ Welcome to NorbertQuest! Type: - [battle] to hunt monsters - [shop] to buy weapons - [exit] to quit the game. """ self.mode = raw_input("What do you want to do?: ") if self.mode == "shop": Shop() if self.mode == "battle": print"You have encountered a",monster,"What will you do?" self.health = 150+self.level*100 self.ehealth = 100+self.level*125 self.m = random.randrange(50)+1+self.level*5 self.xpGain = random.randrange(25)+self.level+25 self.xp = self.xpGain + self.xp LVL() while self.mode == "battle": self.fight = random.randrange(10)+1 if self.fight == 1: self.monster = "Dragon!" elif self.fight == 2: self.monster = "Wild Cayote!" elif self.fight == 3: self.monster == "Jaguar!" elif self.fight == 4: self.monster = "Orc Lord!" elif self.fight == 5: self.monster = "Goblin!" elif self.fight == 6: self.monster = "Crazy Robot!" elif self.fight == 7: self.monster = "Werewolf!" elif self.fight == 8: self.monster = "Vampire!" elif self.fight == 9: self.monster = "Giant Spider!" elif self.fight == 10: self.monster = "Pirate King!" self.turn = raw_input("Do you want to Attack or Defend?") if"attack"in self.turn: print"You're attacking!" EnemyHP() HP() elif"defend"in self.turn: print"You're defending!" print"Monster's HP is",self.ehealth print"Your HP is",self.health else: print"Type attack or Defend!" if self.health <= 0: print"You are dead!" self.mode = "restart" resetHP() elif self.ehealth <= 0: print "You win the battle! You earn",m,"$!" self. money = self.money + self.m self.mode = "restart" resetHP() self.m = random.randrange(50)+1+self.level*5 self.xpGain = random.randrange(25)+self.level+25 self.xp = self.xpGain + self.xp LVL() print"You gain",self.xpGain,"Experience Points!" if self.mode == "exit": self.exit = raw_input("Are you sure you want to quit? All progress will be lost. Yes or no: ") if"yes"in self.exit: break elif"no"in self.exit: self.mode = "restart" raw_input("Press [enter] to exit.") n = NorbertQuest() n.HP()
I keep getting this error:
Python Syntax (Toggle Plain Text)
Traceback (most recent call last): File "C:\Documents and Settings\taf\My Documents\Norbert Quest RPG v1", line 2, in <module> class NorbertQuest(object): File "C:\Documents and Settings\taf\My Documents\Norbert Quest RPG v1", line 4, in NorbertQuest self.w = 0 NameError: name 'self' is not defined
Ah what you have to do is have an __init__ method, this is a method that runs when the class is instantiated (when you make a variable of it)
Oh and in all your functions self needs to be the first argument.
When in a class the self argument is given automatically so when calling it you still only need to supply the ones you specify
Hope that helps you out
python Syntax (Toggle Plain Text)
import random class NorbertQuest(object): def __init__(self): self.w = 0 self.level = 1 self.m = random.randrange(50)+1+level*5 self.cost = 0 self.xp = 0 self.health = 150 self.ehealth = 100 self.money = 0 def Shop(): self.weapon1 = "Steel Knuckles" self.weapon2 = "Knife" self.weapon3 = "Sword" self.weapon4 = "Gun" self.weapon5 = "Rocket Launcher" print \ """ What'll it be? 1 - Steel Knuckles 20$ 2 - Knife 30$ 3 - Sword 100$ 4 - Gun 300$ 5 - Rocket Launcher 1000$ Type exit to quit. """ self.z = input("Which weapon do you want?") if self.z == 1: self.cost = 20 if self.money >= self.cost: print"You have bought",self.weapon1 self.money = self.money - self.cost self.w = 1 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == 2: self.cost = 30 if self.money >= self.cost: print"You have bought",self.weapon2 self.money = self.money - self.cost self.w = 2 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == 3: self.cost = 100 if money >= self.cost: print"You have bought",self.weapon3 self.money = self.money - self.cost self.w = 3 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == 4: self.cost = 300 if money >= self.cost: print"You have bought",self.weapon4 self.money = self.money - self.cost self.w = 4 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == 5: self.cost = 1000 if self.money >= self.cost: print"You have bought",self.weapon5 self.money = self.money - self.cost self.w = 5 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == "exit": self.mode = "restart" def eAttack(): self.attacke = random.randrange(10)+self.level*10 return self.attacke def HP(): self.e = self.eAttack() self.health = self.health - self.e print"Your HP is",self.health def nAttack(): self.attack = random.randrange(10)+level*5 if self.w == 1: self.attack = random.randrange(10)+20+level*5 elif self.w == 2: self.attack = random.randrange(10)+35+level*5 elif self.w == 3: self.attack = random.randrange(10)+55+level*5 elif self.w == 4: self.attack = random.randrange(10)+80+level*5 elif self.w == 5: self.attack = random.randrange(10)+110+level*5 return self.attack tnls = [100, 250, 450, 650, 900, 1200, 1550, 1950, 2400, 2900] def LVL(): if 1 <= level <= len(tnls): tnl = tnls[level-1] if tnl <= xp: level += 1 if level > len(tnls): level = 100 xp = 0 print("Your new level is %d! Congratulations!" % level) if level == 100: print("Congratulations, you beat the Demo!") def EnemyHP(): self.n = self.nAttack() self.ehealth = self.ehealth - self.n print "Monster's HP is",ehealth self.monster = "Giant Python!" while True: print \ """ Welcome to NorbertQuest! Type: - [battle] to hunt monsters - [shop] to buy weapons - [exit] to quit the game. """ self.mode = raw_input("What do you want to do?: ") if self.mode == "shop": Shop() if self.mode == "battle": print"You have encountered a",monster,"What will you do?" self.health = 150+self.level*100 self.ehealth = 100+self.level*125 self.m = random.randrange(50)+1+self.level*5 self.xpGain = random.randrange(25)+self.level+25 self.xp = self.xpGain + self.xp LVL() while self.mode == "battle": self.fight = random.randrange(10)+1 if self.fight == 1: self.monster = "Dragon!" elif self.fight == 2: self.monster = "Wild Cayote!" elif self.fight == 3: self.monster == "Jaguar!" elif self.fight == 4: self.monster = "Orc Lord!" elif self.fight == 5: self.monster = "Goblin!" elif self.fight == 6: self.monster = "Crazy Robot!" elif self.fight == 7: self.monster = "Werewolf!" elif self.fight == 8: self.monster = "Vampire!" elif self.fight == 9: self.monster = "Giant Spider!" elif self.fight == 10: self.monster = "Pirate King!" self.turn = raw_input("Do you want to Attack or Defend?") if"attack"in self.turn: print"You're attacking!" EnemyHP() HP() elif"defend"in self.turn: print"You're defending!" print"Monster's HP is",self.ehealth print"Your HP is",self.health else: print"Type attack or Defend!" if self.health <= 0: print"You are dead!" self.mode = "restart" resetHP() elif self.ehealth <= 0: print "You win the battle! You earn",m,"$!" self. money = self.money + self.m self.mode = "restart" resetHP() self.m = random.randrange(50)+1+self.level*5 self.xpGain = random.randrange(25)+self.level+25 self.xp = self.xpGain + self.xp LVL() print"You gain",self.xpGain,"Experience Points!" if self.mode == "exit": self.exit = raw_input("Are you sure you want to quit? All progress will be lost. Yes or no: ") if"yes"in self.exit: break elif"no"in self.exit: self.mode = "restart" raw_input("Press [enter] to exit.") n = NorbertQuest() n.HP()
python Syntax (Toggle Plain Text)
def this(self): #do stuff #rather than def this(): #do stuff
python Syntax (Toggle Plain Text)
class Test(object): def printforme(self, pr): print pr t = Test() t.printforme("hello")#notice i dont need to worry about self?
Hope that helps you out
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Check out my Site | and join us on IRC | Python Specific IRC
I'm still getting an error. Maybe I did something wrong?
Python Syntax (Toggle Plain Text)
import random class NorbertQuest(object): def __init__(self): self.w = 0 self.level = 1 self.m = random.randrange(50)+1+level*5 self.cost = 0 self.xp = 0 self.health = 150 self.ehealth = 100 self.money = 0 def Shop(): self.weapon1 = "Steel Knuckles" self.weapon2 = "Knife" self.weapon3 = "Sword" self.weapon4 = "Gun" self.weapon5 = "Rocket Launcher" print \ """ What'll it be? 1 - Steel Knuckles 20$ 2 - Knife 30$ 3 - Sword 100$ 4 - Gun 300$ 5 - Rocket Launcher 1000$ Type exit to quit. """ self.z = input("Which weapon do you want?") if self.z == 1: self.cost = 20 if self.money >= self.cost: print"You have bought",self.weapon1 self.money = self.money - self.cost self.w = 1 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == 2: self.cost = 30 if self.money >= self.cost: print"You have bought",self.weapon2 self.money = self.money - self.cost self.w = 2 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == 3: self.cost = 100 if money >= self.cost: print"You have bought",self.weapon3 self.money = self.money - self.cost self.w = 3 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == 4: self.cost = 300 if money >= self.cost: print"You have bought",self.weapon4 self.money = self.money - self.cost self.w = 4 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == 5: self.cost = 1000 if self.money >= self.cost: print"You have bought",self.weapon5 self.money = self.money - self.cost self.w = 5 self.mode = "restart" elif self.money < self.cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") self.mode = "restart" elif self.z == "exit": self.mode = "restart" def eAttack(): self.attacke = random.randrange(10)+self.level*10 return self.attacke def HP(): self.e = self.eAttack() self.health = self.health - self.e print"Your HP is",self.health def nAttack(): self.attack = random.randrange(10)+level*5 if self.w == 1: self.attack = random.randrange(10)+20+level*5 elif self.w == 2: self.attack = random.randrange(10)+35+level*5 elif self.w == 3: self.attack = random.randrange(10)+55+level*5 elif self.w == 4: self.attack = random.randrange(10)+80+level*5 elif self.w == 5: self.attack = random.randrange(10)+110+level*5 return self.attack self.tnls = [100, 250, 450, 650, 900, 1200, 1550, 1950, 2400, 2900] def LVL(): if 1 <= self.level <= len(self.tnls): self.tnl = self.tnls[level-1] if self.tnl <= self.xp: self.level += 1 if self.level > len(self.tnls): self.level = 100 self.xp = 0 print("Your new level is %d! Congratulations!" % se.flevel) if se.flevel == 100: print("Congratulations, you beat the Demo!") def EnemyHP(): self.n = self.nAttack() self.ehealth = self.ehealth - self.n print "Monster's HP is",self.ehealth self.monster = "Giant Python!" while True: print \ """ Welcome to NorbertQuest! Type: - [battle] to hunt monsters - [shop] to buy weapons - [exit] to quit the game. """ self.mode = raw_input("What do you want to do?: ") if self.mode == "shop": Shop() if self.mode == "battle": print"You have encountered a",monster,"What will you do?" self.health = 150+self.level*100 self.ehealth = 100+self.level*125 self.m = random.randrange(50)+1+self.level*5 self.xpGain = random.randrange(25)+self.level+25 self.xp = self.xpGain + self.xp LVL() while self.mode == "battle": self.fight = random.randrange(10)+1 if self.fight == 1: self.monster = "Dragon!" elif self.fight == 2: self.monster = "Wild Cayote!" elif self.fight == 3: self.monster == "Jaguar!" elif self.fight == 4: self.monster = "Orc Lord!" elif self.fight == 5: self.monster = "Goblin!" elif self.fight == 6: self.monster = "Crazy Robot!" elif self.fight == 7: self.monster = "Werewolf!" elif self.fight == 8: self.monster = "Vampire!" elif self.fight == 9: self.monster = "Giant Spider!" elif self.fight == 10: self.monster = "Pirate King!" self.turn = raw_input("Do you want to Attack or Defend?") if"attack"in self.turn: print"You're attacking!" EnemyHP() HP() elif"defend"in self.turn: print"You're defending!" print"Monster's HP is",self.ehealth print"Your HP is",self.health else: print"Type attack or Defend!" if self.health <= 0: print"You are dead!" self.mode = "restart" resetHP() elif self.ehealth <= 0: print "You win the battle! You earn",m,"$!" self. money = self.money + self.m self.mode = "restart" resetHP() self.m = random.randrange(50)+1+self.level*5 self.xpGain = random.randrange(25)+self.level+25 self.xp = self.xpGain + self.xp LVL() print"You gain",self.xpGain,"Experience Points!" if self.mode == "exit": self.exit = raw_input("Are you sure you want to quit? All progress will be lost. Yes or no: ") if"yes"in self.exit: break elif"no"in self.exit: self.mode = "restart" raw_input("Press [enter] to exit.") n = NorbertQuest() n.HP()
![]() |
Other Threads in the Python Forum
- Previous Thread: Ejecting trays of CDs
- Next Thread: Looping through and removing parts of a list
| Thread Tools | Search this Thread |
Tag cloud for Python
accessdenied apache application argv array beginner book change code color converter countpasswordentry dictionary dynamic edit editing enter examples excel file filename float format ftp function gui homework import inches input java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysql newb number numbers numeric output parameters parsing path phonebook port prime programming projects py2exe pygame pyopengl pyqt python random recursion recursive redirect remote reverse scrolledtext session simple smtp software sprite ssh statictext string strings syntax table tennis terminal text thread threading time tkinter tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 variable windows wordgame wxpython





