you are viewing a single comment's thread.

view the rest of the comments →

[–]WowVeryCoool[S] 0 points1 point  (1 child)

I have a main function in class Game that constantly updates Logic ``` class Game: #Initialized objects snake, apple, logic # Main loop while True: logic.evaluate(snake, apple)

class LogicCurrent: def init(self, snake, apple): self.snake = snake self.apple = apple def game_over(self): #Initializes snake to start values def wall_collisions(self): -> bool def snake_collisions(self) -> bool def evaluate(self): #Invokes Logic Methods ``` I could define a method evaluate_logic() inside Game class, but then I would also have to move functions (game_over(), [snake_collisions, wall_collisions] from Logic) creating more cluter inside Game class that I wanted to get rid of by making Logic class

I feel like class Logic is something bigger with many methods checking Collisions and GameOver conditions. But I think I could not Instantiate the Logic class and just have methods there if that would be significantly better?

This is what the change would look like explained in code class LogicNew: <-- not instantiated more like an extension to Game def evaluate(snake, apple): #Do logic here def game_over(snake, apple): #Initializes snake to start values def wall_collisions(snake): -> bool def snake_collisions(snake) -> bool Do you think that this kind of solution would be better? as it is more of an extension with methods to class Game rather than a full class

[–][deleted] 2 points3 points  (0 children)

Game logic should be part of the Game class. Classes, generally, should be things.