diff --git a/data/sprites/food.sprite b/data/sprites/food.sprite index cfcf539..cfd89e1 100644 --- a/data/sprites/food.sprite +++ b/data/sprites/food.sprite @@ -1,13 +1,128 @@ { - -"item_food_potato" : { - "texture" : "food", - "topx" : 0, - "topy" : 0, - "height" : 32, - "width" : 32, - "originx" : 16, - "originy" : 16 -} - + "item_food_potato": { + "texture": "food", + "topx": 0, + "topy": 0, + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + }, + "item_food_carrot": { + "texture": "food", + "topx": 192, + "topy": 0, + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + }, + "item_food_onion": { + "texture": "food", + "topx": 416, + "topy": 0, + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + }, + "item_food_onion_red": { + "texture": "food", + "topx": 448, + "topy": 0, + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + }, + "item_food_pepper_green": { + "texture": "food", + "topx": 576, + "topy": 0, + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + }, + "item_food_pepper_red": { + "texture": "food", + "topx": 608, + "topy": 0, + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + }, + "item_food_pepper_orange": { + "texture": "food", + "topx": 640, + "topy": 0, + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + }, + "item_food_pepper_yellow": { + "texture": "food", + "topx": 672, + "topy": 0, + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + }, + "item_food_water_mellon": { + "texture": "food", + "topx": 736, + "topy": 0, + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + }, + "item_food_mellon": { + "texture": "food", + "topx": 800, + "topy": 0, + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + }, + "item_food_pumpkin": { + "texture": "food", + "topx": 864, + "topy": 0, + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + }, + "item_food_apple_green": { + "texture": "food", + "topx": 32, + "topy": 320, + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + }, + "item_food_apple_yellow": { + "texture": "food", + "topx": 96, + "topy": 320, + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + }, + "item_food_apple_red": { + "texture": "food", + "topx": 128, + "topy": 320, + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + } } \ No newline at end of file diff --git a/extra/scripts/python/process_food_items.py b/extra/scripts/python/process_food_items.py index 84087ad..2f39ab9 100644 --- a/extra/scripts/python/process_food_items.py +++ b/extra/scripts/python/process_food_items.py @@ -1,8 +1,32 @@ import pandas as pd +import json FILENAME="../food_items.csv" +FILENAME_SPRITE="../../../data/sprites/food.sprite" + +def produce_sprite_file(): + df = pd.read_csv(FILENAME) + items = {} + + for index, row in df.iterrows(): + name = "item_food_" + row["food_name"] + item = { + "texture": "food", + "topx": int(row["x"]), + "topy": int(row["y"]), + "height": 32, + "width": 32, + "originx": 16, + "originy": 16 + } + items[name] = item + + # Save the dictionary as a json file + with open(FILENAME_SPRITE, "w") as f: + json.dump(items, f, indent=4) def main(): + produce_sprite_file() reader = pd.read_csv(FILENAME) for row in reader.itertuples(): print(row)