Fruitydelicious Animations (11.02.2023) Instant

# Bounce off edges if x < 0 or x > 10: vx *= -1 if y < 0 or y > 10: vy *= -1

def animate(i): global vx, vy # Update fruit position x, y = fruit.get_data() x += vx y += vy Fruitydelicious animations (11.02.2023)

import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation # Bounce off edges if x &lt; 0

ani = animation.FuncAnimation(fig, animate, frames=100, interval=100) 0 or x &gt

# Movement variables vx, vy = 2, 2

fruit.set_data(x, y) return fruit,