May-14-2025, 01:09 PM
Hello! I am making a module similar to pygame, and I have a problem.
whenever I type in this:
Here's the module if you need it:
whenever I type in this:
blockage = display.Blockage(10, 10, 50, 50, 'red') blockage.frame()the variable blockage will not be projected on the screen
Here's the module if you need it:
import tkinter as tk from pygame import mouse window = None camera = None class GhostGame: class Mouse: @staticmethod def get_pos(): return mouse.get_pos() @staticmethod def get_pressed(): return mouse.get_pressed()[0] class Vector2Game: class Display: @staticmethod def get_window(size): global window window = tk.Tk() window.geometry(f'{size[0]}x{size[1]}') window.mainloop() return window class Camera: def __init__(self): self.position = [0, 0] camera = self class Blockage: blockages = [] def __init__(self, x, y, width, height, color): self.instance = tk.Frame(window, width=width, height=height, bg=color) self.position = [x, y] Vector2Game.Display.Blockage.blockages.append(self) def project(self): self.instance.place(x=self.position[0]-camera.position[0], y=self.position[1]-camera.position[1]) class GUI: gui = [] class UI: def __init__(self, x, y, width, height, color): self.instance = tk.Frame(window, width=width, height=height, bg=color) self.position = [x, y] Vector2Game.Display.GUI.gui.append(self) class Button: def __init__(self, x, y, width, height, color, function, text=None): self.instance = tk.Button(window, width=width, height=height, bg=color, text=text) self.position = [x, y] Vector2Game.Display.GUI.gui.append(self) class TextLabel: def __init__(self, x, y, color, text): self.instance = tk.Label(window, width=width, height=height, bg=color, text=text) self.position = [x, y] Vector2Game.Display.GUI.gui.append(self) class TextArea: def __init__(self, x, y, width, height, color): self.instance = tk.Area(window) self.position = [x, y] Vector2Game.Display.GUI.gui.append(self)