Timeline for Movement in a text-based game using room class (Python)
Current License: CC BY-SA 3.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 11, 2017 at 13:26 | vote | accept | Schrodinger'sStat | ||
Jul 11, 2017 at 13:26 | vote | accept | Schrodinger'sStat | ||
Jul 11, 2017 at 13:26 | |||||
Jul 11, 2017 at 13:18 | vote | accept | Schrodinger'sStat | ||
Jul 11, 2017 at 13:26 | |||||
Jul 7, 2017 at 21:55 | answer | added | abathur | timeline score: 0 | |
Jul 7, 2017 at 20:06 | answer | added | Jimmy | timeline score: 0 | |
Jul 7, 2017 at 19:25 | comment | added | Jimmy |
There's a number of issues that suggest you should brush up on your Python. player should be an instance of a class Player , position should be a link to a room, rooms should either link directly to each other or else you need a global registry of room name string to Room instance, etc.
|
|
Jul 7, 2017 at 19:21 | comment | added | Schrodinger'sStat | I'm currently trying out this method you suggested and I'm trying to get movement working with this player.position = cottage command = input(">>> ") def movement(): if player.position == Room(introd) and command == 'N': set(player.position) = Room(clearing) However I'm getting an error telling me that I have invalid syntax (in sublime text it says "[E] Can't assign to function call") I guess I can't use set() on player.position? | |
Jul 7, 2017 at 18:57 | comment | added | Schrodinger'sStat | Thanks! How would I change the assigned room in player.position as the player moves around though? | |
Jul 7, 2017 at 18:49 | comment | added | Demandooda |
Instead of the player class knowing its Room via a number, the position variable could just store the Room itself. E.g, if the player is in the cottage, then you might say player.position = cottage . Then, you can use the actions by doing say, player.position.actions . This way, it would be overall simpler, and you can get rid of the position variable in the Room class as well. Win-win!
|
|
Jul 7, 2017 at 16:35 | history | edited | Schrodinger'sStat | CC BY-SA 3.0 |
added 74 characters in body
|
Jul 7, 2017 at 16:30 | review | First posts | |||
Jul 7, 2017 at 18:45 | |||||
Jul 7, 2017 at 16:29 | history | asked | Schrodinger'sStat | CC BY-SA 3.0 |