pyscratch-pysc 1.0.3__py3-none-any.whl → 1.0.4__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.
- examples/getting-started/step 7 - Referencing other sprites/enemy.py +1 -6
- pyscratch/game_module.py +7 -7
- pyscratch/sprite.py +31 -7
- {pyscratch_pysc-1.0.3.dist-info → pyscratch_pysc-1.0.4.dist-info}/METADATA +5 -4
- {pyscratch_pysc-1.0.3.dist-info → pyscratch_pysc-1.0.4.dist-info}/RECORD +7 -7
- {pyscratch_pysc-1.0.3.dist-info → pyscratch_pysc-1.0.4.dist-info}/WHEEL +0 -0
- {pyscratch_pysc-1.0.3.dist-info → pyscratch_pysc-1.0.4.dist-info}/top_level.txt +0 -0
@@ -12,11 +12,6 @@ def enemy_on_game_start():
|
|
12
12
|
# hide the parent
|
13
13
|
enemy.hide()
|
14
14
|
|
15
|
-
# the clone appear in the same location as the parent very briefly
|
16
|
-
# when it's created before we set it to a random location.
|
17
|
-
enemy.set_xy((-200, -200))
|
18
|
-
|
19
|
-
|
20
15
|
# clone itself very 2 seconds
|
21
16
|
while True:
|
22
17
|
enemy.create_clone()
|
@@ -29,7 +24,7 @@ enemy.when_game_start().add_handler(enemy_on_game_start)
|
|
29
24
|
#def on_clone(clone_sprite):
|
30
25
|
def on_clone(clone_sprite: pysc.Sprite):
|
31
26
|
|
32
|
-
|
27
|
+
#clone_sprite.hide()
|
33
28
|
# random height
|
34
29
|
clone_sprite.y = pysc.random_number(0, 720)
|
35
30
|
|
pyscratch/game_module.py
CHANGED
@@ -724,6 +724,9 @@ class Game:
|
|
724
724
|
self._space.gravity = xy
|
725
725
|
|
726
726
|
def _new_sprite_of_file(self, caller_file):
|
727
|
+
"""
|
728
|
+
return a index of the sprite created in the file
|
729
|
+
"""
|
727
730
|
if not caller_file in self._sprite_count_per_file:
|
728
731
|
self._sprite_count_per_file[caller_file] = 0
|
729
732
|
else:
|
@@ -732,15 +735,16 @@ class Game:
|
|
732
735
|
return self._sprite_count_per_file[caller_file]
|
733
736
|
|
734
737
|
|
735
|
-
def _add_sprite(self, sprite: Sprite,
|
738
|
+
def _add_sprite(self, sprite: Sprite, caller_file=None):
|
736
739
|
|
737
740
|
self._all_sprites.add(sprite)
|
738
741
|
if len(self._all_sprites) > self.max_number_sprite:
|
739
742
|
raise RuntimeError('Reached the maximum number sprite. ')
|
740
743
|
#self._space.add(sprite.body, sprite.shape)
|
741
744
|
self._sprite_click_trigger[sprite] = []
|
742
|
-
if to_show:
|
743
|
-
|
745
|
+
# if to_show:
|
746
|
+
# sprite.show()
|
747
|
+
#self._all_sprites_to_show.add(sprite)
|
744
748
|
sprite.update()
|
745
749
|
|
746
750
|
if self.__started_interactive:
|
@@ -784,16 +788,12 @@ class Game:
|
|
784
788
|
def _show_sprite(self, sprite: Sprite):
|
785
789
|
"""
|
786
790
|
Show the sprite.
|
787
|
-
|
788
|
-
You can use the alias `sprite.show()` to do the same.
|
789
791
|
"""
|
790
792
|
self._all_sprites_to_show.add(sprite)
|
791
793
|
|
792
794
|
def _hide_sprite(self, sprite: Sprite):
|
793
795
|
"""
|
794
796
|
Hide the sprite.
|
795
|
-
|
796
|
-
You can use the alias `sprite.hide()` to do the same.
|
797
797
|
"""
|
798
798
|
self._all_sprites_to_show.remove(sprite)
|
799
799
|
|
pyscratch/sprite.py
CHANGED
@@ -713,7 +713,14 @@ class Sprite(pygame.sprite.Sprite):
|
|
713
713
|
if not caller_file == this_file:
|
714
714
|
break
|
715
715
|
|
716
|
+
|
717
|
+
self._intend_to_show = True
|
718
|
+
self._shown = False
|
719
|
+
self.show()
|
720
|
+
|
716
721
|
count = game._add_sprite(self, caller_file=caller_file)
|
722
|
+
|
723
|
+
|
717
724
|
self.identifier: str
|
718
725
|
"""
|
719
726
|
An identifier of the sprite for loading sprite states (position and direction).
|
@@ -760,8 +767,10 @@ class Sprite(pygame.sprite.Sprite):
|
|
760
767
|
|
761
768
|
x, y = self._body.position
|
762
769
|
self.image, self.rect, self.mask = self._drawing_manager.on_update(x, y, self.__direction.angle_degrees)
|
763
|
-
|
770
|
+
self._shown = self._intend_to_show
|
771
|
+
|
764
772
|
self._physics_manager.on_update(self.image)
|
773
|
+
|
765
774
|
|
766
775
|
if self.__is_dragging:
|
767
776
|
self._body.velocity=0,0
|
@@ -1364,12 +1373,17 @@ class Sprite(pygame.sprite.Sprite):
|
|
1364
1373
|
```
|
1365
1374
|
"""
|
1366
1375
|
|
1367
|
-
if not self in game._all_sprites_to_show:
|
1368
|
-
|
1376
|
+
# if not self in game._all_sprites_to_show:
|
1377
|
+
# return False
|
1369
1378
|
|
1370
|
-
if not other_sprite in game._all_sprites_to_show:
|
1379
|
+
# if not other_sprite in game._all_sprites_to_show:
|
1380
|
+
# return False
|
1381
|
+
|
1382
|
+
if not self._shown:
|
1383
|
+
return False
|
1384
|
+
|
1385
|
+
if not other_sprite._shown:
|
1371
1386
|
return False
|
1372
|
-
|
1373
1387
|
|
1374
1388
|
if not pygame.sprite.collide_rect(self, other_sprite):
|
1375
1389
|
return False
|
@@ -1380,6 +1394,9 @@ class Sprite(pygame.sprite.Sprite):
|
|
1380
1394
|
"""
|
1381
1395
|
Returns whether or not this sprite is touching the mouse
|
1382
1396
|
"""
|
1397
|
+
if not self._shown:
|
1398
|
+
return False
|
1399
|
+
|
1383
1400
|
mos_x, mos_y = pygame.mouse.get_pos()
|
1384
1401
|
|
1385
1402
|
if not self.rect.collidepoint((mos_x, mos_y)):
|
@@ -1411,12 +1428,17 @@ class Sprite(pygame.sprite.Sprite):
|
|
1411
1428
|
The hidden sprite is still in the space but it cannot touch another sprites
|
1412
1429
|
"""
|
1413
1430
|
game._hide_sprite(self)
|
1431
|
+
self._shown = False
|
1432
|
+
self._intend_to_show = False
|
1414
1433
|
|
1415
1434
|
def show(self):
|
1416
1435
|
"""
|
1417
1436
|
Shows the sprite.
|
1418
1437
|
"""
|
1419
1438
|
game._show_sprite(self)
|
1439
|
+
self._intend_to_show = True
|
1440
|
+
# self._shown is set to True only during the update
|
1441
|
+
|
1420
1442
|
|
1421
1443
|
@override
|
1422
1444
|
def remove(self, *_):
|
@@ -1455,8 +1477,10 @@ class Sprite(pygame.sprite.Sprite):
|
|
1455
1477
|
shape_size_factor = self._physics_manager.shape_size_factor,
|
1456
1478
|
body_type = self._body.body_type,
|
1457
1479
|
)
|
1458
|
-
if not self
|
1459
|
-
|
1480
|
+
if not self._intend_to_show:
|
1481
|
+
sprite.hide()
|
1482
|
+
else:
|
1483
|
+
sprite.show()
|
1460
1484
|
|
1461
1485
|
if self.__rotation_style == _RotationStyle.LEFTRIGHT:
|
1462
1486
|
sprite.set_rotation_style_left_right()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pyscratch-pysc
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.4
|
4
4
|
Summary: A Python game development framework designed to provide an easy transitioning from Scratch to Python
|
5
5
|
Author-email: Daniel Ka-Wa Chan <kwdaniel525@protonmail.com>
|
6
6
|
License: MIT
|
@@ -22,11 +22,12 @@ For more information, see: https://kwdchan.github.io/pyscratch/
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
25
|
## Change History
|
29
26
|
|
27
|
+
### 12 Sep 2025
|
28
|
+
**v1.0.4**
|
29
|
+
Fixed the show/hide collision related problem due to the deferral of movement to the frame update.
|
30
|
+
|
30
31
|
### 07 Sep 2025
|
31
32
|
**v1.0.3**
|
32
33
|
Added undeclared dependency: Pillow
|
@@ -50,7 +50,7 @@ examples/getting-started/step 5 - local variables/player.py,sha256=J_kBKzFwfNRDn
|
|
50
50
|
examples/getting-started/step 6 - shared variables/enemy.py,sha256=80tUMTuNQHj3LUL3EGJWvCJIe530bXgbc7oXzlsGeLM,1588
|
51
51
|
examples/getting-started/step 6 - shared variables/main.py,sha256=tyNS0FeNTNfgs-imleNBAVm0XR5gOBcGMX4UskSRHTo,437
|
52
52
|
examples/getting-started/step 6 - shared variables/player.py,sha256=h9lIxlfCZvn1-hjtwe6SFtBgRIhqevfNg3SacfXCejg,2195
|
53
|
-
examples/getting-started/step 7 - Referencing other sprites/enemy.py,sha256=
|
53
|
+
examples/getting-started/step 7 - Referencing other sprites/enemy.py,sha256=96vAsR-1FinQXmQ-UkdN7DB_bZkFXffJLgG0PysZtag,1892
|
54
54
|
examples/getting-started/step 7 - Referencing other sprites/hearts.py,sha256=6xnCdWT6ewFVNIp2iZ4CSMzGiQfQD9g2lxDXkbTOziY,1121
|
55
55
|
examples/getting-started/step 7 - Referencing other sprites/main.py,sha256=4E3WEqL_leVlOjFYoJa01zvlDf7aWmNy3VQvia4d55Y,656
|
56
56
|
examples/getting-started/step 7 - Referencing other sprites/player.py,sha256=k8Zhg4JwTDxmusLB71eegn0q3h7iM2eosN44mox8GjI,1291
|
@@ -72,9 +72,9 @@ examples/simple_pong/right_paddle.py,sha256=72Co3jEIIh6LWXSASmFyPPc8e_pysCCkc5D6
|
|
72
72
|
examples/simple_pong/score_display.py,sha256=U9dRWp-mxxCvlgJOzKXa8Qr5WIYpI4oUQSAZX2l04u4,1234
|
73
73
|
pyscratch/__init__.py,sha256=CXCU5cYmovoV678NggRm5uMokd0l3MVakMq0XgyJA9o,2117
|
74
74
|
pyscratch/event.py,sha256=IVhXzQ4wm7Gk-q8uzY3v8Vs8w-jGE15Ec-ndpRrnJak,7439
|
75
|
-
pyscratch/game_module.py,sha256=
|
75
|
+
pyscratch/game_module.py,sha256=23Bn4nQzwb1kVuzT7m-CKBJr8ocQTe-RdiipPVzq5co,55059
|
76
76
|
pyscratch/helper.py,sha256=Ni46g3dJPFohoLFpAlHfmK6xS9kfdeKStDxlyiJFc58,15549
|
77
|
-
pyscratch/sprite.py,sha256=
|
77
|
+
pyscratch/sprite.py,sha256=lTsz9s3TlA6R_rBo-i6xJGbqv8V2oNOXLzE-PnhI54U,65204
|
78
78
|
pyscratch/tools/sprite_preview/main.py,sha256=M0xb9CXyhWzlysOnA04GUanjyMOho0WaKU6Rrs556Lk,817
|
79
79
|
pyscratch/tools/sprite_preview/settings.py,sha256=tK3yvuEK-yXGdaFZeu49F1Q1uRYbr2GVsBD5-CTPsu8,250
|
80
80
|
pyscratch/tools/sprite_preview/left_panel/frame_preview_card.py,sha256=7ek8t_LP8n_LrO-cAu9DYLyCFNHCIjRniZ5PcD0XFqc,6558
|
@@ -95,7 +95,7 @@ pyscratch/tools/sprite_preview/right_panel/spritesheet_view.py,sha256=RTQzHBeK_E
|
|
95
95
|
pyscratch/tools/sprite_preview/right_panel/ss_select_corner.py,sha256=aDAgBhrgTErHxjc0wskvN1949D6lTr805lMshjuQd_0,5842
|
96
96
|
pyscratch/tools/sprite_preview/utils/input_box.py,sha256=1isrpnHG06O729kaL3cVrB3vmunAKEtGQswEF-HM41I,9175
|
97
97
|
pyscratch/tools/sprite_preview/utils/render_wrapped_file_name.py,sha256=FOmvfqa9qqNNikZSygswBUN15d4xFfOvVN7FjuJEUSQ,3186
|
98
|
-
pyscratch_pysc-1.0.
|
99
|
-
pyscratch_pysc-1.0.
|
100
|
-
pyscratch_pysc-1.0.
|
101
|
-
pyscratch_pysc-1.0.
|
98
|
+
pyscratch_pysc-1.0.4.dist-info/METADATA,sha256=hd9wCg86sgbSkk9datZABKYEk9UMyPgcNV1epwI3sKk,1088
|
99
|
+
pyscratch_pysc-1.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
100
|
+
pyscratch_pysc-1.0.4.dist-info/top_level.txt,sha256=wXgJXVC5K61iy-F-zWhWp2jmw5_PHaxCTNHO5PxR_YY,26
|
101
|
+
pyscratch_pysc-1.0.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|