crystalwindow 4.7__tar.gz → 4.8__tar.gz

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.
Files changed (50) hide show
  1. {crystalwindow-4.7/crystalwindow.egg-info → crystalwindow-4.8}/PKG-INFO +1 -1
  2. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/gui.py +1 -1
  3. crystalwindow-4.8/crystalwindow/tilemap.py +103 -0
  4. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/websearch.py +1 -0
  5. {crystalwindow-4.7 → crystalwindow-4.8/crystalwindow.egg-info}/PKG-INFO +1 -1
  6. {crystalwindow-4.7 → crystalwindow-4.8}/setup.py +1 -1
  7. crystalwindow-4.7/crystalwindow/tilemap.py +0 -13
  8. {crystalwindow-4.7 → crystalwindow-4.8}/LICENSE +0 -0
  9. {crystalwindow-4.7 → crystalwindow-4.8}/MANIFEST.in +0 -0
  10. {crystalwindow-4.7 → crystalwindow-4.8}/README.md +0 -0
  11. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/FileHelper.py +0 -0
  12. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/Icons/default_icon.png +0 -0
  13. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/Icons/file_icons.png +0 -0
  14. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/__init__.py +0 -0
  15. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/ai.py +0 -0
  16. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/animation.py +0 -0
  17. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/assets.py +0 -0
  18. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/camera.py +0 -0
  19. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/clock.py +0 -0
  20. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/collision.py +0 -0
  21. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/color_handler.py +0 -0
  22. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/crystal3d.py +0 -0
  23. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/docs/getting_started.md +0 -0
  24. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/docs/index.md +0 -0
  25. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/draw_helpers.py +0 -0
  26. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/draw_rects.py +0 -0
  27. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/draw_text_helper.py +0 -0
  28. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/draw_tool.py +0 -0
  29. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/fun_helpers.py +0 -0
  30. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/gametests/3dsquare.py +0 -0
  31. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/gametests/__init__.py +0 -0
  32. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/gametests/__main__.py +0 -0
  33. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/gametests/gravitytest.py +0 -0
  34. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/gametests/guitesting.py +0 -0
  35. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/gametests/sandbox.py +0 -0
  36. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/gametests/squaremove.py +0 -0
  37. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/gametests/testtttagain.py +0 -0
  38. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/gametests/windowtesting.py +0 -0
  39. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/gravity.py +0 -0
  40. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/gui_ext.py +0 -0
  41. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/math.py +0 -0
  42. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/objects.py +0 -0
  43. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/sprites.py +0 -0
  44. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/ver_warner.py +0 -0
  45. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow/window.py +0 -0
  46. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow.egg-info/SOURCES.txt +0 -0
  47. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow.egg-info/dependency_links.txt +0 -0
  48. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow.egg-info/requires.txt +0 -0
  49. {crystalwindow-4.7 → crystalwindow-4.8}/crystalwindow.egg-info/top_level.txt +0 -0
  50. {crystalwindow-4.7 → crystalwindow-4.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crystalwindow
3
- Version: 4.7
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
@@ -45,7 +45,7 @@ class Button:
45
45
  # ======================================
46
46
  def update(self, win):
47
47
  mx, my = win.mouse_pos
48
- x, y, w, h = self.rect
48
+ x, y, w, h = self.rect
49
49
 
50
50
  # Reset transient states
51
51
  self._clicked = False
@@ -0,0 +1,103 @@
1
+ from .sprites import Sprite
2
+
3
+ class TileMap:
4
+ def __init__(self, tile_size=32):
5
+ self.tile_size = tile_size
6
+ self.tiles = [] # list of Sprite
7
+
8
+ def add_tile(self, image, x, y):
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)
60
+
61
+ def draw(self, win):
62
+ """Draw all tiles."""
63
+ for t in self.tiles:
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)
@@ -10,6 +10,7 @@ from dataclasses import dataclass
10
10
  from typing import List, Tuple, Optional, Any
11
11
 
12
12
 
13
+
13
14
  # ================================
14
15
  # Dataclass: Unified Search Result
15
16
  # ================================
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crystalwindow
3
- Version: 4.7
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
@@ -7,7 +7,7 @@ with open("README.md", encoding="utf-8") as f:
7
7
 
8
8
  setup(
9
9
  name="crystalwindow",
10
- version="4.7", # Force metadata refresh
10
+ version="4.8", # Force metadata refresh
11
11
  packages=find_packages(include=["crystalwindow", "crystalwindow.*"]),
12
12
 
13
13
  include_package_data=True, # include package_data files
@@ -1,13 +0,0 @@
1
- from .sprites import Sprite
2
-
3
- class TileMap:
4
- def __init__(self, tile_size):
5
- self.tile_size = tile_size
6
- self.tiles = []
7
-
8
- def add_tile(self, image, x, y):
9
- self.tiles.append(Sprite.image(image, x, y))
10
-
11
- def draw(self, win):
12
- for t in self.tiles:
13
- win.draw_sprite(t)
File without changes
File without changes
File without changes
File without changes