crystalwindow 3.6.post5__tar.gz → 3.6.7__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.
- {crystalwindow-3.6.post5/crystalwindow.egg-info → crystalwindow-3.6.7}/PKG-INFO +1 -1
- crystalwindow-3.6.7/crystalwindow/gravity.py +86 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/sprites.py +13 -3
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7/crystalwindow.egg-info}/PKG-INFO +1 -1
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/setup.py +1 -1
- crystalwindow-3.6.post5/crystalwindow/gravity.py +0 -75
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/LICENSE +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/MANIFEST.in +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/README.md +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/FileHelper.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/Icons/default_icon.png +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/__init__.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/animation.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/assets.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/camera.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/clock.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/collision.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/crystal3d.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/docs/getting_started.md +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/docs/index.md +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/draw_helpers.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/draw_rects.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/draw_text_helper.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/draw_tool.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/fun_helpers.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/gametests/3dsquare.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/gametests/__init__.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/gametests/__main__.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/gametests/gravitytest.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/gametests/guitesting.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/gametests/sandbox.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/gametests/squaremove.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/gametests/windowtesting.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/gui.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/gui_ext.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/math.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/player.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/tilemap.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/ver_warner.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow/window.py +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow.egg-info/SOURCES.txt +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow.egg-info/dependency_links.txt +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/crystalwindow.egg-info/top_level.txt +0 -0
- {crystalwindow-3.6.post5 → crystalwindow-3.6.7}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crystalwindow
|
|
3
|
-
Version: 3.6.
|
|
3
|
+
Version: 3.6.7
|
|
4
4
|
Summary: A Tkinter powered window + GUI toolkit made by Crystal (MEEEEEE)! Easier apps, smoother UI and all-in-one helpers!
|
|
5
5
|
Home-page: https://pypi.org/project/crystalwindow/
|
|
6
6
|
Author: CrystalBallyHereXD
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
class Gravity:
|
|
2
|
+
def __init__(self, obj, force=0.6, terminal_velocity=18, bouncy=False, bounce_strength=0.7):
|
|
3
|
+
"""
|
|
4
|
+
obj: Sprite (or object with x, y, width, height, vel_y)
|
|
5
|
+
force: gravity per frame
|
|
6
|
+
terminal_velocity: max falling speed
|
|
7
|
+
bouncy: should object bounce on collision
|
|
8
|
+
bounce_strength: fraction of vel_y to keep when bouncing
|
|
9
|
+
"""
|
|
10
|
+
self.obj = obj
|
|
11
|
+
|
|
12
|
+
# Ensure velocity exists
|
|
13
|
+
if not hasattr(self.obj, "vel_y"):
|
|
14
|
+
self.obj.vel_y = 0
|
|
15
|
+
|
|
16
|
+
self.force = force
|
|
17
|
+
self.terminal_velocity = terminal_velocity
|
|
18
|
+
self.bouncy = bouncy
|
|
19
|
+
self.bounce_strength = bounce_strength
|
|
20
|
+
self.on_ground = False
|
|
21
|
+
self.stretch_factor = 0 # optional squishy effect
|
|
22
|
+
|
|
23
|
+
# Decide mode (rect or sprite)
|
|
24
|
+
self.mode = "sprite" if hasattr(obj, "sprite") else "rect"
|
|
25
|
+
|
|
26
|
+
# -----------------------
|
|
27
|
+
# Rect getter
|
|
28
|
+
# -----------------------
|
|
29
|
+
def get_obj_rect(self):
|
|
30
|
+
if self.mode == "sprite":
|
|
31
|
+
s = self.obj.sprite
|
|
32
|
+
return s.x, s.y, s.width, s.height
|
|
33
|
+
else:
|
|
34
|
+
return self.obj.x, self.obj.y, self.obj.width, self.obj.height
|
|
35
|
+
|
|
36
|
+
# -----------------------
|
|
37
|
+
# Rect setter
|
|
38
|
+
# -----------------------
|
|
39
|
+
def set_obj_rect(self, x, y):
|
|
40
|
+
if self.mode == "sprite":
|
|
41
|
+
self.obj.sprite.x = x
|
|
42
|
+
self.obj.sprite.y = y
|
|
43
|
+
else:
|
|
44
|
+
self.obj.x = x
|
|
45
|
+
self.obj.y = y
|
|
46
|
+
|
|
47
|
+
# -----------------------
|
|
48
|
+
# Update gravity
|
|
49
|
+
# -----------------------
|
|
50
|
+
def update(self, dt=1, platforms=[]):
|
|
51
|
+
# Apply gravity (per frame, not dt scaled)
|
|
52
|
+
self.obj.vel_y += self.force
|
|
53
|
+
if self.obj.vel_y > self.terminal_velocity:
|
|
54
|
+
self.obj.vel_y = self.terminal_velocity
|
|
55
|
+
|
|
56
|
+
# Move
|
|
57
|
+
x, y, w, h = self.get_obj_rect()
|
|
58
|
+
y += self.obj.vel_y
|
|
59
|
+
self.on_ground = False
|
|
60
|
+
|
|
61
|
+
# Platform collisions
|
|
62
|
+
for plat in platforms:
|
|
63
|
+
plat_w = getattr(plat, "width", 32)
|
|
64
|
+
plat_h = getattr(plat, "height", 32)
|
|
65
|
+
|
|
66
|
+
if (x + w > plat.x and x < plat.x + plat_w and
|
|
67
|
+
y + h > plat.y and y < plat.y + plat_h):
|
|
68
|
+
# Land on top
|
|
69
|
+
y = plat.y - h
|
|
70
|
+
self.on_ground = True
|
|
71
|
+
|
|
72
|
+
if self.bouncy:
|
|
73
|
+
self.obj.vel_y = -self.obj.vel_y * self.bounce_strength
|
|
74
|
+
self.stretch_factor = min(0.5, self.stretch_factor + 0.2)
|
|
75
|
+
else:
|
|
76
|
+
self.obj.vel_y = 0
|
|
77
|
+
self.stretch_factor = 0
|
|
78
|
+
|
|
79
|
+
# Slowly reset stretch
|
|
80
|
+
if self.stretch_factor > 0:
|
|
81
|
+
self.stretch_factor -= 0.05
|
|
82
|
+
if self.stretch_factor < 0:
|
|
83
|
+
self.stretch_factor = 0
|
|
84
|
+
|
|
85
|
+
# Write back position
|
|
86
|
+
self.set_obj_rect(x, y)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import random
|
|
1
2
|
from tkinter import PhotoImage
|
|
2
3
|
|
|
3
4
|
class Sprite:
|
|
@@ -21,16 +22,19 @@ class Sprite:
|
|
|
21
22
|
else:
|
|
22
23
|
raise ValueError("Sprite needs either 'size' or 'image'")
|
|
23
24
|
|
|
25
|
+
# optional velocity fields for physics
|
|
26
|
+
self.vel_x = 0
|
|
27
|
+
self.vel_y = 0
|
|
28
|
+
|
|
24
29
|
# === CLASS METHODS ===
|
|
25
30
|
@classmethod
|
|
26
31
|
def image(cls, img, pos):
|
|
32
|
+
# fallback if img is missing
|
|
27
33
|
if isinstance(img, dict) and img.get("fallback"):
|
|
28
34
|
print("⚠️ Missing image, making RANDOM rect fallback.")
|
|
29
35
|
w, h = img["size"]
|
|
30
36
|
color = img["color"]
|
|
31
37
|
return cls.rect(pos, w, h, color=color)
|
|
32
|
-
|
|
33
|
-
# normal image
|
|
34
38
|
return cls(pos, image=img)
|
|
35
39
|
|
|
36
40
|
@classmethod
|
|
@@ -52,11 +56,17 @@ class Sprite:
|
|
|
52
56
|
win.draw_rect(self.color, (draw_x, draw_y, self.width, self.height))
|
|
53
57
|
|
|
54
58
|
def move(self, dx, dy):
|
|
55
|
-
"""Move sprite by dx/dy"""
|
|
59
|
+
"""Move sprite manually by dx/dy"""
|
|
56
60
|
self.x += dx
|
|
57
61
|
self.y += dy
|
|
58
62
|
self.pos = (self.x, self.y)
|
|
59
63
|
|
|
64
|
+
def apply_velocity(self, dt=1):
|
|
65
|
+
"""Apply vel_x/vel_y to x/y for physics"""
|
|
66
|
+
self.x += self.vel_x * dt
|
|
67
|
+
self.y += self.vel_y * dt
|
|
68
|
+
self.pos = (self.x, self.y)
|
|
69
|
+
|
|
60
70
|
# === COLLISION ===
|
|
61
71
|
def colliderect(self, other):
|
|
62
72
|
"""Check if self collides with another sprite"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crystalwindow
|
|
3
|
-
Version: 3.6.
|
|
3
|
+
Version: 3.6.7
|
|
4
4
|
Summary: A Tkinter powered window + GUI toolkit made by Crystal (MEEEEEE)! Easier apps, smoother UI and all-in-one helpers!
|
|
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="3.6.
|
|
10
|
+
version="3.6.7", # Force metadata refresh
|
|
11
11
|
packages=find_packages(include=["crystalwindow", "crystalwindow.*"]),
|
|
12
12
|
|
|
13
13
|
include_package_data=True, # include package_data files
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
class Gravity:
|
|
2
|
-
def __init__(self, obj, force=1, terminal_velocity=15, bouncy=False, bounce_strength=0.7):
|
|
3
|
-
self.obj = obj
|
|
4
|
-
if not hasattr(self.obj, "vel_y"):
|
|
5
|
-
self.obj.vel_y = 0
|
|
6
|
-
self.force = force
|
|
7
|
-
self.terminal_velocity = terminal_velocity
|
|
8
|
-
self.bouncy = bouncy
|
|
9
|
-
self.bounce_strength = bounce_strength
|
|
10
|
-
self.on_ground = False
|
|
11
|
-
self.stretch_factor = 0 # for squishy effect
|
|
12
|
-
|
|
13
|
-
# --- NEW: choose mode ---
|
|
14
|
-
# If object has .sprite use that, else fallback to rect mode
|
|
15
|
-
if hasattr(obj, "sprite"):
|
|
16
|
-
self.mode = "sprite"
|
|
17
|
-
else:
|
|
18
|
-
self.mode = "rect"
|
|
19
|
-
|
|
20
|
-
def get_obj_rect(self):
|
|
21
|
-
# helper to get x,y,w,h depending on mode
|
|
22
|
-
if self.mode == "sprite":
|
|
23
|
-
s = self.obj.sprite
|
|
24
|
-
x = getattr(s, "x", 0)
|
|
25
|
-
y = getattr(s, "y", 0)
|
|
26
|
-
w = getattr(s, "width", getattr(s, "w", 32))
|
|
27
|
-
h = getattr(s, "height", getattr(s, "h", 32))
|
|
28
|
-
else:
|
|
29
|
-
x = getattr(self.obj, "x", 0)
|
|
30
|
-
y = getattr(self.obj, "y", 0)
|
|
31
|
-
w = getattr(self.obj, "width", getattr(self.obj, "w", 32))
|
|
32
|
-
h = getattr(self.obj, "height", getattr(self.obj, "h", 32))
|
|
33
|
-
return x, y, w, h
|
|
34
|
-
|
|
35
|
-
def update(self, dt, platforms=[]):
|
|
36
|
-
# apply gravity
|
|
37
|
-
self.obj.vel_y += self.force * dt * 60
|
|
38
|
-
if self.obj.vel_y > self.terminal_velocity:
|
|
39
|
-
self.obj.vel_y = self.terminal_velocity
|
|
40
|
-
|
|
41
|
-
# move object
|
|
42
|
-
x, y, w, h = self.get_obj_rect()
|
|
43
|
-
y += self.obj.vel_y
|
|
44
|
-
self.on_ground = False
|
|
45
|
-
|
|
46
|
-
# check collisions
|
|
47
|
-
for plat in platforms:
|
|
48
|
-
plat_w = getattr(plat, "width", getattr(plat, "w", 0))
|
|
49
|
-
plat_h = getattr(plat, "height", getattr(plat, "h", 0))
|
|
50
|
-
if (x + w > plat.x and x < plat.x + plat_w and
|
|
51
|
-
y + h > plat.y and y < plat.y + plat_h):
|
|
52
|
-
|
|
53
|
-
y = plat.y - h
|
|
54
|
-
self.on_ground = True
|
|
55
|
-
|
|
56
|
-
if self.bouncy:
|
|
57
|
-
self.obj.vel_y = -self.obj.vel_y * self.bounce_strength
|
|
58
|
-
self.stretch_factor = min(0.5, self.stretch_factor + 0.2)
|
|
59
|
-
else:
|
|
60
|
-
self.obj.vel_y = 0
|
|
61
|
-
self.stretch_factor = 0
|
|
62
|
-
|
|
63
|
-
# slowly reset stretch
|
|
64
|
-
if self.stretch_factor > 0:
|
|
65
|
-
self.stretch_factor -= 0.05
|
|
66
|
-
if self.stretch_factor < 0:
|
|
67
|
-
self.stretch_factor = 0
|
|
68
|
-
|
|
69
|
-
# write back position
|
|
70
|
-
if self.mode == "sprite":
|
|
71
|
-
self.obj.sprite.x = x
|
|
72
|
-
self.obj.sprite.y = y
|
|
73
|
-
else:
|
|
74
|
-
self.obj.x = x
|
|
75
|
-
self.obj.y = y
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|