Log In  
Follow
Lahat
Follow

Hi I have made a quick python script to turn an square picture to a string of text that can the be parsed by pico8 to make a nice splashscreen.


Pico8 code

function txt_to_pic(txt)
 local d={
 a=10,
 b=11,
 c=12,
 d=13,
 e=14,
 f=15
 }
 d['0']=0
 d['1']=1
 d['2']=2
 d['3']=3
 d['4']=4
 d['5']=5
 d['6']=6
 d['7']=7
 d['8']=8
 d['9']=9
 local x=0
 local y=0
 for i=0,#txt do
  if x>128 then 
   x=0
   y+=1
  end
  c=d[sub(txt,i,i)]
  pset(x,y,c)
  x+=1
 end
end

And here is the python script (just replace "me.jpg" by your image):

import numpy
import PIL
#%%
img = PIL.Image.open("me.jpg")
img = img.resize((128,128))
imgarr = numpy.array(img)
newimg=numpy.array(img)
img.resize((128*10,128*10))

p8colors=[
        (0,0,0),
        (29,43,83),
        (126,37,83),
        (0,135,81),
        (171, 82, 54),
        (95, 87, 79),
        (194, 195, 199),
        (255, 241, 232),
        (255, 0, 77),
        (255, 163, 0),
        (255, 236, 39),
        (0, 228, 54),
        (41, 173, 255),
        (131, 118, 156),
        (255, 119, 168),
        (255, 204, 170)]

col_to_letter='0123456789ABCDEF'

def color_dist(a,b):
    r1,g1,b1 = a[:3]
    r2,g2,b2 = b[:3]
    return int(((r1-r2)**2+(g1-g2)**2+(b1-b2)**2)**(0.5))

def best_col(c):
    distances=[color_dist(c,i) for i in p8colors]
    m=min(distances)
    return  distances.index(m)
STR = ''

for y,line in enumerate(imgarr):
    for x,c in enumerate(line):
        newc=best_col(c)
        STR+=col_to_letter[newc]
        newimg[y][x]=p8colors[newc]

    STR+='L'

p8image=(STR)
PIL.Image.fromarray(newimg).resize((1280,1280))

Cart #ganuhupawe-0 | 2019-11-01 | Code ▽ | Embed ▽ | No License

P#69552 2019-11-01 12:34 ( Edited 2019-11-01 12:35)

Cart #brexit-2 | 2019-10-31 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
17

A highly realistic simulation of Brexit negotiations. Enjoy the riveting and exciting career of a Brexit Prime Minister. Only you can do this, because no one else wants to deal with it.

I have not seen any 'political satire' games here, so I hope its a good precedent. There is very contextually implied nsfw material which is based on real events and quotes.

P#69500 2019-10-31 01:06 ( Edited 2019-10-31 21:39)

Hi, I am having a problem with sprites and the map.

It seems that the botom half of my spritesheets is interlinked with the bottom part of the map.

It is realy frustating, is there anything I can do?

P#69453 2019-10-29 12:38

Following the vein of word quiz animals I have now made another version.

Code wise it now enables to use funcitons instead of sprites.

The drawing function do not use any global variable besides the tick number (tick+=1 every _update()).

Any suggestions would be welcome.

Cart #word_quiz_shapes-3 | 2019-10-24 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

To do:

better mainpage.
MOAR shapes.

P#69243 2019-10-24 23:31 ( Edited 2019-10-25 20:55)

Cart #word_quiz_animals-2 | 2019-10-21 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

A small young children game for learning to spell and read.
want to update with more and more animals (ideally consume all possible sprites).

P#69082 2019-10-19 23:22 ( Edited 2019-10-26 12:52)

Cart #58686 | 2018-11-02 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

A simple generative art.

The formula is printed at the bottom of the screen.

P#58687 2018-11-02 18:16 ( Edited 2018-11-03 12:35)

Cart #58501 | 2018-10-28 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

generative art

P#58502 2018-10-28 07:06 ( Edited 2018-10-28 11:06)

Cart #58466 | 2018-10-27 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

Just playing with pixels.

A bit of generative art.

P#58467 2018-10-27 05:09 ( Edited 2018-10-29 21:11)

Follow Lexaloffle:        
Generated 2019-12-10 14:41 | 0.094s | 4194k | Q:99