Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Python help needed (creating small game)

I've read "Learn Python the hard way" and I didn't like it AT ALL.
I don't think it's a good python introduction book.

I have a copy of the official python tutorial, and it's really great and simple.

You can check it online at http://docs.python.org/2/tutorial/
(Oct 29, 2013 07:54 PM)DevonRay Wrote:  Well here is the problem I have: I am creating a small game, and I want the user to be able to pick one of two sides at the beginning of the game. For example, If it was StarWars based, I will have my main script with the intro to the game, then allow the user to raw_input if they want to play the game on the good side, or the bad side. and based on their input i want a specific script to run that has their choice of the game on it. Sorry if this is confusing...

I wouldn't start a game at your level yet, until you understand what classes are and how to use them properly would probably be the first place to start...

but for what you asked:
Code
def good():
  print("you picked good team!")

def evil():
  print("you picked evil team!")

choice = '':
while choice not in ["1","2"]:
  choice = raw_input("pick a side\n1. good team\n2. evil team")
if choice == "1":
  good()
elif choice == "2":
  evil()
Learn Python The Hard Way is exactly what is sounds like. Hard. What I suggest to start out with is something like scratch, or stencyl. Now I know I'm gonna get some crazy replies saying "Don't tell him to use some sort of crap program like that" but I myself still use Scratch extensively. It helps me create an idea for a game, without going to the time and effort to actually coding the whole thing from start to finish. Its also a good way to learn programming command flow, and to learn how programming works in general.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 632 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[Python] by SkidyMar 29, 2018 06:54 AM 3 167 Mar 29, 2018 06:54 AM
Last Post: .kr.
[Python] by JuiceWaterJul 11, 2017 05:54 PM 2 114 Jul 11, 2017 05:54 PM
Last Post: JuiceWater