Last active
March 14, 2023 22:07
-
-
Save catsocks/f61a69c1a7f38ee59074c44c417fd654 to your computer and use it in GitHub Desktop.
Animated drawing of the sea with the sun and clouds moving at the top and blue waves at the bottom. Made with the Pyxel retro game engine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Draw a really simple animated picture of the sun with moving clouds on the top and blue | |
waves on the bottom with the Pyxel retro game engine. | |
""" | |
import math | |
import time | |
import pyxel | |
WIDTH = 160 | |
HEIGHT = 120 | |
def update(): | |
pass | |
def draw(): | |
pyxel.cls(7) # clear the canvas with white | |
t = time.monotonic() | |
# Draw the clouds with little dots. | |
for y in range(HEIGHT // 10): | |
for x in range(WIDTH // 5): | |
s = math.sin((x * 0.1) + y + (t * 0.0125)) | |
if s > 0.5 and s < 0.7: | |
pyxel.pset(x * 6, y * 4, 12) # blue | |
# Draw the sun with one circle and use another for hiding any clouds that may | |
# appear too close to it. | |
pyxel.circ(WIDTH / 2, 20, 15, 7) # white | |
pyxel.circ(WIDTH / 2, 20, 10, 10) # paint the sun with yellow | |
# Draw the waves with tall narrow rectangles. | |
for x in range(WIDTH): | |
h = 20 | |
y = (HEIGHT - h) + math.sin((x * 0.1) + (t * 0.25)) * 3 | |
pyxel.rect(x, y, 1, h + (math.pi * 3), 12) # blue | |
if __name__ == "__main__": | |
pyxel.init(WIDTH, HEIGHT) | |
pyxel.run(update, draw) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sea.mp4