crystalwindow 3.6.6__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.
Files changed (44) hide show
  1. {crystalwindow-3.6.6/crystalwindow.egg-info → crystalwindow-3.6.7}/PKG-INFO +1 -1
  2. crystalwindow-3.6.7/crystalwindow/gravity.py +86 -0
  3. {crystalwindow-3.6.6 → crystalwindow-3.6.7/crystalwindow.egg-info}/PKG-INFO +1 -1
  4. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/setup.py +1 -1
  5. crystalwindow-3.6.6/crystalwindow/gravity.py +0 -75
  6. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/LICENSE +0 -0
  7. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/MANIFEST.in +0 -0
  8. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/README.md +0 -0
  9. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/FileHelper.py +0 -0
  10. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/Icons/default_icon.png +0 -0
  11. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/__init__.py +0 -0
  12. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/animation.py +0 -0
  13. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/assets.py +0 -0
  14. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/camera.py +0 -0
  15. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/clock.py +0 -0
  16. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/collision.py +0 -0
  17. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/crystal3d.py +0 -0
  18. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/docs/getting_started.md +0 -0
  19. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/docs/index.md +0 -0
  20. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/draw_helpers.py +0 -0
  21. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/draw_rects.py +0 -0
  22. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/draw_text_helper.py +0 -0
  23. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/draw_tool.py +0 -0
  24. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/fun_helpers.py +0 -0
  25. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/gametests/3dsquare.py +0 -0
  26. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/gametests/__init__.py +0 -0
  27. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/gametests/__main__.py +0 -0
  28. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/gametests/gravitytest.py +0 -0
  29. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/gametests/guitesting.py +0 -0
  30. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/gametests/sandbox.py +0 -0
  31. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/gametests/squaremove.py +0 -0
  32. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/gametests/windowtesting.py +0 -0
  33. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/gui.py +0 -0
  34. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/gui_ext.py +0 -0
  35. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/math.py +0 -0
  36. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/player.py +0 -0
  37. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/sprites.py +0 -0
  38. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/tilemap.py +0 -0
  39. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/ver_warner.py +0 -0
  40. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow/window.py +0 -0
  41. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow.egg-info/SOURCES.txt +0 -0
  42. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow.egg-info/dependency_links.txt +0 -0
  43. {crystalwindow-3.6.6 → crystalwindow-3.6.7}/crystalwindow.egg-info/top_level.txt +0 -0
  44. {crystalwindow-3.6.6 → 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.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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crystalwindow
3
- Version: 3.6.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.6", # Force metadata refresh
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