Look at the change from level 1 to two. Then look at the change from two to three. Why is it different? I want them to both be like the change from level 1 to level 2. Any suggestions?
To answer you're question, it's because if you were using functions, you would put the first function calling at the very end of every Single function. Since all the functions, would run. But for the second to third, you just call it on each other, like this:
def first_func():
# code
second_func() # calling second function here
def second_func():
# code
third_func() # calling third one here. and so on
def third_func():
# code
first_func() # calling
That's the reason
@RYANTADIPARTHI so, could you change this to make it specifically to my code?
@ColePete can't, because you are using while
loops, but you can do levels with functions.
@RYANTADIPARTHI So how do I fix while keeping a similar code.
@ColePete well, on top of your code, break into functions. Just add def func()
and indent the code.
@RYANTADIPARTHI I don't know how.
@ColePete ok, like this:
def first_func():
while game_running == True:
new_round = True
player = {"attack": 10, "heal": 16, "health": 100}
monster = {"attack": 12, "health": 100}
weapon = {"close range": "Sword", "long range": "Bow and Arrow"}
clear(.1)
random_name = random.randint( 0, 4)
monster_name1 = monster_names[random_name]
del monster_names2[random_name]
random_name = random.randint( 0, 3)
monster_name2 = monster_names2[random_name]
del boss_names[random_name]
random_name = random.randint( 0, 2)
boss_name = boss_names[random_name]
print("---" * 7)
print("Enter PLAYER Name")
player_name = input()
clear()
while select_weapon == True:
clear(1)
print("---" * 7)
print("Please Select Weapon")
print("1) Sword")
print("2) Bow and Arrow")
player_weapon = input()
if player_weapon == "1":
print("---" * 7)
print("You have chosen a sword as your weapon")
player = {"attack": 14, "heal": 12, "health": 100}
monster = {"attack" : 16, "health" : 100, "name" : random_name}
select_weapon = False
elif player_weapon == "2":
print("---" * 7)
print("You have chosen a bow and arrow as your weapon")
player = {"attack": 8, "heal": 20, "health": 100}
monster = {"attack" : 16, "health" : 100, "name" : random_name}
select_weapon = False
else:
print("***" * 7)
print("ERR: Invalid Input")
print("***" * 7)
clear(1.5)
first_func() # calling
Like i did above, do the same for others.
@RYANTADIPARTHI is there anything that I delete?
@RYANTADIPARTHI so I just add that instead of my first while loop?
@ColePete if you want to you can keep your look
@RYANTADIPARTHI can you just fork it and then show me the forked code with your edits?
@ColePete you just have to put that function like i said, and call it at the end.
@RYANTADIPARTHI But where do I put it? inside the first while loop at the top, or delete the first while loop and put that there in its place????????
@ColePete try both, and see which one works
@ColePete ok, i would suggest not deleting anything, and putting it first.
@RYANTADIPARTHI whenever I put the code in I get on error under "while select weapon == True"
@MocaCDeveloper @whippingdot I feel bad always asking ya'll for help, but, I am stuck.
I am thinking. Maybe the indents are wrong? @ColePete
@Whippingdot well, if the indents were wrong, I would get a red squiggly line under where the indent is messed up.
I am forking the repl and making it simpler. I will then paste the code here. You can find the difference by looking at the history of the repl after pasting the changed code I give you here. @ColePete
@Whippingdot thx, feel free to fix any other problems. (But please tell me what you did, so that i can know and learn from it)
Got to go see ya!
@Whippingdot how is the fork coming along? The other guy didn't fix the problem.
Yeah, it is coming along. It takes time, sry. I will try to solve the main problem today. You have 500 lines of code. Yesterday I finished about 120 @ColePete
@Whippingdot Lol all good sry to bother u.
Work on a different project, you can work on many at the same time. @ColePete
I am doing yours, and 3 more. @ColePete
@Whippingdot, I know that I can, I just don't know what to do.
Done
I finished @ColePete. I did a lot of indenting changes.
Print
Also, at the start you kept on using print one after another, instead of doing that, you can just use one print statement and whenever you want it to print a new line, type \n in the double quotes.
Input
Also, when inputing something you can type stuff in double quotes inside the input statement and that will print before asking you the input. You don't need a print statement before the input statement. Also, you can put the input statement inside int() so it changes the answer to an integer. Then you don't need to check if the number is "1", only if it is 1.
THE CODE
@ColePete
@Whippingdot WOW thanks for all the tips. I am still a noob at this coding thing. (I will deny ever saying this) So thanks for all the tips and help that you have provided me!
If you put this on the share section, @ mention my name cause I helped you soo much. Also mark me as the answer. The boss is not fully complete I think, but I also helped on it. finish the boss section and then share it. @ColePete
@Whippingdot will do! also, if you check the FAQ page in the read me, you will see that I already mentioned you there.
@Whippingdot, also, how do I make it show the counter at the end?
Just print the counter.
@ColePete
ok thanks
@Whippingdot
EDIT: whenever i put that code, i get the red line under it
I don't what the error is. Try to do it yourself. I have helped you so much. @ColePete
@Whippingdot I think i found out what was wrong, i am testing it right now. I am sorry that i made you go through all this trouble for a video game.
Naa, I like helping you. Just was stressed that I was not helping you quick enough. Thanks. @ mention me when you have another doubt. Have a good day/night. Bye! @ColePete
@Whippingdot bruh, you fixed the code faster than I ever could have. not fast enough? psh whatever. Thanks again!