crystalwindow 3.6.6__tar.gz → 3.6.9__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.6/crystalwindow.egg-info → crystalwindow-3.6.9}/PKG-INFO +1 -1
- crystalwindow-3.6.9/crystalwindow/gravity.py +86 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/window.py +13 -2
- {crystalwindow-3.6.6 → crystalwindow-3.6.9/crystalwindow.egg-info}/PKG-INFO +1 -1
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/setup.py +1 -1
- crystalwindow-3.6.6/crystalwindow/gravity.py +0 -75
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/LICENSE +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/MANIFEST.in +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/README.md +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/FileHelper.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/Icons/default_icon.png +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/__init__.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/animation.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/assets.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/camera.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/clock.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/collision.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/crystal3d.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/docs/getting_started.md +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/docs/index.md +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/draw_helpers.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/draw_rects.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/draw_text_helper.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/draw_tool.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/fun_helpers.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/gametests/3dsquare.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/gametests/__init__.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/gametests/__main__.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/gametests/gravitytest.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/gametests/guitesting.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/gametests/sandbox.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/gametests/squaremove.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/gametests/windowtesting.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/gui.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/gui_ext.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/math.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/player.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/sprites.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/tilemap.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow/ver_warner.py +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow.egg-info/SOURCES.txt +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow.egg-info/dependency_links.txt +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/crystalwindow.egg-info/top_level.txt +0 -0
- {crystalwindow-3.6.6 → crystalwindow-3.6.9}/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.9
|
|
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,6 +1,6 @@
|
|
|
1
1
|
# === Window Management (tkinter version) ===
|
|
2
2
|
import tkinter as tk
|
|
3
|
-
import base64, io, os, sys, contextlib
|
|
3
|
+
import base64, io, os, sys, contextlib, time
|
|
4
4
|
|
|
5
5
|
# === Boot ===
|
|
6
6
|
main_file = os.path.basename(sys.argv[0])
|
|
@@ -114,6 +114,8 @@ class Window:
|
|
|
114
114
|
self._mouse_pressed = (False, False, False)
|
|
115
115
|
self._bg_color = (20, 20, 50)
|
|
116
116
|
self.draw_calls = []
|
|
117
|
+
self._key_last = {} # new dict to store last press time per key
|
|
118
|
+
self._key_cooldown = 0.15 # seconds, tweak for faster/slower input
|
|
117
119
|
|
|
118
120
|
# === Event bindings ===
|
|
119
121
|
self.root.bind("<KeyPress>", self._on_keydown)
|
|
@@ -148,7 +150,16 @@ class Window:
|
|
|
148
150
|
def key_pressed(self, key):
|
|
149
151
|
if isinstance(key, str):
|
|
150
152
|
key = self.KEY_MAP.get(key, key)
|
|
151
|
-
|
|
153
|
+
|
|
154
|
+
now = time.time()
|
|
155
|
+
pressed = self.keys.get(key, False)
|
|
156
|
+
|
|
157
|
+
last = self._key_last.get(key, 0)
|
|
158
|
+
if pressed and (now - last) >= self._key_cooldown:
|
|
159
|
+
self._key_last[key] = now
|
|
160
|
+
return True
|
|
161
|
+
|
|
162
|
+
return False
|
|
152
163
|
|
|
153
164
|
def mouse_pressed(self, button=1):
|
|
154
165
|
return self._mouse_pressed[button - 1]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: crystalwindow
|
|
3
|
-
Version: 3.6.
|
|
3
|
+
Version: 3.6.9
|
|
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.9", # 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
|