started working on the thing
31
src/game.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from kandinsky import *
|
||||
|
||||
print("Game started")
|
||||
colors = [color(i) for i in [(26,28,44),(93,39,93),(177,62,83),(239,125,87),(255,205,117),(167,240,112),(56,183,100),(37,113,121),(41,54,111),(59,93,201),(65,166,246),(115,239,247),(244,244,244),(148,176,194),(86,108,134),(51,60,87)]]
|
||||
sprites = {}
|
||||
|
||||
class Ingredient:
|
||||
def __init__(self, i_nom):
|
||||
self.i_nom = i_nom
|
||||
self.i_sprite = sprites[i_nom]
|
||||
|
||||
class Plat:
|
||||
def __init__(self, p_type, p_ingredients):
|
||||
self.p_type = p_type
|
||||
self.p_ingredients = p_ingredients
|
||||
|
||||
def draw_map(mapid: int):
|
||||
if mapid==0:
|
||||
fill_rect(0,40,320,182,colors[4]) # table
|
||||
fill_rect(40,80,240,4,colors[3])
|
||||
fill_rect(40,84,240,2,colors[1])
|
||||
fill_rect(40,86,240,8,colors[2])
|
||||
fill_rect(40,94,240,12,colors[15])
|
||||
fill_rect(40,106,240,116,colors[14]) # sol
|
||||
fill_rect(120,120,80,80,colors[4]) # table 2
|
||||
fill_rect(120,200,80,4,colors[3])
|
||||
fill_rect(122,204,76,2,colors[1])
|
||||
fill_rect(122,206,76,8,colors[2])
|
||||
fill_rect(122,214,76,8,colors[15])
|
||||
|
||||
draw_map(0)
|
||||
59
src/sprites/_converter.py
Normal file
@@ -0,0 +1,59 @@
|
||||
from os import listdir
|
||||
from os.path import isfile, join
|
||||
from PIL import Image
|
||||
import numpy as np
|
||||
|
||||
path = "./src/sprites/"
|
||||
files_list = [f for f in listdir(path) if isfile(join(path, f))]
|
||||
|
||||
def get_offset_x(img, w, h)->int:
|
||||
offsetx = 0
|
||||
for i in range(h):
|
||||
for i in range(w):
|
||||
if img.getpixel((offsetx, i))[3] == 0:
|
||||
continue
|
||||
else:
|
||||
return offsetx
|
||||
offsetx+=1
|
||||
return offsetx
|
||||
|
||||
def get_offset_y(img, w, h)->int:
|
||||
offsety = 0
|
||||
for i in range(w):
|
||||
for i in range(h):
|
||||
if img.getpixel((i, offsety))[3] == 0:
|
||||
continue
|
||||
else:
|
||||
return offsety
|
||||
offsety+=1
|
||||
return offsety
|
||||
|
||||
def get_croped_image(img)-> tuple[Image.Image, int, int]:
|
||||
w, h = img.size
|
||||
offsetx, offsety = get_offset_x(image, w, h), get_offset_y(img, w, h)
|
||||
img_reversed = image.rotate(180)
|
||||
neg_offsetx, neg_offsety = get_offset_y(img_reversed, w, h), get_offset_x(img_reversed, w, h)
|
||||
img_croped = img.crop((offsetx, offsety, h-neg_offsety, w-neg_offsetx))
|
||||
print("w;", w, "h",h,"x:",offsetx, "y:", offsety, "neg x:", neg_offsetx, "neg y:", neg_offsety)
|
||||
print(h-offsetx-neg_offsetx, w-offsety-neg_offsety)
|
||||
return (img_croped, offsetx, offsety)
|
||||
|
||||
image = Image.open(join(path, "salade.png"))
|
||||
image_croped, off_x, off_y = get_croped_image(image)
|
||||
w, h = image_croped.size
|
||||
result = ""
|
||||
for i in range(w):
|
||||
for i in range(h):
|
||||
result.
|
||||
image_croped.show()
|
||||
exit()
|
||||
|
||||
|
||||
for file in files_list:
|
||||
if not file.endswith(".png"):
|
||||
print("Skipping", file, ", because it's not a png image.")
|
||||
break
|
||||
image = Image.open(join(path, file))
|
||||
w, h = image.size
|
||||
offsetx, offsety = 0,0
|
||||
|
||||
BIN
src/sprites/assiette.png
Normal file
|
After Width: | Height: | Size: 268 B |
BIN
src/sprites/oignon.png
Normal file
|
After Width: | Height: | Size: 330 B |
BIN
src/sprites/oignon_coupe.png
Normal file
|
After Width: | Height: | Size: 285 B |
BIN
src/sprites/planche.png
Normal file
|
After Width: | Height: | Size: 329 B |
BIN
src/sprites/player_down.png
Normal file
|
After Width: | Height: | Size: 280 B |
BIN
src/sprites/player_left.png
Normal file
|
After Width: | Height: | Size: 286 B |
BIN
src/sprites/player_right.png
Normal file
|
After Width: | Height: | Size: 290 B |
BIN
src/sprites/player_up.png
Normal file
|
After Width: | Height: | Size: 236 B |
BIN
src/sprites/poele.png
Normal file
|
After Width: | Height: | Size: 368 B |
BIN
src/sprites/salade.png
Normal file
|
After Width: | Height: | Size: 311 B |
BIN
src/sprites/salade_cuite.png
Normal file
|
After Width: | Height: | Size: 284 B |
BIN
src/sprites/steak.png
Normal file
|
After Width: | Height: | Size: 330 B |
BIN
src/sprites/steak_cuit.png
Normal file
|
After Width: | Height: | Size: 196 B |