#🔒 Building with pygame

5 messages · Page 1 of 1 (latest)

trail tiger
#

I need help to know how can i struct my project, actually i have one class Screen (that operates atributes like width, height, title, icon, clock, fps, and methods like update_display and update,resolution), but i have ScreenContext too, that gives only the essensial informmation needed to build something, and UIManager (this contains methods to create UI like icons and bottons and methods to mananging it like event handle, update, draw, , because have on_screen_update_resolution too (this method allows rescaling of possible elements)... But I'm not sure if what I've done so far would be okay for a game, or if the design is flawed, since I feel that the rescaling part isn't independent of the module but depends on when the screen necessarily calls its update resolution method.. . .

languid sapphireBOT
#

@trail tiger

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

trail tiger
#

This is the current code I have for the UI manager: ```python
class UIManager:
def init(self, screen_context):
""" Gestiona TODOS los elementos de interfaz de usuario. """
self.context = screen_context

    # diferents types of UI Objects
    self.all_elements = []         
    self.rescalable_elements = []    
    self.clickable_elements = []     
    
    
    self.hovered_element = None
    self.pressed_element = None


# more code. . .


def on_screen_update_resolution(self,new_context):
    """Actualiza el tamaño de la pantalla"""
    self.context = new_context
    # Redimensionar elementos
    for element in self.rescalable_elements:
        if hasattr(element, 'set_context'):
            element.set_context(new_context)
        if hasattr(element, 'rescale'):
            element.rescale()
languid sapphireBOT
#

@trail tiger

Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.