crystalwindow 4.7__py3-none-any.whl → 4.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- crystalwindow/gui.py +1 -1
- crystalwindow/tilemap.py +93 -3
- crystalwindow/websearch.py +1 -0
- {crystalwindow-4.7.dist-info → crystalwindow-4.8.dist-info}/METADATA +1 -1
- {crystalwindow-4.7.dist-info → crystalwindow-4.8.dist-info}/RECORD +8 -8
- {crystalwindow-4.7.dist-info → crystalwindow-4.8.dist-info}/WHEEL +0 -0
- {crystalwindow-4.7.dist-info → crystalwindow-4.8.dist-info}/licenses/LICENSE +0 -0
- {crystalwindow-4.7.dist-info → crystalwindow-4.8.dist-info}/top_level.txt +0 -0
crystalwindow/gui.py
CHANGED
crystalwindow/tilemap.py
CHANGED
|
@@ -1,13 +1,103 @@
|
|
|
1
1
|
from .sprites import Sprite
|
|
2
2
|
|
|
3
3
|
class TileMap:
|
|
4
|
-
def __init__(self, tile_size):
|
|
4
|
+
def __init__(self, tile_size=32):
|
|
5
5
|
self.tile_size = tile_size
|
|
6
|
-
self.tiles = []
|
|
6
|
+
self.tiles = [] # list of Sprite
|
|
7
7
|
|
|
8
8
|
def add_tile(self, image, x, y):
|
|
9
|
-
|
|
9
|
+
"""Add a tile snapped to grid."""
|
|
10
|
+
gx = x // self.tile_size * self.tile_size
|
|
11
|
+
gy = y // self.tile_size * self.tile_size
|
|
12
|
+
tile = Sprite((gx, gy), (self.tile_size, self.tile_size), image=image)
|
|
13
|
+
self.tiles.append(tile)
|
|
14
|
+
return tile
|
|
15
|
+
|
|
16
|
+
def remove_tile_at(self, x, y):
|
|
17
|
+
"""Remove a tile that sits on this grid cell."""
|
|
18
|
+
gx = x // self.tile_size * self.tile_size
|
|
19
|
+
gy = y // self.tile_size * self.tile_size
|
|
20
|
+
for t in self.tiles:
|
|
21
|
+
if t.pos[0] == gx and t.pos[1] == gy:
|
|
22
|
+
self.tiles.remove(t)
|
|
23
|
+
return True
|
|
24
|
+
return False
|
|
25
|
+
|
|
26
|
+
def get_tile_at(self, x, y):
|
|
27
|
+
"""Return tile located at the grid coords."""
|
|
28
|
+
gx = x // self.tile_size * self.tile_size
|
|
29
|
+
gy = y // self.tile_size * self.tile_size
|
|
30
|
+
for t in self.tiles:
|
|
31
|
+
if t.pos[0] == gx and t.pos[1] == gy:
|
|
32
|
+
return t
|
|
33
|
+
return None
|
|
34
|
+
|
|
35
|
+
def to_data(self):
|
|
36
|
+
"""Convert to serializable list for saving."""
|
|
37
|
+
return [
|
|
38
|
+
{
|
|
39
|
+
"x": t.pos[0],
|
|
40
|
+
"y": t.pos[1],
|
|
41
|
+
"image_id": t.image_id if hasattr(t, "image_id") else None
|
|
42
|
+
}
|
|
43
|
+
for t in self.tiles
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
def load_data(self, data, image_loader):
|
|
47
|
+
"""
|
|
48
|
+
Load tiles from list.
|
|
49
|
+
image_loader(id) → returns the image object used by Sprite.
|
|
50
|
+
"""
|
|
51
|
+
self.tiles = []
|
|
52
|
+
for d in data:
|
|
53
|
+
img = image_loader(d["image_id"])
|
|
54
|
+
tile = Sprite((d["x"], d["y"]),
|
|
55
|
+
(self.tile_size, self.tile_size),
|
|
56
|
+
image=img)
|
|
57
|
+
if img is not None:
|
|
58
|
+
tile.image_id = d["image_id"]
|
|
59
|
+
self.tiles.append(tile)
|
|
10
60
|
|
|
11
61
|
def draw(self, win):
|
|
62
|
+
"""Draw all tiles."""
|
|
12
63
|
for t in self.tiles:
|
|
13
64
|
win.draw_sprite(t)
|
|
65
|
+
class Grid:
|
|
66
|
+
def __init__(self, win, cell_size=(16, 16)):
|
|
67
|
+
self.win = win
|
|
68
|
+
self.cell_w, self.cell_h = cell_size
|
|
69
|
+
self.update_size()
|
|
70
|
+
|
|
71
|
+
def update_size(self):
|
|
72
|
+
self.w, self.h = self.win.size
|
|
73
|
+
|
|
74
|
+
self.cols = self.w // self.cell_w
|
|
75
|
+
self.rows = self.h // self.cell_h
|
|
76
|
+
self.cells = [(cx, cy) for cy in range(self.rows) for cx in range(self.cols)]
|
|
77
|
+
|
|
78
|
+
# MAKES GRID WORK LIKE gameg(x, y)
|
|
79
|
+
def __call__(self, x, y):
|
|
80
|
+
"""Return cell index for given pixel pos."""
|
|
81
|
+
return x // self.cell_w, y // self.cell_h
|
|
82
|
+
|
|
83
|
+
def snap(self, x, y):
|
|
84
|
+
gx = x // self.cell_w * self.cell_w
|
|
85
|
+
gy = y // self.cell_h * self.cell_h
|
|
86
|
+
return gx, gy
|
|
87
|
+
|
|
88
|
+
def get_cell(self, x, y):
|
|
89
|
+
return x // self.cell_w, y // self.cell_h
|
|
90
|
+
|
|
91
|
+
def cell_to_px(self, cx, cy):
|
|
92
|
+
return cx * self.cell_w, cy * self.cell_h
|
|
93
|
+
|
|
94
|
+
def draw(self, color=(200, 200, 200)):
|
|
95
|
+
self.update_size()
|
|
96
|
+
|
|
97
|
+
# vertical
|
|
98
|
+
for x in range(0, self.w, self.cell_w):
|
|
99
|
+
self.win.draw_line((x, 0), (x, self.h), color)
|
|
100
|
+
|
|
101
|
+
# horizontal
|
|
102
|
+
for y in range(0, self.h, self.cell_h):
|
|
103
|
+
self.win.draw_line((0, y), (self.w, y), color)
|
crystalwindow/websearch.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crystalwindow
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.8
|
|
4
4
|
Summary: A Tkinter powered window + GUI toolkit made by Crystal (ME)! Easier apps, smoother UI and all-in-one helpers!, Gui, Buttons, FileHelper, Sprites, Animations, Colors, Math, Gravity, Camera, 3D and more!
|
|
5
5
|
Home-page: https://pypi.org/project/crystalwindow/
|
|
6
6
|
Author: CrystalBallyHereXD
|
|
@@ -14,14 +14,14 @@ crystalwindow/draw_text_helper.py,sha256=qv5fFCuTCKWeGDk9Z_ZpOzrTFP8YYwlgQrrorwr
|
|
|
14
14
|
crystalwindow/draw_tool.py,sha256=1YYEqjmgt4HpV3S15sTjCSmcqgHup4fD8gskTkxU0t4,1638
|
|
15
15
|
crystalwindow/fun_helpers.py,sha256=x-OF5dlMlHgvXjtT7Om8RvzKWgizSwnzeaM0_W3-SKQ,870
|
|
16
16
|
crystalwindow/gravity.py,sha256=pZJykZzO-mKVBPsZRP55nnlvUoYQfR29wPgJcI4IbBs,2904
|
|
17
|
-
crystalwindow/gui.py,sha256=
|
|
17
|
+
crystalwindow/gui.py,sha256=_T4diMardg50gk0_OBpFHfJo5Coo-D3aZt3Vl6PJjxQ,5287
|
|
18
18
|
crystalwindow/gui_ext.py,sha256=JctpNPr7gtGdro3csyUo9ft3FFArj3JhkVlgKF0lyME,3407
|
|
19
19
|
crystalwindow/math.py,sha256=slOY3KQZ99VDMUMxsSJabMyRtJcwVzEyxR2RoXspHho,963
|
|
20
20
|
crystalwindow/objects.py,sha256=VCEvRrzPv-bWCiVw63rMF67KYluP6FKySgDOvOiN8QU,5413
|
|
21
21
|
crystalwindow/sprites.py,sha256=IADCQetFDQoat3qGpKkH93TdtqqgldfHl4N0HKX1Ajc,7480
|
|
22
|
-
crystalwindow/tilemap.py,sha256=
|
|
22
|
+
crystalwindow/tilemap.py,sha256=endJ8KcbP9EjPvL9qWsOpV4jc_Re1yH080aUyDkwufA,3378
|
|
23
23
|
crystalwindow/ver_warner.py,sha256=qEN3ulc1NixBy15FFx2R3Zu0DhyJTVJwiESGAPwpynM,3373
|
|
24
|
-
crystalwindow/websearch.py,sha256=
|
|
24
|
+
crystalwindow/websearch.py,sha256=IgsoKt27yCBHeq8yFVfSq_8sEj5KP6mqn2yNRTsRw1A,5161
|
|
25
25
|
crystalwindow/window.py,sha256=qfz0e8dhLH0ZfoqjswFu20NJqh3Ln6rhaZ3v626Uewk,31849
|
|
26
26
|
crystalwindow/Icons/default_icon.png,sha256=Loq27Pxb8Wb3Sz-XwtNF1RmlLNxR4TcfOWfK-1lWcII,7724
|
|
27
27
|
crystalwindow/Icons/file_icons.png,sha256=kqjvz3gMaIbepW4XGrLZOjDYu-yhFbVxjvylS-0RO4U,5659
|
|
@@ -36,8 +36,8 @@ crystalwindow/gametests/sandbox.py,sha256=Oo2tU2N0y3BPVa6T5vs_h9N6islhQrjSrr_78X
|
|
|
36
36
|
crystalwindow/gametests/squaremove.py,sha256=ei6DMnvcgpOhmxbGv-Yqmx5EqiZjKbVlZhI7YbT2hY8,643
|
|
37
37
|
crystalwindow/gametests/testtttagain.py,sha256=oIhK9MGgMVly_W2lRwD9Hn9WyPdd8JnX2HGrLTGZdxY,373
|
|
38
38
|
crystalwindow/gametests/windowtesting.py,sha256=_9X6wnV1-_X_PtNS-0zu-k209NtFIwAc4vpxLPp7V2o,97
|
|
39
|
-
crystalwindow-4.
|
|
40
|
-
crystalwindow-4.
|
|
41
|
-
crystalwindow-4.
|
|
42
|
-
crystalwindow-4.
|
|
43
|
-
crystalwindow-4.
|
|
39
|
+
crystalwindow-4.8.dist-info/licenses/LICENSE,sha256=Gt5cJRchdNt0guxyQMHKsATN5PM5mjuDhdO6Gzs9qQc,1096
|
|
40
|
+
crystalwindow-4.8.dist-info/METADATA,sha256=vzIbfgjqLtMouCXoHIyg1l348FsMgPDXZ765Gj8lpAQ,7523
|
|
41
|
+
crystalwindow-4.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
42
|
+
crystalwindow-4.8.dist-info/top_level.txt,sha256=PeQSld4b19XWT-zvbYkvE2Xg8sakIMbDzSzSdOSRN8o,14
|
|
43
|
+
crystalwindow-4.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|