Pygrr - I've been stupid!
All this time, I've been doing it all wrong... Joking, it's not too bad! You know when I said you must call Object.pack() to update the canvas? I was wrong! Instead of Pygrr creating a new object, there are a few insanely useful Tkinter commands to help with this. These come in the form of:
canvas.scale()
canvas.move()
canvas.itemconfigure()
canvas.coords()
This may look like nonsense to you, but to Pygrr (which handles all this back-end stuff), it's so valuable! scale() allows me to, well, scale objects from a point by an amount and from a point (x+y), move() allows me to move things (this is what Pygrr currently uses), itemconfigure() allows me to configure settings (such as colour, outline width, and so much more!), and coords() allows me to change an polygon's coordinates - when used with some complex maths, I can rotate objects, or even change their model... Hallelujah!
I'll show you... Here's what now happens if you dynamically call the Object.set_model() when the object exists... No more pesky Object.pack(), it just works...
Here's the code:
import pygrr
pygrr.create_window()
player = pygrr.Object()
player.pack()
i = 0
while True: # this is the game loop!
player.set_model(pygrr.create_model.square(i))
pygrr.next_frame()
i += 1
The same can be said for colours, too! Let's make a rainbow circle!
In the next post, I'll add rotational functions, and scaling. Until then;
Isaac, over and out...