# Help need to convert a standalon pygame program into a ETC mode

**URL:** <https://forum.critterandguitari.com/t/help-need-to-convert-a-standalon-pygame-program-into-a-etc-mode/4421>\
**Category:** ETC\
**Created:** [June 9, 2019, 9:14pm UTC](https://forum.critterandguitari.com/t/help-need-to-convert-a-standalon-pygame-program-into-a-etc-mode/4421 "2019-06-09T21:14:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fanwander](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.critterandguitari.com/fanwander/32/5076_2.png) [@fanwander](https://forum.critterandguitari.com/u/fanwander)\
**Post date:** [June 9, 2019, 9:14pm UTC](https://forum.critterandguitari.com/t/help-need-to-convert-a-standalon-pygame-program-into-a-etc-mode/4421/1 "2019-06-09T21:14:11Z")

</div>

Hello,

There is this nice pygame example of a rotating cube:

> **[Rotating 3D Wireframe Cube with Python](http://codentronix.com/2011/04/21/rotating-3d-wireframe-cube-with-python/)**
>
> In the last tutorial we saw how to make a simple 3D simulation. In this tutorial we will build from the theory and code from the last tutorial and make a rotating 3D wireframe cube. Read more »

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. 🙂

---

<div class="post-metadata">

**Author:** ![thetechnobear](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.critterandguitari.com/thetechnobear/32/42_2.png) [@thetechnobear](https://forum.critterandguitari.com/u/thetechnobear)\
**Post date:** [June 11, 2019, 6:40pm UTC](https://forum.critterandguitari.com/t/help-need-to-convert-a-standalon-pygame-program-into-a-etc-mode/4421/2 "2019-06-11T18:40:33Z")

</div>

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.

```auto
Simulation().run()
```

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…

first option:  
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)

second option:  
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.
