Hi Im currently building a script game, soon to be image game. Having trouble with a part of a code. -
ranger_join = raw_input("\nWill you let him?(y/n)? ")
-
-
if ranger_join == "y":
-
print "The ranger joins you on your trip. Yay."
-
-
elif ranger_join == "n":
-
print "The ranger is offended and draws his sword.\n"
-
# attacking the ranger
-
weapon = raw_input("What weapon do you have? Oak Staff or Iron Sword? ")
-
#using the Oak Staff
-
if weapon == "oak staff":
-
attack = 3
-
print "\nYou draw your Oak Staff"
-
attack = 3
-
while ranger_health > 0:
-
ranger_health = ranger_health - attack
-
health = health - ranger_damage
-
-
print "You're hero takes a swing and the ranger has", ranger_health, " health remaining."\
-
"But you have", health, "hit points remaining\n"
-
if health <= 0:
-
print "You died. Bet you wish you stayed at the inn."
-
-
# using the Iron Sword
-
elif weapon == "iron sword":
-
print "\nYou draw your Iron Sword"
-
attack = 5
-
while ranger_health > 0 or health > 0:
-
ranger_health = ranger_health - attack
-
health = health - ranger_damage
-
-
print "You're hero takes a swing and the ranger has", ranger_health, " health remaining."\
-
"But you have", health, "hit points remaining\n"
-
if ranger_health <= 0:
-
print "It sucks"
-
exit
-
#gain an item for defeating ranger
-
-
elif health <= 0:
-
print "You died. Bet you wish you stayed at the inn.\n"
-
This is for a fantasy type game. When the hero has been killed, the code keeps running until the ranger dies. How do I fix this up?
But later on I will be trying to create a function for turns at attacking.
2 1333
Please post the code with [code ] and [/ code] to keep indentation !
Hi Im currently building a script game, soon to be image game. Having trouble with a part of a code. - ranger_join = raw_input("\nWill you let him?(y/n)? ")
-
-
if ranger_join == "y":
-
print "The ranger joins you on your trip. Yay."
-
-
elif ranger_join == "n":
-
print "The ranger is offended and draws his sword.\n"
-
# attacking the ranger
-
weapon = raw_input("What weapon do you have? Oak Staff or Iron Sword? ")
-
#using the Oak Staff
-
if weapon == "oak staff":
-
attack = 3
-
print "\nYou draw your Oak Staff"
-
attack = 3
-
while ranger_health > 0:
-
ranger_health = ranger_health - attack
-
health = health - ranger_damage
-
-
print "You're hero takes a swing and the ranger has", ranger_health, " health remaining."\
-
"But you have", health, "hit points remaining\n"
-
if health <= 0:
-
print "You died. Bet you wish you stayed at the inn."
-
-
# using the Iron Sword
-
elif weapon == "iron sword":
-
print "\nYou draw your Iron Sword"
-
attack = 5
-
while ranger_health > 0 or health > 0:
-
ranger_health = ranger_health - attack
-
health = health - ranger_damage
-
-
print "You're hero takes a swing and the ranger has", ranger_health, " health remaining."\
-
"But you have", health, "hit points remaining\n"
-
if ranger_health <= 0:
-
print "It sucks"
-
exit
-
#gain an item for defeating ranger
-
-
elif health <= 0:
-
print "You died. Bet you wish you stayed at the inn.\n"
This is for a fantasy type game. When the hero has been killed, the code keeps running until the ranger dies. How do I fix this up?
But later on I will be trying to create a function for turns at attacking.
To exit the while loop, when your hero dies, use "break" - if health <= 0:
-
print "You died. Bet you wish you stayed at the inn."
-
break #used to immediately exit any for or while loop
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Steven D'Aprano |
last post by:
I've been working with the Borg design pattern from here:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531
and I'm having problems subclassing it.
I'm a newbie, so I've probably...
|
by: imranzafar |
last post by:
Hi! I am a beginner in C++. This is little assignment. It gives an
error "Structure Require on Left Side of dot operator" Can anybody help
me what went wrong in this code?
#include <conio.h>...
|
by: Marlene Stebbins |
last post by:
My hobby project is a library of routines in C that do big integer
arithmetic. I've been working on it for several weeks and it now
consists of about 1200 lines of code. I've got addition,...
|
by: luna |
last post by:
theres no errors in my code - but it does nothing at all - its supposed to
be populating text boxes!!
any ideas ? (im am pretty new to all this)
If Not Page.IsPostBack Then
Dim search As...
|
by: sam_cit |
last post by:
Hi,
I needed help in converting a character to the correspoding
hexadecimal values, like the following example,
ASCII value : ABC
Hex Code Value : %41%42%43...
whats the logic of conversion...
|
by: Buck Rogers |
last post by:
Hi all! Newbie here.
Below is an example from Teach Yourself C in 21 Days. My apologies
if it is a bit long.
What I don't understand is how the "get_data" function can call the...
|
by: Randy Volkart |
last post by:
I'm trying to fix a glitch in a complex access database, and have a
fairly complex problem... unless there's some obscure easy fix I don't
know being fairly new with Access. Basically, the area...
|
by: kya2 |
last post by:
I am not able to create following store procedure.
CREATE PROCEDURE DBSAMBA.InsertDeleteBatch(OUT norows INT )
RESULT SETS 1
LANGUAGE SQL
BEGIN part1
DECLARE TOTAL_LEFT INT DEFAULT 0;
...
|
by: Ravindra.B |
last post by:
I have declared a global variable which is array of pointers and
allocated memory for each array variable by using malloc. Some thing
similar to below...
static char *arr;
main()
{
int i;
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |