Skip to content

Instantly share code, notes, and snippets.

@loleg
Created February 17, 2025 08:53
Show Gist options
  • Save loleg/4a29a91fd08c83a88359062711433f87 to your computer and use it in GitHub Desktop.
Save loleg/4a29a91fd08c83a88359062711433f87 to your computer and use it in GitHub Desktop.
"Ye Nan Pu" - a tiny animation in TIC-80
# title: Ye Nan Pu
# author: seism
# desc: a midnight heart-hack-ttack made at MountainBytes 2025
# site: https://mountainbytes.ch
# license: WTFPL License
# version: 0.1
# script: python
from math import sin
from random import random, seed
t=0
x=96
y=24
width = 50
def TIC():
global t
global x
global y
seed(time()//100)
day = True
if sin(t/100) < 0.5:
cls(10)
else:
cls(8)
day = False
# background
#rect(0, 60, 240, 20, 8)
rect(0, 80, 240, 60, 8)
# sunny skies
sunx = 10 + int(t/10)
suny = 10 + int(sin(t/100)*30)
if day:
circ(sunx, suny, 7, 4)
circb(sunx, suny, 7, 3)
circb(sunx, suny, 8, 11)
else:
#clip(sunx, suny-10, 10, 20)
circ(sunx, suny, 7, 13)
#clip(0, 0, 240, 200)
print("MOUNTAINBYTES DEMOLAB 2025",40,1,11)
for zz in range(0, 20):
z = zz * 8
for st in range(0, 30):
mr = int(sin(st) * 10) + 30
s = -25*width + int(t / 2) + (st * width)
val = 50+int((random()-0.5)*zz*7*sin(t/400))
if s<-100 or s>400:
continue
# draw some things
if zz == 0 and st%6 == 0:
flx = s + int(width/4)
fly = z + mr + 5
# flagpole
line(flx, fly, flx, fly + 20, 14)
# flag
rect(flx, fly, 12, 10, 2)
# cross
rect(flx+5, fly+2, 2, 6, 12)
rect(flx+3, fly+4, 6, 2, 12)
# shading
for my in range(0, 10):
line(
s,
z + mr + my,
s + width/2,
val + z + mr + my,
1
)
line(
s + width/2,
val + z + mr + my,
s + width,
z + mr + my,
7
)
# draw some shaky mountains
line(
s,
z + mr,
s + width/2,
val + z + mr,
15
)
line(
s + width/2,
val + z + mr,
s + width,
z + mr,
11
)
line(
s + width/2,
val + z + mr,
s + width,
10 + z + mr,
0
)
# bounce bounce
#snowfall = int(sin(t/100)*4)
#rect(0, 60 - snowfall, 240, 2, 12)
for cl in range(0, 40):
clx = (cl * 14) - 20
cly = int(sin(cl*t/100)*10)
circ(clx, 110-cly, 2 + int(10-sin(t/100)*2), 13)
circ(clx, 95+cly, 2 + int(10+sin(t/100)*4), 12)
#print("t:"+str(t),74,24)
t+=1
if t>2450:
t=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment