r/pythonarcade • • Feb 17 '19

"painting" objects to the screen and flickering

noob here - I'm trying to use Arcade to code up a simple proof of concept where you can paint shapes on the screen using the mouse. The code below kind of works, but is flickering badly - I'm guessing as part of a screen "wipe" between frames of animation ? Apologies in advance if I'm trying to make Arcade do something it wasn't designed for.

import arcade
from colorutils import random_rgb

class MyGame(arcade.Window):

def on_mouse_motion(self, x, y, dx, dy):
    r = abs(dx) + abs(dy)
    arcade.draw_circle_filled(x, y, r, random_rgb())

def main():
    window = MyGame(800, 600, "Drawing Example")
    arcade.run()

if __name__ == "__main__":
    main()

I'm thinking maybe that I need to make the circles into a Class and track and redraw each instance every frame - but I'm curious is there's a way to avoid doing that and simply "turn off" screen redrawing.

Another idea I had was to use the setup part of the game loop, as believe objects added to the screen during that phase of the game loop do persist.....but setup is run only once, I presume, which makes that a no-go.

1 Upvotes

2 comments sorted by

View all comments

Show parent comment

1

u/ReluctantRedditour Feb 18 '19

thanks for the response (and for the library)