summaryrefslogtreecommitdiff
path: root/txtgameengine/twod
diff options
context:
space:
mode:
authorJonas Bernard <public.jbernard@web.de>2021-04-24 02:00:21 +0200
committerJonas Bernard <public.jbernard@web.de>2021-04-24 02:00:21 +0200
commita3998a8e8b507cf2915e81ab6fbb05efef29eb65 (patch)
tree268a7cf64e6b01eb355e7e37736ecdb80e2a978e /txtgameengine/twod
parent156114359f6bb26a3cca198ac7a31bddc44381f7 (diff)
downloadtxtgameengine-a3998a8e8b507cf2915e81ab6fbb05efef29eb65.tar.gz
txtgameengine-a3998a8e8b507cf2915e81ab6fbb05efef29eb65.tar.bz2
txtgameengine-a3998a8e8b507cf2915e81ab6fbb05efef29eb65.zip
new paths
Diffstat (limited to 'txtgameengine/twod')
-rw-r--r--txtgameengine/twod/textures.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/txtgameengine/twod/textures.py b/txtgameengine/twod/textures.py
index 796774e..378227d 100644
--- a/txtgameengine/twod/textures.py
+++ b/txtgameengine/twod/textures.py
@@ -1,25 +1,27 @@
+import os
import typing
from PIL import Image
import numpy as np
+from ..app import builtin_resource_path
-TEXTURE_FOLDER = 'txtgameengine/res/textures/'
+TEXTURE_FOLDER = builtin_resource_path / 'textures'
if typing.TYPE_CHECKING:
from ..app import TxtGameApp
class Texture:
- def __init__(self, app: 'TxtGameApp', path: str):
+ def __init__(self, app: 'TxtGameApp', path: os.PathLike):
self.app = app
self.path = path
self._bind_to_gl()
def _bind_to_gl(self):
- image = Image.open(TEXTURE_FOLDER + self.path)
+ image = Image.open(os.path.join(TEXTURE_FOLDER, self.path))
self.width, self.height = image.size
imagedata = np.array(list(image.getdata()), np.uint8)
self.gl_texid = self.app.render.setup_texture(self.width, self.height, imagedata)
image.close()
def free(self):
- self.app.render.free_texture(self.gl_texid) \ No newline at end of file
+ self.app.render.free_texture(self.gl_texid)