r/pythonarcade • u/nantr0nic • Dec 31 '24
SpriteList drawing issue -- beginner question/issue(?)
Hello!
First time Reddit poster!
I've been studying Python for a few months and wrote a very basic Vampire Survivors type game in Pygame. After reading about Arcade, I decided it has some features that appeal to my goals for the game and I prefer how Arcade handles certain things (e.g. ways to set timers, delta_time stuff, physics stuff for later, etc.). I decided to try and re-write the game in Arcade before I get further with it but I'm running into an interesting and probably basic issue with drawing shapes.
I have a Player (Sprite) class with a draw() method that does "draw_circle_filled". In my main file I setup the sprite list under the Game class as suggested in the documentation. The problem is this: when under the on_draw() method for the Game class the sprite list is drawn, instead of a circle an error-type thing is rendered. When under the same method the sprite itself is drawn, the circle is drawn as expected.
I am running this on a Linux system with an Nvidia GTX 1070 on X11 so perhaps this is an Nvidia/OpenGL issue? I read the SpriteList class has "optimized code" which I assume means it utilizes the GPU concurrently with the CPU? Just a guess! (Still a beginner :) )
I am using arcade 3.0.0.dev32 and pyglet 2.1.dev5 on python 3.12.8
Thank you in advance for any guidance or suggestions! I appreciate you.
Here is my system information:
Garuda Linux (Arch) -- KDE Plasma 6.2.4 -- Kernel: 6.12.6-1-clear -- Nvidia GTX 1070 using Proprietary driver 565.77
Here are the screenshots showing the difference and below those I'll provide the code (The first is main.py, the second is player.py, the last is config.py).


main.py ( with self.player_list.draw() ):
import arcade
import config as c
from player import Player
class Game(arcade.Window):
def __init__(self, width, height, title):
super().__init__(width, height, title)
arcade.set_background_color(arcade.color.BLACK)
self.player_sprite = None
self.player_list = None
def setup(self):
"""Set up game variables. Call to restart game."""
self.player_list = arcade.SpriteList()
self.player_sprite = Player()
self.player_list.append(self.player_sprite)
def on_draw(self):
"""Render the screen."""
self.clear()
self.player_list.draw()
def on_update(self, delta_time):
"""All move logic and game logic goes here. Normally you'll call
update()on the sprite lists that need it."""
pass
def main():
game = Game(c.SCREEN_WIDTH, c.SCREEN_HEIGHT, c.SCREEN_TITLE)
game.setup()
arcade.run()
if __name__ == "__main__":
main()
player.py:
import arcade
import config as c
class Player(arcade.Sprite):
def __init__(self):
super().__init__()
self.center_x = c.SCREEN_WIDTH / 2
self.center_y = c.SCREEN_HEIGHT / 2
self.radius = c.player_size
self.color = c.player_color
def draw(self):
arcade.draw_circle_filled(self.center_x, self.center_y, self.radius, self.color)
config.py:
### Constant settings ###
# Possibly resizeable window, however:
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 720
SCREEN_TITLE = "Circle Cirvivors"
### Possibly dynamic settings ###
# Player #
player_size = 20
player_color = [140, 210, 205]
View all comments
Show parent comment
1
u/nantr0nic Dec 31 '24
Your comment helped me realize I should try drawing the SpriteList() using a png image and it was successful! This ruled out there being an issue with my python/nvidia/linux setup.
I tried using arcade.draw_circle_filled() under the Player class init (without a draw() method) and it is the same result. In Pygame I was able to create a circle surface and treat it as a sprite in order to detect collisions and so on; however, looking through the Arcade documentation I'm seeing there is "arcade.SpriteCircle" which might be what I'm looking for. Thank you for reminding me of the age old suggestion to check the documentation more carefully 😅 Here is (so far) what has worked:
player.py:
I am, however, curious if there is a correct way to use draw_circle_filled() and treat it as a sprite rather than using arcade.SpriteCircle() -- if only to better understand how Arcade works.
Also, a bit unrelated: even though the documentation says the "color" attribute has the same requirements for draw_circle_filled() and SpriteCircle(), it seems using a list for SpriteCircle() produces a TypeError: "unhashable type: 'list'".
Thank you for your help!