Re: Keeping track of state without globals?

2021-01-06 Thread AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector
Re: Keeping track of state without globals? Gotcha, yeah I think I will go with this approach. URL: https://forum.audiogames.net/post/604798/#p604798 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman

Re: Keeping track of state without globals?

2021-01-06 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
Re: Keeping track of state without globals? your code looks quite clean. for keeping track of state between iterations of the main loop, I think just setting up state inside main() before the main loop starts should be fine. then you can update the state inside the main loop

Re: Keeping track of state without globals?

2021-01-06 Thread AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector
Re: Keeping track of state without globals? Dude it wasn't me, it was Black, and it's set to autoformat every time I save... lol. URL: https://forum.audiogames.net/post/604765/#p604765 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https

Re: Keeping track of state without globals?

2021-01-06 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
Re: Keeping track of state without globals? @19I tell you what, that is some nicely laid out code!! We always moan when code is badly formatted, or not formatted at all, but that is lovely to read. Well done. URL: https://forum.audiogames.net/post/604759/#p604759 -- Audiogames

Re: Keeping track of state without globals?

2021-01-06 Thread AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector
Re: Keeping track of state without globals? 3import logging import sys import os os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide" import pygame import XInput as xin from cytolk import tolk from pygame.locals import * logging.basicConfig( filename="contro

Re: Keeping track of state without globals?

2021-01-06 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
Re: Keeping track of state without globals? @17 it is starting to seem to me that the issue you are running into is more a matter of having your state be in scope in the function that handles the event loop and to update it between iterations of the loop. I cant access your code

Re: Keeping track of state without globals?

2021-01-06 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
Re: Keeping track of state without globals? @13 I am not sure if that actually improves the situation over using global variables, since all you are doing is wrapping then in a class definition, so it is still global state, albeit wrapped in a class. as a general rule, it isn't a great

Re: Keeping track of state without globals?

2021-01-05 Thread AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector
Re: Keeping track of state without globals? Yeah it's not a huge thing. I did start working on a class for the announce state. I decided to do it properly because I can pass in the controller index into the constructor so it will handle multiple controllers. But then I have to figure out

Re: Keeping track of state without globals?

2021-01-05 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
Re: Keeping track of state without globals? If your program is too small to deserve not using globals, if you are going to finish this then never touch it again, then just use globals.  Doing class-level variables that get changed by classmethods doesn't help you because they're globals

Re: Keeping track of state without globals?

2021-01-05 Thread AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector
Re: Keeping track of state without globals? I should be able to handle multiple controllers as things stand right now, because each one gets its own index which I pass to functions that will use it.I just don't see the point in all that. It seems silly to me to go through all that just

Re: Keeping track of state without globals?

2021-01-05 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
Re: Keeping track of state without globals? @13That feels like extra typing, and you don't get much that using a module doesn't already give you.Why not instantiate the classes somewhere? A nice little application.py module should do it, then you can keep all your instantiated whatnots

Re: Keeping track of state without globals?

2021-01-05 Thread AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector
Re: Keeping track of state without globals? I think what I'll end up doing is making classes that you call directly without having to create objects for them. That's what seems to make the most sense in this particular case.So by me putting the variables right under class rather than

Re: Keeping track of state without globals?

2021-01-05 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
Re: Keeping track of state without globals? @10 although I do often advocate functional programming, this instance I am not actually advocating FP. the alternative solution I am proposing is just regular procedural imperativ programming.and I think in this case I am considering

Re: Keeping track of state without globals?

2021-01-05 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
Re: Keeping track of state without globals? @10OK, thanks. URL: https://forum.audiogames.net/post/604432/#p604432 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Keeping track of state without globals?

2021-01-05 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
Re: Keeping track of state without globals? @8I entirely fail to see how what you are proposing is helpful for a new programmer.  There is a reason people don't start with functional programming.  You tend to provide entirely correct answers without considering your audience, which

Re: Keeping track of state without globals?

2021-01-05 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
Re: Keeping track of state without globals? @5Oh wow, I'm screwed then. I make all my classes with the attrs package haha.I love having the vision to create great things, but not the brains to make them truly awesome.Thanks for the heads-up though, I'll look into it. URL: https

Re: Keeping track of state without globals?

2021-01-05 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
Re: Keeping track of state without globals? global mutable state sure is something you want to avoid, since it can be accessed anywhere, making it difficult to reason about. one way to limit the scope definitely is what has been proposed, to use a class and make the mutable state a field

Re: Keeping track of state without globals?

2021-01-05 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
Re: Keeping track of state without globals? global mutable state sure is something you want to avoid, since it can be accessed anywhere, making it difficult to reason about. one way to limit the scope definitely is what has been proposed, to use a class and make the mutable state a field

Re: Keeping track of state without globals?

2021-01-05 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
Re: Keeping track of state without globals? global mutable state sure is something you want to avoid, since it can be accessed anywhere, making it difficult to reason about. one way to limit the scope definitely is what has been proposed, to use a class and make the mutable state a field

Re: Keeping track of state without globals?

2021-01-04 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
Re: Keeping track of state without globals? Nah.  Synthizer is like 6000 or 7000 lines at this point and counting.  It's still under 50 classes despite using classes for lots of things.  Some free functions do algorithmic heavy lifting, but nonetheless.  Whoever taught you that classes

Re: Keeping track of state without globals?

2021-01-04 Thread AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector
Re: Keeping track of state without globals? I'm not saying I'm not gonna do it, In fact, I will. I am just grumbling about it because I hate classes. The second you start using them, then everything becomes a class and you've got objects all over the place because you need one

Re: Keeping track of state without globals?

2021-01-04 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
Re: Keeping track of state without globals? Classes aren't OOP unless you want them to be.  Sure, you can go do a bunch of stuff with inheritance and have your nice 6-level hierarchy and UML diagram if you want, but let's not.The best way to think of classes is as a sort of bag where you

Re: Keeping track of state without globals?

2021-01-04 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
Re: Keeping track of state without globals? Also, a trick I've used when dealing with GPS coordinates, save a spoken position. Initialise it to None:class StickClass: spoken_option: Optional[float] = None def stick_thing(self, position: float) -> N

Re: Keeping track of state without globals?

2021-01-04 Thread AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector
Re: Keeping track of state without globals? I was trying to avoid all that. I hate OOP constructs. It always just seems so over-engineered for the problem at hand. I guess I will have to at some point though.I can't really use constants here because each variable or element in a tuple

Re: Keeping track of state without globals?

2021-01-04 Thread AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector
Re: Keeping track of state without globals? I was trying to avoid all that. I hate OOP constructs. It always just seems so over-engineered for the problem at hand. URL: https://forum.audiogames.net/post/604259/#p604259 -- Audiogames-reflector mailing list Audiogames-reflector

Re: Keeping track of state without globals?

2021-01-04 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
Re: Keeping track of state without globals? Don't have time to review the code but the answer to this sort of problem is almost always "make a class, then put the variables on the class".  When it gets big enough, figure out how to separate it into separate classes with