PIX is a simple pixel editor for my game CALculator
from time import * from ion import * from kandinsky import * def compress(tab): a="" for i in tab: for j in i: a=str(j*1)+a return int(a,2) def emprec(x,y,sx,sy,col): fill_rect(x,y,sx,1,col) fill_rect(x,y,1,sy,col) fill_rect(sx+x-1,y,1,sy,col) fill_rect(x,sy+y-1,sx,1,col) def edit(sx,sy): w=10 m=1 for i in range(sx): for j in range(sy): emprec(i*w+m,j*w+m,w-2*m,w-2*m,color(0,0,0)) sp=[[False for i in range(sx)] for j in range(sy)] x=0 y=0 while not keydown(KEY_EXE): if keydown(KEY_DOWN): for i in range(m): emprec(x*w+i,y*w+i,w-i*2,w-i*2,color(255,255,255)) y+=1 elif keydown(KEY_UP): for i in range(m): emprec(x*w+i,y*w+i,w-i*2,w-i*2,color(255,255,255)) y-=1 if keydown(KEY_LEFT): for i in range(m): emprec(x*w+i,y*w+i,w-i*2,w-i*2,color(255,255,255)) x-=1 elif keydown(KEY_RIGHT): for i in range(m): emprec(x*w+i,y*w+i,w-i*2,w-i*2,color(255,255,255)) x+=1 x=x%sx y=y%sy if keydown(KEY_OK): sp[y][x]=not sp[y][x] if sp[y][x]: fill_rect(x*w+m+1,y*w+m+1,w-2*m-2,w-2*m-2,color(0,0,0)) else: fill_rect(x*w+m+1,y*w+m+1,w-2*m-2,w-2*m-2,color(250,250,250)) sleep(0.1) for i in range(m): emprec(x*w+i,y*w+i,w-i*2,w-i*2,color(255,100,0)) sleep(0.1) return compress(sp) print(edit(16,16))