r/pythonarcade • • Apr 06 '20
Showing images in an Arcade window
Hi folks
Based on a previous post where I was looking at porting my Pygame project to Arcade, I've got most of that done.
I've had issues with the world view mini map which is a semi-transparent overlay showing what an avatar has scanned and where they are on the game board - but in a basic representation.
I tried to make this a sprite - didn't work. Based on feedback on my post and direct chats I worked out that you can't dynamically update a sprite's image to a real time like feed. Looks like Pyglet complains. I managed to overwrite the sprite's texture about 5 times and then it died - so it looks like under the hood there's a texture buffering going on that I can't access.
So plan B - created a shape list and am drawing the map each on_update / on_draw call for the window - update builds the list - draw calls that draw() function for the list. This is working - but the FPS count for the window plummets from 60 to 30 because of this extra drawing.
Sprites are obviously much more efficient at drawing.
When I was dynamically replacing the texture for the sprite I was creating the map as a Pillow image and using this is a call to arcade.Texture() - like I said works then falls over because of a buffer overrun somewhere.
I was thinking that showing a single image instead of drawing shapes might be faster - but I can't find an arcade function that will place a PIL image onto the main window. Anyone know if this can be done?
I'll stick with the drawing shapes for now - but don't like inefficient code (very old gripe of mine during all my coding background - since 1980 and counting!)
Any help / pointers very much appreciated.
Screen shot of what I've done is shown below - pleased with ease of Arcade but coming against somethings that it can't do because I'm not building a platformer - and not sure I want to delve into using Pyglet raw just yet :)

Cheers
RC
View all comments
Show parent comment
2
u/[deleted] Apr 06 '20
Hiya
The drawing all the shapes is OK for now - not efficient - but OK. It’s the ‘toss it into a corner’ that I’m not sure how I can do - can’t see an arcade function that would allow me to display an image - assume it’s lower level which is something I might look on later - for now this works - slows things down but that’s OK for now - plenty of time for refactoring later! :)
If I get a chance then I’ll look behind the curtain - but I’ve still got some porting from Pygame to do - showing realtime position, heading data etc. On the right hand side of the window - again looks like lots of drawing when in Pygame it was a sprite with updated image to speed things up.
Looking forward to whatever else you can get into arcade - a way of updating the image for a texture and have it take note of the change would be useful because as I said I assume Pyglet or Arcade is buffering the image somewhere so any changing once displayed is ignored - I tried lots of spikes and none worked :)