These are chat archives for sam0s/sam0sRpg

15th
Oct 2015
Sam Tubb
@sam0s
Oct 15 2015 01:50
How can I make the gamestate change from a seperate file?
Sam Tubb
@sam0s
Oct 15 2015 01:59
I need to tell the game to change states from the menustate file.
Andrew
@djkool
Oct 15 2015 03:05
just need to import the state from the module
The one thing you need to worry about ‘circular dependencies'
Basically, you are trying to import a module that tries to import your module
One way to get around this is to do the import within the function that will be switching states
Andrew
@djkool
Oct 15 2015 03:12
but that is one of the reasons to intelligently separate modules
Sam Tubb
@sam0s
Oct 15 2015 10:27
I can't seem to make this work, I read up on circular imports, and in menustates.py, I import game.py, and in game.py I import menustates.py but I still can't use game.changeState(TestState) inside of menustate.py
Andrew
@djkool
Oct 15 2015 15:16
Sorry, that was my fault because I didn’t fully understand your question :(
The GameClass is responsible for switching gamestates.
Our custom GameClass is called RpgGame, but you should never have to import it.
Each GameState automatically has a reference to it as self.gc
Sam Tubb
@sam0s
Oct 15 2015 15:18
Oh
i had no idea
lol thanks
Andrew
@djkool
Oct 15 2015 15:20
so it would be self.gc.changeState(TestState)
Sam Tubb
@sam0s
Oct 15 2015 15:20
Got it. Thats pretty cool!
Andrew
@djkool
Oct 15 2015 15:21
Yea, that is why the GameClass has a lot of constants or what would be considered global variables in it.
Because it lets you access them in any gamestate with self.gc
Sam Tubb
@sam0s
Oct 15 2015 15:28
Im learning alot about game structure! I promise there wont be too many more questions ;)
Andrew
@djkool
Oct 15 2015 15:29
Nono, ask away! That is pretty much the whole point of this ;)
That and experimenting with designs.
Sam Tubb
@sam0s
Oct 15 2015 15:34
:shipit:
Andrew
@djkool
Oct 15 2015 16:09
If you find/read a cool way of implementing something, you should try it out.
Sam Tubb
@sam0s
Oct 15 2015 18:51
For sure m8
Sam Tubb
@sam0s
Oct 15 2015 22:29
I pushed it earlier, have you checked it out yet?