© 2023 All rights reserved - AR GANG
import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation
import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation Fruitydelicious animations (11.02.2023)
pip install numpy matplotlib 1. Bouncing Fruit This animation features a bouncing fruit (in this case, a simple circle representing an apple) across the screen. import numpy as np import matplotlib
# Fruits properties fruits = [ {'x': 2, 'y': 2, 'size': 1, 'color': 'r'}, # Apple {'x': 5, 'y': 5, 'size': 2, 'color': 'g'}, # Banana {'x': 8, 'y': 8, 'size': 3, 'color': 'b'}, # Cherry ] # Apple {'x': 5
# Bounce off edges if x < 0 or x > 10: vx *= -1 if y < 0 or y > 10: vy *= -1
# Movement variables vx, vy = 2, 2