![]()
lien à conserver:
www.nuitducode.net/pyxel/studio/5624tdlr
|
Durant l'épreuve de la Nuit du Code, vous disposerez de 6 heures pour créer un jeu avec Python / Pyxel. Pour cela, vous pouvez utiliser les ressources (fichiers LES RÈGLES
QUELQUES CONSEILS
ndc.py
import pyxel
from math import cos, sin, dist
LOD = 2
LOD_OFFSET = 0
pyxel.init(256, 256, title="Shaders", fps=60)
pyxel.colors.from_list([0x000000, 0xdd4411, 0xbb1122, 0xaa0044, 0x990055, 0x880066, 0x770088])
pyxel.image(0).load(0, 0, "Stencil.png")
ox = pyxel.width // 2
oy = pyxel.height // 2
hcollen = (len(pyxel.colors.to_list()) - 1) / 2
def update():
pass
def rotate_coords(x, y, angle):
cos_t = cos(angle)
sin_t = sin(angle)
dx = x - ox
dy = y - oy
return dx * cos_t - dy * sin_t + ox, dx * sin_t + dy * cos_t + oy
def draw():
pyxel.cls(0)
global_angle = pyxel.noise(pyxel.frame_count/1024)/2.5
for y in range(43, pyxel.height - 43, LOD):
offset = round(pyxel.noise(y / 32, pyxel.frame_count / 128) * 4)
if LOD_OFFSET: offset = offset // LOD * LOD
for x in range(67, pyxel.width - 67, LOD):
px, py = rotate_coords(x, y, global_angle)
if pyxel.images[0].pget(px, py) == 0: continue
angle = ((abs(ox - x) + abs(oy - y)) + pyxel.frame_count / 4) / 6
rx, ry = rotate_coords(x, y, angle)
noise = pyxel.ceil(
pyxel.noise(rx / 64,
ry / 64,
pyxel.frame_count / 128)
* hcollen + hcollen)
pyxel.rect(x+offset, y, LOD, LOD, noise)
pyxel.run(update, draw)
Documentation
BIBLIOTHÈQUES
Si vous utilisez des bibliothèques tierces pour votre projet (c'est-à-dire de bibliothèques qui ne sont pas des bibliothèques standard de Python), indiquez-les ci-dessous (noms séparés par des virgules). Exemple: numpy,pandas Remarque: ne déclarer que des bibliothèques tierces, pas des bibliothèques standard de Python. Par exemple, random est une bibliothèque standard, pas une bibliothèque tierce. DOCUMENTATION PYXEL
|