pikt_maker.py

Created by frablock

Created on September 12, 2021

1.7 KB

Partager

Concevez vos sprites directement depuis votre calculatrice

Voir la documentation


from gemamin import *;lett,im,pal,x,y="0123456789ABCDE","",[[255,255,255]],0,0
for im100 in range(100):im+="0"
def save(a):open(a,"w").write('###pik_maker\nclass pik:p=(["pikt","'+im+'",'+str(pal)+',(10,10)],print("1sprite"))')
def gr():
 for i in range(11):draw_line(10*i+50,50,10*i+50,150,(0,0,0))
 for i in range(11):draw_line(50,10*i+50,150,10*i+50,(0,0,0))
def col(a):
 a,b,cy=list(a),0,["R","G","B"]
 while True:
  fr(150,10,20,20,a);ds(cy[b],180,10);ds(str(a)+"  ",150,40)
  gm_w("alpha=choisir dans palette","shift=input ("+cy[b]+")")
  try:
   if kd(KEY_ALPHA):a=pal[int(i(str(pal)+"[0;"+str(len(pal)-1)+"]"))]
   if kd(KEY_SHIFT):a[b]=int(i(cy[b]+" : "))
  except:gm_err("input invalide")
  for e in range(5):
   if kd(e):
    if e==1:a[b]+=1;sl(0.1)
    if e==2:a[b]-=1;sl(0.1)
    if e==3 and b!=2:b+=1;sl(0.5)
    if e==0 and b!=0:b-=1;sl(0.5)
    if e==4:return a
def edit(a):
 global pal
 global im
 c,r=col(pal[int("0x"+im[a])]),""
 p(pal)
 if c.count(pal)==0 and len(pal)<=16:pal.append(c)
 try:l=list(im);l[a]=lett[pal.index(c)]
 except:gm_err("trop de couleur dans palette")
 for e in l:r+=e
 im=r
def po(a,b):fr(a*10+50,b*10+50,5,5,(ra(0,255),ra(0,255),ra(0,255)))
pikt(im,pal,(10,10,10,"?"),xy=(50,50))
while True:
 gm_w("EXE pour valider","OK pour selectionner")
 if kd(KEY_EXE):p('class pik:p=(("pikt","'+im+'",'+str(pal)+',(10,10)),print("1sprite"))\nsave("nom_du_fichier.pik")\npour sauvegarder');break
 for e in range(5):
  if kd(e):
   pikt(im,pal,(10,10,10,"?"),xy=(50,50))
   if e==1:y-=1
   if e==2:y+=1
   if e==3:x+=1
   if e==0:x-=1
   if e==4:sl(0.5);edit(ca);gr()
   sl(0.1)
 gr();po(x,y);ca=int(str(y)+str(x))
 if x==10:x,y=0,y+1
 if x==-1:x,y=10,y-1
 if y==10:y,x=0,x+1
 if y==-1:y,x=10,x-1

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.