How can I extend a "normal" class with a static class in Python? -
i'm using python 3 , i'm trying rewrite graphics library wrote while ago. right now, have class called scene
has 3 methods in addition constructor: logic(self)
, update(self)
, , render(self)
.
logic(self)
handles logic of each scene
. handles mouse , keyboard input, , figures out whether button clicked, et cetera.
update(self)
can thought of abstract method. contents raise notimplementederror
. update(self)
called number of times each second, , updates whatever going on in program, but not draw on screen. framerate-independent update. if pong made library, ball's position updated in method.
render(self)
updates screen. way, speed of program not determined framerate.
i current implementation of scene
. it's clean right now, , seems intuitive. however, can't on how extend scene
. suppose want make scene
basic gui main menu. want there only one main menu scene
, because don't think it's idea recreate whole other scene
every time main menu viewed , used.
i started out extending scene
static class, realized it's not possible that. is current paradigm extend scene
with normal class, , recreate , destroy everytime subclass must used? example, should recreate , destroy hypothetical mainmenu(scene)
object when viewing , leaving it, respectively?
Comments
Post a Comment