Can someone help me figure out why my eyesy patch doesn't work the same as it does in pygame?

The title says it all pretty much. I was following along with Coding Train to make one of his visual p5 examples in python with the eyesy.
This is my eyesy patch: eyesy patch - Pastebin.com
This is my pygame file that works how I want: pygame file - Pastebin.com

The patches are nearly identical to each other so why could it be that my eyesy is only producing a few circles that don’t move and the other file works like a moving star field?

Im not very experienced with best practices so anyone feel free to jump in and correct me. You should not declare a class inside your setup(). I moved it out and also passed screen and etc as function parameters to the functions that needed them and it seems to be working in the ETC emulator. Havent tried it on hardware though.

import pygame
import random

width = 1280
height = 720
stars = []
center_x = width//2
center_y = height//2
radius = 10

class Star:
    def __init__(self):
        self.x = random.randint(-width,width)
        self.y = random.randint(-height,height)
        self.z = random.randint(center_y,width)
        self.pz = self.z

    def update(self):
        self.z -= 10
        if self.z < 1: # when our z is reduced too much instead of crashing we remake the points to be at random new spots, this also saves us from having to make a new star too
            self.x = random.randint(-width, width)
            self.y = random.randint(-height, height)
            self.z = random.randint(center_y, width)
            self.pz = self.z

    def show(self, screen, etc):
        sx = self.x / self.z * center_y + center_x
        sy = self.y / self.z * center_y + center_y
        pygame.draw.circle(screen, etc.color_picker(etc.knob4), (sx,sy), int(radius*5*etc.knob1))


def setup(screen, etc):
    for i in range(0,101):
        stars.append(Star()) # add 100 random stars to our list

def draw(screen, etc) :
    etc.color_picker_bg(etc.knob5)
    for star in stars:
        star.update()
        star.show(screen,etc)

That didn’t fix it unfortunately. I really have no idea why it wouldn’t be working

Ill try on hardware and see if I can get it working. its likely due to the fact that the eyesy runs python 2

Really? That’s a terrible idea by CG to have had that since when this came out Python 2 was basically obsolete

agreed. its been causing me a lot of issues. would be nice to get an update.

Any luck getting the patch to properly work?

Not really. The Dots just sit there in a grid.I’m going to try and rewrite it today to find what the issue is but I need to understand the algorithm a little more. I’m assuming youre working off the first coding challenge “Star Field” correct?

Yep! I found coding train through your original post haha. Really neat way to work on my coding skill. Hopefully you can get it to run!

I got it… and as suspected it’s a Python 2 issue. The problem was that in Python 2 the product of division between int / int = int whereas in Python 3 int/int = float this was messing up the division by your z factor.

To fix all I did was take my original reply and cast the z position to float in the show() function and then converted back to int for the draw circle function as that’s what it expects. Code included below.

import pygame
import random

width = 1280
height = 720
stars = []
center_x = width//2
center_y = height//2
radius = 10

class Star:
    def __init__(self):
        self.x = random.randint(-width,width)
        self.y = random.randint(-height,height)
        self.z = random.randint(center_y,width)
        self.pz = self.z

    def update(self):
        self.z -= 10
        if self.z < 1: # when our z is reduced too much instead of crashing we remake the points to be at random new spots, this also saves us from having to make a new star too
            self.x = random.randint(-width, width)
            self.y = random.randint(-height, height)
            self.z = random.randint(center_y, width)
            self.pz = self.z

    def show(self, screen, etc):
        sx = self.x / float(self.z) * center_y + center_x
        sy = self.y / float(self.z) * center_y + center_y
        pygame.draw.circle(screen, etc.color_picker(etc.knob4), (int(sx),int(sy)), int(radius*5*etc.knob1))


def setup(screen, etc):
    for i in range(0,101):
        stars.append(Star()) # add 100 random stars to our list

def draw(screen, etc) :
    etc.color_picker_bg(etc.knob5)
    for star in stars:
        star.update()
        star.show(screen,etc)```

Did it work for you?

Sorry just saw this kind of late, will try soon though!