There is this nice pygame example of a rotating cube:
I’d like to convert it into a mode, but I am a little bit lost in what to do where.
This is what I think what has to be done:
The Class Point3D should come in the first part of my mode (before def setup)
The Class Simulation has to be broken up.
The content of def run from line 37 to 57 (second part of the code) is what should be in def draw of my mode.
def init is not required until line 9. But the vertex list, the faces and the angles (lines 10 to 25 are required some how. But where???
I am not that familiar with the concept of this “self.”-variable. So I am a littel bit lost here.
Any help would be appreciated.
yeah, as you say this is pretty simple to do.
this is based around classes, and self represents the instance of this class,
which you can see is created at the bottom of the code.
this actually creates a simulation object, and then calls run on it…
(and because run() never ends, it doesnt get destroyed till pygame exits)
you have 2 choices…
there is nothing stopping you using classes yourself, so you could just hack the Simulation class, add a global instance of it in the mode, then call init() and run() from the mode.
(obviously only the simulation bits you have highlighted already)
just make the vertices/faces etc global, like other modes do with their data.
then as you say just initialise in init, and do the rendering in render.