EvilZone

Programming and Scripting => Projects and Discussion => : hanorotu August 20, 2012, 10:57:54 PM

: [Python]Text based game based on the movie "Saw"
: hanorotu August 20, 2012, 10:57:54 PM
I have learned a lot about python in the past 2 or three days. My whole weekend was nothing but studying and constantly practicing. So for my first python project I will be developing a text based game in which you have life points, different story lines (later on)

But yeah, should be fun. I will keep updated on the project here.
: Re: [Python]Text based game based on the movie "Saw"
: Ragehottie August 20, 2012, 11:22:25 PM
Cool. At one point I tried to make a tetris game in Python using only if/else statements...... it kinda worked..... I guess... Haha. Anyways, good luck. I will keep this post checked hardcore
: Re: [Python]Text based game based on the movie "Saw"
: hanorotu August 20, 2012, 11:24:23 PM
Awesome! I think this is going to be a lot of if/elses xD
: Re: [Python]Text based game based on the movie "Saw"
: Daemon August 21, 2012, 12:47:44 AM
Instead of if/else look.to use switches (c++ word for them. Idk the python term) then make a function for each room and use the switch to change rooms. I found this to be an easy way to make the code a little more bearable
: Re: [Python]Text based game based on the movie "Saw"
: Ragehottie August 21, 2012, 01:23:07 AM
Awesome! I think this is going to be a lot of if/elses xD


Bad Idea. js
: Re: [Python]Text based game based on the movie "Saw"
: lucid August 21, 2012, 02:09:28 AM
Instead of if/else look.to use switches (c++ word for them. Idk the python term) then make a function for each room and use the switch to change rooms. I found this to be an easy way to make the code a little more bearable

I second the fuck out of that. If/else statements are messy. You'll find switches are much more efficient and alot neater.

EDIT: @Daemon, I think it's probably still called switch statements. That term is used in Javascript I'm sure it's in most other languages too.
: Re: [Python]Text based game based on the movie "Saw"
: hanorotu August 21, 2012, 02:43:38 AM
Alright, I'm on it. Thanks for the help! I can use all of it I can get lol

Python's lack of a 'switch' statement has garnered much discussion and even a PEP. The most popular substitute uses dictionaries to map cases to functions, which requires lots of defs or lambdas.
: Re: [Python]Text based game based on the movie "Saw"
: hanorotu August 22, 2012, 12:43:44 AM
http://pastebin.com/x504jVFE

First very very rough draft of the first level. Don't ask me how to make another loop after this one for the second level cause I honestly don't know yet. I'll cross that bridge when I come to it lol
: Re: [Python]Text based game based on the movie "Saw"
: techb August 22, 2012, 02:02:37 AM
http://pastebin.com/x504jVFE (http://pastebin.com/x504jVFE)

First very very rough draft of the first level. Don't ask me how to make another loop after this one for the second level cause I honestly don't know yet. I'll cross that bridge when I come to it lol


Use separate classes for all elements. Player, items, rooms, etc. Then you could use one main game loop.
: Re: [Python]Text based game based on the movie "Saw"
: Kulverstukas August 22, 2012, 09:02:24 AM
Yes, like Techb said - use Classes. It's a MUST for this kind of project.
On a side note, maybe you could make it nice looking with some colored text, using Curses, or just Urwid (http://excess.org/urwid/) if Curses is too hard.
: Re: [Python]Text based game based on the movie "Saw"
: hanorotu August 22, 2012, 12:33:28 PM
Thanks all. Ill work on it