I wrote a mode using CS Code and the Eyesy emulator. Everything works fine but when I load it on hardware and try to run it seems to not be able to load the necessary libraries. Specifically pygame.math.vector2
There are also some other oddities like when I used basic sys commands like type() are not running on the eyesy but do in the emulator on VS code.
The following code produces the subsequent print statement in the Eyesy console for example:
I cant even get a basic scritpo to test Vector2 object to run.
import pygame
import random
from pygame.locals import *
import pygame.gfxdraw
import math
testVector = pygame.Vector2(2,3)
def setup(screen, etc) :
pass
def draw(screen, etc) :
print(str(testVector))
This running on the Eyesy spits out
Mode ZHS - Boids not loaded, probably has errors.
Starting
error with setup: Traceback (most recent call last):
File "main.py", line 188, in
mode.setup(screen, etc)
File "/sdcard/Modes/Python/ZHS - Boids//main.py", line 12, in setup
def draw(screen, etc) :
AttributeError: 'module' object has no attribute 'Vector2'
error with draw: Traceback (most recent call last):
File "main.py", line 195, in
mode.draw(screen, etc)
File "/sdcard/Modes/Python/ZHS - Boids//main.py", line 18, in draw
NameError: global name 'testVector' is not defined
This same exact code running locally produces the expected output in the console.
PS E:\Eyesy\Scripts\Boids> eyesim --mode-folder "E:\Eyesy\Scripts\Boids"
pygame 2.1.2 (SDL 2.0.18, Python 3.6.7)
Hello from the pygame community. https://www.pygame.org/contribute.html
********************************************************************************
Press the spacebar to toggle widget visibility!
********************************************************************************
[2, 3]
[2, 3]
[2, 3]
[2, 3]
[2, 3]
It might be a version problem. I think the most recent EYESY OS is using Pygame v1.9.2 or 1.9.3 (although looking at the docs vector2 should be available in 1.9.3…so might be something else)
Ugh I dont want to have to write all the vector math methods… You think I could get that class from pygame and include it as a local import? Im trying to find out if I can just copy paste that into my code.
Looking into that possibility it seems like the better solution is to figure out how to get pygame.math.Vector2 working. Any help is more than appreciated. I promise to pay it back with cool modes…
Ive already got about 90% of my own vector class working. but it would be good to know what the issue is anyway. Basically just a few geometry and arithmetic features. Again though this is working locally but giving me issues on hardware
Ive attached the full file for anyone who wants to take a look. Now the issue is that operator functionality isnt working on hardware…
error with draw: Traceback (most recent call last):
File "main.py", line 195, in
mode.draw(screen, etc)
File "/sdcard/Modes/Python/ZHS - Boids//main.py", line 114, in draw
b.flock()
File "/sdcard/Modes/Python/ZHS - Boids//main.py", line 304, in flock
alignment = self.align(nearBoids)
File "/sdcard/Modes/Python/ZHS - Boids//main.py", line 355, in align
steering /= total
TypeError: unsupported operand type(s) for /=: 'instance' and 'int'
Got it working with my own vector class and swapping out itruediv for ifloordiv in the aritmetic functions. Now I just have to optimize. Lesson learned. Python 2 on the eyesy vs Python 3 in the emulator