-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgamefiles.old.py
34 lines (28 loc) · 881 Bytes
/
gamefiles.old.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import json, pickle, pathlib
import pygame as pg
from pygame.locals import *
class GameFile:
def __init__(self, manager, path, customname = None):
print(path)
self.path = pathlib.Path(path)
self.dir= self.path.parent
self.type = self.path.suffix
self.manager = manager
if customname is None:
self.name = self.path.name
else:
self.name = customname
self.manager.addfile(self)
def load(self):
data = {}
if self.type == '.json':
with open(self.path, 'r') as file:
data.update(json.load(file) )
if self.type == '.png':
data.update({
'img': GameImage(self.path)
})
data['_dir'] = str(self.dir)
self.manager.add_data(self, data)
class Spritesheet:
pass