celeste_levels.py

Created by mathieu-croslacoste

Created on January 03, 2025

9.31 KB

Adaptation du script “celeste” par loic-azavant (https://my.numworks.com/python/loic-azavant/celeste#:~:text=Cr%C3%A9%C3%A9%20par-,loic%2Dazavant,-Cr%C3%A9%C3%A9%20le%2012)

À utiliser avec “celeste.py” (https://my.numworks.com/python/mathieu-croslacoste/celeste)


from kandinsky import draw_string as D,fill_rect as F
from time import sleep as S,monotonic as M
from ion import keydown as K
import micropython as mp
mp.kbd_intr(52)
LEVELS=[((r"________________________________________________________________________________________________________________________________________ab_____________________gh_________abc_________gh_________ghi___abc___gh_________ghi___dhi___gh_________ghf____gi___gh__`______gi_____gi___ghbbbbc__abhi_____gi___gh",(13,23),2),
(r"_________r___________________r___________________r___________________r___________________r___________`_______r___ac__abbbbc______r___gi__ghhhhi______r___gi__dhhhhi______r___gf___ghhhhc_____r___o____ghhhhi_________o____ghhhhi_________o____ghhhhhbbbbbbbbbi____gh",(13,20),2),
(r"_______________________________________________________________________abc_______`_________ghi______bc_________ghf______hi_________gi_______hhc________df_____abhhi_______________ghhhhbbc____________ghhhhhhi_______ac___ghhhhhhi_____abhi___ghhhhhhi___abhhhi___gh",(13,20),2),
(r"________________________________________________________________________________________________________________________________________________________________________________`_________________________________bbc________________________________hhi________________________________hhirrrrrrrrrrrrrrrrrrr__________jbbhhhc______r_______r______________dhhhhi______r_______r_______________ghhhi______r_______r_______________ghhhi______r_______r_______________g",(13,35),2)),
((r"heeeeeeehhhhheef___gi_r__r__ghhef______gi_r__r__ghf________gi_rrrr__df_________gi________________jbhi_________________dhi__________________gi__________ac______gi__________gi______gi__________gis_____gi______ac__ghc_____gi_`____gissghi_____ghbbc___ghbbhhi_____g",(13,20),1),
(r"eeeeeeeehhhhhhhi___gr__r____ghhehhhi___grrrr_w__ghf_dehi___gr__r____gi____di___grrrr____di_____o___gc________n_____n___gi__________________gi__________________gi_______sss________gi_______abc______abhi_______dhi__sabbhhhi_`__q___gissahhhhhhhbbbbc___ghbbhhhhhhh",(13,20),1),
(r"hhhheeeeeeeehhhhhheeeeef___ghhhef________deeeef_________ghhf_________________________ghi__________________________ghi___ac_______________abc___ghi___df_______________ghf___dhi____r___rm__________di_____gi____r___rgc__________n__w__gi________rgi______ss________gi________rdi______acssss___sgi__________n___sssghbbbcssabhi_`____________abbhhhhhhbbhhhhbbc___________ghhhhhhhhhhhhh",(13,29),1),
(r"hhhhheeeeeeehi___ghhhhheehhhhhheef_______gi___dehhhf__dhhhhf__________di____vghi____dhhi____________o____vghf_____dhi___abc______o____vgi___w___gi___dei______n_____gf_______gi___vrn____________n________gf___vr______________________gt___vr__rr__________________gt___vr______________p_______gt___________________________gc_`_________________________ghbbc________________________g",(13,29),1),
(r"heef___deeeeeeeeeeehi__________________gi__________________gi_____ac___rr______gi___abhi___________gi___dhhi_______rr__gi____dhi___________gi_____di___________gi______n___rr______gi__________________gi_____________rr___gi_`________________ghbbbbbbbc__________g",(13,20),1),
(r"heeeeeeeehhhhhhi___gi________dehhhhi___gi_w________dhhhi___gi___________dhhf___ghbl_sss______git___ghf__abl______git___gi___gi_______dit___gi___df________ot___gi_____________dl___gi________________q_gi________________jkhi__________________gisss_________m_____ghbbcss___sssso_____gheeekl___jkkbf_____gf___________o______gp___________o______gp___________o______gp_`__acqmssso______gbbbbbhhbhbbbi______g",(20,20),1),
(r"heeeeeeeeehhhhheeeehi_________dehhit___gi___________dhit___gi____m_______git___gi____o_______dit___gi____o________ot___gis___o_q______ot___ghc__sgbbbbc___ot___ghis_ahhhhhi___ot___ghhc_ghhhhhi___dl___ghhi_dhhhhhi________ghhi__deeehhc_______ghhf______dehc______ghf_________di______gi___________gc_____gisssss______ghbc_`_ghbbbbbbbc___ghhhbbbh",(17,20),3),
(r"heeeeeeeeehhheef___gi_________ghf______gi_________gi_______gi_`___jbbbef_______ghbkl__vghf_________ghi____vgi_____jbbbbhhi____vgf______ghhhhhisss_vn_______dhhhhhhbbc___________dhhhhhhhi_____r______dehhhhhi_____r________ghhhhf______________ghhhi_______________g",(13,20),1),
(r"i___n_______________dhhhhi____________________dehhi_______ss_____________dhi_______ac______________ghbbbc___df______________ghhhhi________s_____ss___ghhhhf________ac____acs__ghhhf_________df____del__ghhi________________uuu__ghhf_____________________ghi______________________ghissss____sssssmqm____`_ghhbbbcssssabbbbhbhbcqabbh",(13,25),1),
(r"________________________________________________________________________________________________________________________________________________________________________________________________________c___ac_____________ahc_ahhbc____abc___ahhhbhhhhhc_`_ghhbbbhh",(13,20),1)),
((r"hhheeeeeeeeeeeef___ghhf_______uuu______ghf_________________gi__________s_______gi___rrrrrrrjkkbbbbbhi__rabbkl_____deehhhi__ahhf__________dhhi__dhi_____s______dhf___gf_____ms______gt___o_____sgc______gc___n_____ahi______gi________sghi_q__`_gi________ahhhbbbbbbh",(13,20),1),
(r"eeeefrdeeefrdeef___g_____r____vr_______grrrrrr____vr_______g_____r____vr_______grrrrrr____vr_______g_____r_____r____jbbhrrrrrr_s___r_____dhhc____r_ms__r_s____ghi______gc____m____dhi______gi____o_____gi______gi____o_____gi_`____gi____o_____ghbbcsssgissssosssssg",(13,20),1),
(r"hhhhhhhf_____________dhhhhhhhhhf_______________ghhhhhhhi________________dhhhhhhhf_________________ghhhhhi__________________ghhhhhi_____________s____dhhhhhf_______r_____m_____ghhhi________r_____os____ghhhi________rss___dc____ghhhis_______uur___uo____dhhhhc_________r____o_____hheeis________r____o_____hf__dc__s__________dc____i____n__r___________gbbbbi_______r___________dhhhhi_`__________________ghhhhbbbbbc______________ghhh",(17,25),2),
(r"________________________________________________________________________________________________________________________________________________________________________________________________________c___ac_____________ahc_ahhbc____abc___ahhhbhhhhhc_`_ghhbbbhh",(13,20),1)),
((r"hheeeeeeeeeeeeei___ghf_____________o___gi______________n___gi____ss____________gi___sac___ssms____sgi___jhissabbhcssssahiq___dfuudeehfkkkkghhl___vt_____o_____ghit___vt_____o_____dhit___vt__s__os_s___git___vt__m__dl_m___ghc______qo_____gc`_ghi___abbbi_____ghbbh",(13,20),1),
(r"hheeeeeeeeeeeeef___ghf_________________gi__________________gi____s______ss_ssssghkkl_ms_ssssakkkkbbhiuuu_dkkbbbkf____dehi______vgef________gi______vo__________gi__ssssaf______s___gi__jkkkf____s__m_`_gi___________m__gbbbhi___________o__ghhhhhcssssssssssgbbhhhhh",(13,20),1),
(r"________________________________________________________________________________________________________________________________________________________________________________________________________c___ac_____________ahc_ahhbc____abc___ahhhbhhhhhc_`_ghhbbbhh",(13,20),1))]
def load_level(n):
 try:return LEVELS[n]
 except IndexError:return 0
def draw_image(rle,x0,y0,w,pal,zoomx,zoomy,itransp=-1):
 i,x=0,0;x0,y0=int(x0),int(y0);nvals=len(pal)-1;nbits=0
 while nvals:nvals>>=1;nbits+=1
 maskval=(1<<nbits)-1;maskcnt=(0xFF>>nbits>>1)<<nbits
 while i<len(rle):
  v=rle[i];mv=v&maskval;c=(v&maskcnt)>>nbits
  if v&0b10000000 or nbits==8:i+=1;c|=rle[i]<<(7-nbits+(nbits==8))
  c+=1
  while c:
   cw=min(c,w-x)
   if mv!=itransp:F(x0+x*zoomx,y0,cw*zoomx,zoomy,pal[mv])
   c-=cw;x=(x+cw)%w;y0+=x==0 and zoomy
  i+=1
palette=("#f8f0e0","#20b0f8",(0,0,100),"#00e850","#f80048","#645450","#c0c0c0","#f8a000","#a85030")
images=(None,None,
b"\2\xa0\x021 A\20Q\20\21\20\21\20\21\20\21\20Q",
b"\xf0\1\1P1\20\xa1\4",
b"`\2\xf0\x0010A Q\20!\0\21\20Q\20Q\20",
b"\20Q\20Q\20\21\0!\20Q A01\xf0\0\2`",
b"\xa1\4\x101P\1\xf0\1",
b"Q\20Q\20\1\20!\20\1\20!\20A 1\xa0\2\2",
b"\20Q A A0101 A A\20Q",b"\xf1\a",
b"Q\20A A 1010A A Q\20",b"\2\xa0\2!0A A0!\x80\1\2`",
b"\x80\3\x01010\1\x80\3",b"`\2\x80\1!0A A0!\xa0\2\2",
b"\2P\2\xa0\2\21@1010\1\0\x1101\20",
b" !@\21P\21@!@101@\21 \2P\2",b"\x101@!@!0!@!P\21P\21@1\20",
b"\2P\2\xa0\1\1P101@\21\xa0\1\2P\2",
b'\x82\1\b7\b"\5\22\5B\25B\5\22\5B\25B\5\22\5B\25',
b"\x95\x022525252\x95\2",
b'\22\0"\0"\0"\0"\0"\0\22\6\20\2\6\20\2\6\0\6\2\6\0\6\5\6\0\6\5\6\0\6\5\6\0\6\5&\5&',
b'%B6\0"\6`F"%B6\0"\6`F"',
b'&\5&\5\6\0\6\5\6\0\6\5\6\0\6\5\6\0\6\5\6\0\6\2\6\0\6\2\6\20\2\6\20\22\0"\0"\0"\0"\0"\0\22',
b'"F`\6"\x006B%"F`\6"\x006B%',
b'\22\3\2\23B\23B4"\4\a4\x124\a\4\22\24\a$"4B\24"')
palette2=("k","#b8c0c0","#787898","#10acf8",)
logo=(b"l\1\xd0\1\1\0\1\xc8\1\2\b\1\xc0\1\2\20\3\xb8\1\2\24\3\xb4\1\3\30\3\b\1\xa0\1\2 \3\0\2\0\2\x98\1\3(\2\b\2\x94\1\3\x84\1\21\4\25\4\5\4\3\b\25\b\21\4\25\4\25\0\31\0\31\0\5\0\3\f\31\0\31\0\31\0!\b\5\0\5\24\5\24\5\24\5\34\5\f\5\20\6\24\16\f\6\24\16\f\32\b\6\f\16\b\6\b\6\0\6\24\6\f\2\0\6,\2\b\6\f\6\20\32\0\26\4\32\0\26\4\32\b\6\f\26\4\22\4\32\0\32\0\32\4\22\f\6\f\32\x8c\2\3t\3T\3\xfc\0\3H\a\x84\1\3@\3\x8c\1\3<\3\x90\1\38\3\x94\1\3\4\a$\3\x98\1\3\0\3\0\3 \3\xa0\1\3\b\3\34\3\xb0\1\3\34\3\xb4\1\3\24\3\xbc\1\3\f\3\xc4\1\3")
def drw_logo():draw_image(logo,105,20,55,palette2,zoomx=2,zoomy=2,itransp=0)
def drw_texture(i,x,y):
 if i<2:F(x,y,16,16,(0,0,100))
 else:draw_image(images[i],x,y,8,palette,2,2)
keys={}
def keyinput(key,value=None):
 if value!=None:keyPressed=value
 else:keyPressed=K(key)
 if not key in keys:keys[key]=0
 if keyPressed and not keys[key]:keys[key]=1;return 1
 if keys[key]:
  if not keyPressed:keys[key]=0
  return 0
 return 0
tile_colors=((0,0,100),(220,150,50),(0,200,250),(255,0,0),(150,150,0))

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.