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 1346
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 missed something obvious.
I want two Borg-like classes where all instances share state within each
class, but not between them. This is what I tried:
|
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>
#include <stdio.h>
#include <iostream.h>
void set(void);
void display(void);
|
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, subraction and
multiplication working, but there is a problem with division. I think my
algorithm is OK; it's nothing fancy, just grade school long division. It
crashes with a seg fault on some inputs and produces the correct result
with others. Despite...
|
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 String
Dim strConn As String =
"server=Gringotts;uid=sa;pwd=password;database=database"
|
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
"continue_function", and if NO is returned to "get_data", display_report
executes and the program ends? Basically I am having trouble understanding
the program flow within the "if" loop in the "main" function.
|
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 I'm trying to
fix includes a form which takes entered data, concatenates it into a VB
string to form an SQL query, then launches a report with information
from the query. Several tables are linked in the query, but the key
ones for this problem...
|
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;
SELECT COUNT(*)INTO TOTAL_LEFT FROM DBSAMBA.REPORTEDTRANSACTION_S;
WHILE (TOTAL_LEFT > 0)
DO
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |