mima-engine 0.2.2__py3-none-any.whl → 0.2.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.

Potentially problematic release.


This version of mima-engine might be problematic. Click here for more details.

Files changed (57) hide show
  1. mima/__init__.py +4 -1
  2. mima/backend/pygame_assets.py +67 -9
  3. mima/backend/pygame_backend.py +5 -2
  4. mima/backend/pygame_events.py +210 -194
  5. mima/backend/touch_control_scheme_a.py +126 -0
  6. mima/backend/touch_control_scheme_b.py +132 -0
  7. mima/core/__init__.py +0 -0
  8. mima/{collision.py → core/collision.py} +45 -28
  9. mima/core/database.py +58 -0
  10. mima/{engine.py → core/engine.py} +51 -33
  11. mima/{mode_engine.py → core/mode_engine.py} +7 -6
  12. mima/{scene_engine.py → core/scene_engine.py} +3 -7
  13. mima/maps/template.py +31 -1
  14. mima/maps/tiled/tiled_object.py +1 -1
  15. mima/maps/tiled/tiled_tileset.py +10 -5
  16. mima/maps/tilemap.py +4 -10
  17. mima/maps/tileset.py +5 -4
  18. mima/objects/animated_sprite.py +79 -68
  19. mima/objects/creature.py +20 -7
  20. mima/objects/dynamic.py +3 -1
  21. mima/objects/effects/colorize_screen.py +9 -1
  22. mima/objects/effects/debug_box.py +11 -2
  23. mima/objects/effects/light.py +6 -1
  24. mima/objects/effects/show_sprite.py +17 -6
  25. mima/objects/effects/walking_on_grass.py +27 -13
  26. mima/objects/effects/walking_on_water.py +36 -31
  27. mima/objects/loader.py +6 -9
  28. mima/objects/projectile.py +15 -5
  29. mima/objects/sprite.py +8 -1
  30. mima/objects/world/color_gate.py +10 -15
  31. mima/objects/world/color_switch.py +18 -28
  32. mima/objects/world/container.py +32 -37
  33. mima/objects/world/floor_switch.py +22 -28
  34. mima/objects/world/gate.py +21 -24
  35. mima/objects/world/light_source.py +27 -32
  36. mima/objects/world/logic_gate.py +30 -37
  37. mima/objects/world/movable.py +106 -89
  38. mima/objects/world/oneway.py +63 -41
  39. mima/objects/world/pickup.py +81 -17
  40. mima/objects/world/switch.py +46 -35
  41. mima/objects/world/teleport.py +21 -22
  42. mima/scripts/commands/oneway_move.py +4 -3
  43. mima/scripts/commands/present_item.py +10 -10
  44. mima/types/graphic_state.py +1 -0
  45. mima/usables/item.py +28 -9
  46. mima/usables/weapon.py +28 -8
  47. mima/util/constants.py +3 -3
  48. mima/util/input_defaults.py +12 -0
  49. mima/util/runtime_config.py +8 -15
  50. mima/util/trading_item.py +4 -1
  51. mima/view/mima_mode.py +8 -2
  52. mima/view/mima_scene.py +6 -0
  53. mima/view/mima_window.py +91 -0
  54. {mima_engine-0.2.2.dist-info → mima_engine-0.2.4.dist-info}/METADATA +4 -4
  55. {mima_engine-0.2.2.dist-info → mima_engine-0.2.4.dist-info}/RECORD +57 -53
  56. {mima_engine-0.2.2.dist-info → mima_engine-0.2.4.dist-info}/WHEEL +1 -1
  57. {mima_engine-0.2.2.dist-info → mima_engine-0.2.4.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,7 @@
1
1
  import math
2
2
  from typing import List, Optional
3
3
 
4
+ from ...maps.tilemap import Tilemap
4
5
  from ...types.alignment import Alignment
5
6
  from ...types.damage import Damage
6
7
  from ...types.direction import Direction
@@ -19,34 +20,29 @@ class Movable(Dynamic):
19
20
  self,
20
21
  px: float,
21
22
  py: float,
22
- tileset_name: str,
23
- image_name: str,
23
+ name="Movable",
24
+ *,
24
25
  sprite_name: str,
25
- facing_direction: Direction,
26
- graphic_state: GraphicState,
27
- mrange: float,
28
- liftable: bool,
29
- destroyable: bool,
30
- movable: bool,
31
- intangible: bool,
32
- force_collision_check: bool,
33
- tilemap=None,
26
+ tilemap: Optional[Tilemap] = None,
34
27
  dyn_id=-1,
35
- name="Movable",
28
+ mrange: float = 0.0,
29
+ liftable: bool = False,
30
+ destroyable: bool = False,
31
+ movable: bool = False,
32
+ intangible: bool = False,
33
+ force_collision_check: bool = False,
36
34
  ):
37
- super().__init__(px, py, name, tilemap, dyn_id)
38
-
39
- self.sprite = AnimatedSprite(
40
- tileset_name,
41
- image_name,
42
- sprite_name,
43
- graphic_state,
44
- facing_direction,
35
+ super().__init__(
36
+ px,
37
+ py,
38
+ name,
39
+ tilemap=tilemap,
40
+ sprite_name=sprite_name,
41
+ dyn_id=dyn_id,
45
42
  )
43
+
46
44
  self.type = ObjectType.MOVABLE
47
45
  self.alignment = Alignment.NEUTRAL
48
- self.facing_direction = facing_direction
49
- self.graphic_state = graphic_state
50
46
  self.solid_vs_map = True
51
47
 
52
48
  self.range = mrange
@@ -67,12 +63,22 @@ class Movable(Dynamic):
67
63
  self.actor: Optional[Dynamic] = None
68
64
  self.vx_mask = 0
69
65
  self.vy_mask = 0
66
+ self._vx_throw = 0
67
+ self._vy_throw = 0
68
+ self._speed_throw = 4.0
70
69
  self.move_direction: str = ""
71
70
  self.moves_on_collision = self.movable or self.destroyable
72
71
  # self.onscreen_collision_skippable = (
73
72
  # not self.movable and not force_collision_check
74
73
  # )
75
74
 
75
+ self._impact_offsets = [
76
+ [0.5, 0.5],
77
+ [-0.5, 0.5],
78
+ [-0.5, -0.5],
79
+ [0.5, -0.5],
80
+ ]
81
+
76
82
  def update(self, elapsed_time: float, target: Optional[Dynamic] = None):
77
83
  if self.intangible:
78
84
  self.solid_vs_dyn = False
@@ -199,7 +205,11 @@ class Movable(Dynamic):
199
205
  def _throw(self):
200
206
  if self.pz < 0.5:
201
207
  self.solid_vs_dyn = True
208
+ self.speed = 1.0
202
209
  if self.pz > 0:
210
+ self.vx = self._vx_throw
211
+ self.vy = self._vy_throw
212
+ self.speed = self._speed_throw
203
213
  return
204
214
 
205
215
  self._create_impact()
@@ -265,13 +275,13 @@ class Movable(Dynamic):
265
275
  # Throw away
266
276
  self.vx = self.vy = 0
267
277
  if self.actor.facing_direction == Direction.SOUTH:
268
- self.vy = 4
278
+ self.vy = self._vy_throw = 1
269
279
  if self.actor.facing_direction == Direction.WEST:
270
- self.vx = -4
280
+ self.vx = self._vx_throw = -1
271
281
  if self.actor.facing_direction == Direction.NORTH:
272
- self.vy = -4
282
+ self.vy = self._vy_throw = -1
273
283
  if self.actor.facing_direction == Direction.EAST:
274
- self.vx = 4
284
+ self.vx = self._vx_throw = 1
275
285
 
276
286
  self.vz = 6.0
277
287
  self.pz = self.actor.pz + 0.9
@@ -295,85 +305,92 @@ class Movable(Dynamic):
295
305
  self.vx = self.vy = 0.0
296
306
 
297
307
  def _create_impact(self):
298
- impact: List[Projectile] = []
299
- impact.append(
300
- Projectile(
301
- self.px + 0.5,
302
- self.py + 0.5,
303
- 0,
304
- 0,
305
- 0.2,
306
- self.alignment,
307
- self.tilemap,
308
- )
309
- )
310
- impact.append(
311
- Projectile(
312
- self.px - 0.5,
313
- self.py + 0.5,
314
- 0,
315
- 0,
316
- 0.2,
317
- self.alignment,
318
- self.tilemap,
319
- )
320
- )
321
- impact.append(
322
- Projectile(
323
- self.px - 0.5,
324
- self.py - 0.5,
325
- 0,
326
- 0,
327
- 0.2,
328
- self.alignment,
329
- self.tilemap,
330
- )
331
- )
332
- impact.append(
333
- Projectile(
334
- self.px + 0.5,
335
- self.py - 0.5,
336
- 0,
337
- 0,
338
- 0.2,
339
- self.alignment,
340
- self.tilemap,
308
+ # impact: List[Projectile] = []
309
+ # impact.append(
310
+ # Projectile(
311
+ # self.px + 0.5,
312
+ # self.py + 0.5,
313
+ # 0,
314
+ # 0,
315
+ # 0.2,
316
+ # self.alignment,
317
+ # self.tilemap,
318
+ # )
319
+ # )
320
+ for idx, offsets in enumerate(self._impact_offsets):
321
+ p = Projectile(
322
+ self.px + offsets[0],
323
+ self.py + offsets[1],
324
+ f"Movable Impact {idx}",
325
+ sprite_name="small_explosion",
326
+ tilemap=self.tilemap,
327
+ alignment=self.alignment,
328
+ duration=0.2,
341
329
  )
342
- )
330
+ p.solid_vs_dyn = False
331
+ p.solid_vs_map = False
332
+ p.damage = 5
333
+ # impact.append(p)
334
+ self.engine.get_view().add_projectile(p, self.tilemap.name)
335
+
336
+ # impact.append(
337
+ # Projectile(
338
+ # self.px - 0.5,
339
+ # self.py + 0.5,
340
+ # 0,
341
+ # 0,
342
+ # 0.2,
343
+ # self.alignment,
344
+ # self.tilemap,
345
+ # )
346
+ # )
347
+ # impact.append(
348
+ # Projectile(
349
+ # self.px - 0.5,
350
+ # self.py - 0.5,
351
+ # 0,
352
+ # 0,
353
+ # 0.2,
354
+ # self.alignment,
355
+ # self.tilemap,
356
+ # )
357
+ # )
358
+ # impact.append(
359
+ # Projectile(
360
+ # self.px + 0.5,
361
+ # self.py - 0.5,
362
+ # 0,
363
+ # 0,
364
+ # 0.2,
365
+ # self.alignment,
366
+ # self.tilemap,
367
+ # )
368
+ # )
343
369
 
344
- for pro in impact:
345
- pro.sprite.name = "explosion"
346
- pro.solid_vs_dyn = False
347
- pro.solid_vs_map = False
348
- pro.damage = 5
349
- self.engine.view.add_projectile(pro, self.tilemap.name)
370
+ # for pro in impact:
371
+ # pro.sprite.name = "explosion"
372
+ # pro.solid_vs_dyn = False
373
+ # pro.solid_vs_map = False
374
+ # pro.damage = 5
350
375
 
351
376
  @staticmethod
352
377
  def load_from_tiled_object(obj, px, py, width, height, tilemap):
353
378
  movable = Movable(
354
379
  px=px,
355
380
  py=py,
356
- tileset_name=obj.get_string("tileset_name"),
357
- image_name=obj.get_string("tileset_name"),
381
+ name=obj.name,
358
382
  sprite_name=obj.get_string("sprite_name"),
359
- graphic_state=GraphicState[
360
- obj.get_string("graphic_state", "standing").upper()
361
- ],
362
- facing_direction=Direction[
363
- obj.get_string("facing_direction", "south").upper()
364
- ],
383
+ tilemap=tilemap,
384
+ dyn_id=obj.object_id,
365
385
  mrange=obj.get_float("range"),
366
386
  liftable=obj.get_bool("liftable"),
367
387
  destroyable=obj.get_bool("destroyable"),
368
388
  movable=obj.get_bool("movable"),
369
389
  intangible=obj.get_bool("intangible"),
370
390
  force_collision_check=obj.get_bool("force_collision_check"),
371
- tilemap=tilemap,
372
- dyn_id=obj.object_id,
373
- name=obj.name,
374
391
  )
375
- movable.sprite.width = int(width * Movable.engine.rtc.tile_width)
376
- movable.sprite.height = int(height * Movable.engine.rtc.tile_height)
392
+ # movable.sprite.width = int(width * Movable.engine.rtc.tile_width)
393
+ # movable.sprite.height = int(height * Movable.engine.rtc.tile_height)
377
394
  for dt in Damage:
378
395
  movable.attributes.defense[dt] = obj.get_int(
379
396
  f"defense_{dt.name.lower()}"
@@ -1,3 +1,6 @@
1
+ from typing import List, Optional, Union
2
+
3
+ from ...maps.tilemap import Tilemap
1
4
  from ...scripts.commands.oneway_move import CommandOnewayMove
2
5
  from ...types.direction import Direction
3
6
  from ...types.graphic_state import GraphicState
@@ -13,30 +16,26 @@ class Oneway(Dynamic):
13
16
  self,
14
17
  px: float,
15
18
  py: float,
16
- tileset_name: str,
17
- image_name: str,
18
- sprite_name: str,
19
- facing_direction: Direction,
20
- graphic_state: GraphicState,
21
- jump_vx: float,
22
- jump_vy: float,
23
- width: float,
24
- height: float,
25
- tilemap,
26
- dyn_id=-1,
27
19
  name="Oneway",
20
+ *,
21
+ sprite_name: str = "",
22
+ tilemap: Optional[Tilemap] = None,
23
+ dyn_id=-1,
24
+ jump_vx: float = 0.0,
25
+ jump_vy: float = 0.0,
26
+ width: float = 0.0,
27
+ height: float = 0.0,
28
28
  ):
29
- super().__init__(px, py, name, tilemap, dyn_id)
30
- self.sprite = AnimatedSprite(
31
- tileset_name,
32
- image_name,
33
- sprite_name,
34
- graphic_state,
35
- facing_direction,
29
+ super().__init__(
30
+ px,
31
+ py,
32
+ name,
33
+ tilemap=tilemap,
34
+ sprite_name=sprite_name,
35
+ dyn_id=dyn_id,
36
36
  )
37
37
  self.type = ObjectType.ONEWAY
38
- self.graphic_state = graphic_state
39
- self.facing_direction = facing_direction
38
+ self.layer = 0
40
39
  self.sprite.width = int(width * self.engine.rtc.tile_width)
41
40
  self.sprite.height = int(height * self.engine.rtc.tile_height)
42
41
 
@@ -48,24 +47,26 @@ class Oneway(Dynamic):
48
47
  self.height: float = height
49
48
  self.jump_vx: float = 0.0
50
49
  self.jump_vy: float = 0.0
50
+ self.jump_direction = Direction.from_velocity(jump_vx, jump_vy)
51
51
  self.activation_delay: float = ONEWAY_ACTIVATION_DELAY
52
52
  self.triggered: bool = False
53
+ self.is_active: bool = False
53
54
  self.cooldown: float = 0.0
54
55
  self.target = None
55
56
 
56
57
  if jump_vx < 0:
57
58
  self.jump_vx = jump_vx - 1
58
- self.hitbox_px += 0.1
59
+ # self.hitbox_px += 0.1
59
60
  elif jump_vx > 0:
60
61
  self.jump_vx = jump_vx + 1
61
- self.hitbox_px -= 0.1
62
+ # self.hitbox_px -= 0.1
62
63
 
63
64
  if jump_vy < 0:
64
65
  self.jump_vy = jump_vy - 1
65
- self.hitbox_py += 0.1
66
+ # self.hitbox_py += 0.1
66
67
  elif jump_vy > 0:
67
68
  self.jump_vy = jump_vy + 1
68
- self.hitbox_py -= 0.1
69
+ # self.hitbox_py -= 0.1
69
70
 
70
71
  def update(self, elapsed_time, target=None):
71
72
  self.sprite.update(
@@ -92,9 +93,15 @@ class Oneway(Dynamic):
92
93
  # Activation countdown reached 0 and the jump is initiated.
93
94
  if self.timer <= 0.0 and self.target is not None:
94
95
  self.engine.script.add_command(
95
- CommandOnewayMove(self.target, self.jump_vx, self.jump_vy)
96
+ CommandOnewayMove(
97
+ self.target,
98
+ self.jump_vx,
99
+ self.jump_vy,
100
+ target.get_player(),
101
+ )
96
102
  )
97
103
  self.cooldown = 2.0
104
+ self.is_active
98
105
 
99
106
  # Reset the triggered flag so it has to be activated again
100
107
  # by interaction
@@ -102,11 +109,25 @@ class Oneway(Dynamic):
102
109
  self.target = None
103
110
 
104
111
  def on_interaction(self, target, nature=Nature.WALK):
105
- if target.type == ObjectType.PLAYER and nature == Nature.WALK:
112
+ if (
113
+ target.type == ObjectType.PLAYER
114
+ and nature == Nature.WALK
115
+ and self.cooldown <= 0.0
116
+ ):
106
117
  # No interaction when target is higher than the oneway
107
118
  if target.pz > 0:
108
119
  return False
109
120
 
121
+ if self.jump_direction != target.facing_direction:
122
+ return False
123
+
124
+ tcenterx = target.px + (target.hitbox_px + target.hitbox_width) / 2
125
+ tbottomy = target.py + target.hitbox_py + target.hitbox_height
126
+ ttopy = target.py + target.hitbox_py
127
+ tleftx = target.px + target.hitbox_px
128
+ trightx = tleftx + target.hitbox_width
129
+
130
+ # print(tcenterx, tbottomy)
110
131
  # We have to check that target is not placed "more" in the
111
132
  # target direction than the oneway
112
133
  if (
@@ -121,7 +142,7 @@ class Oneway(Dynamic):
121
142
  and target.py <= self.py + self.height - target.hitbox_py
122
143
  ):
123
144
  return False
124
- if self.jump_vy > 0 and target.py >= self.py:
145
+ if self.jump_vy > 0 and tbottomy >= self.py: # FIXME
125
146
  return False
126
147
 
127
148
  if self.jump_vx == 0:
@@ -135,12 +156,15 @@ class Oneway(Dynamic):
135
156
  return False
136
157
  if target.py + 1.0 <= self.py:
137
158
  return False
138
-
139
159
  self.triggered = True
140
160
  self.target = target
141
161
  if self.timer <= 0.0:
142
162
  self.timer = self.activation_delay
163
+ # return False
143
164
 
165
+ # print(
166
+ # f"activated {self.timer:.3f}, {self.px, self.py}, {target.px, target.py}, {target.sprite.width, target.sprite.height}"
167
+ # )
144
168
  return True
145
169
 
146
170
  return False
@@ -151,23 +175,21 @@ class Oneway(Dynamic):
151
175
  @staticmethod
152
176
  def load_from_tiled_object(obj, px, py, width, height, tilemap):
153
177
  oneway = Oneway(
154
- px=px,
155
- py=py,
156
- tileset_name=obj.get_string("tileset_name"),
157
- image_name=obj.get_string("tileset_name"),
178
+ px,
179
+ py,
180
+ obj.name,
158
181
  sprite_name=obj.get_string("sprite_name"),
159
- graphic_state=GraphicState[
160
- obj.get_string("graphic_state", "standing").upper()
161
- ],
162
- facing_direction=Direction[
163
- obj.get_string("facing_direction", "south").upper()
164
- ],
182
+ tilemap=tilemap,
183
+ dyn_id=obj.object_id,
165
184
  jump_vx=obj.get_float("jump_vx"),
166
185
  jump_vy=obj.get_float("jump_vy"),
167
186
  width=width,
168
187
  height=height,
169
- tilemap=tilemap,
170
- dyn_id=obj.object_id,
171
- name=obj.name,
188
+ )
189
+ oneway.graphic_state = (
190
+ GraphicState[obj.get_string("graphic_state", "standing").upper()],
191
+ )
192
+ oneway.facing_direction = (
193
+ Direction[obj.get_string("facing_direction", "south").upper()],
172
194
  )
173
195
  return [oneway]
@@ -1,27 +1,61 @@
1
+ from typing import Optional
2
+
3
+ from ...maps.tilemap import Tilemap
1
4
  from ...objects.dynamic import Dynamic
5
+ from ...types.direction import Direction
6
+ from ...types.graphic_state import GraphicState
2
7
  from ...types.nature import Nature
3
8
  from ...types.object import ObjectType
4
9
  from ...types.terrain import Terrain
10
+ from ...usables.item import Item
5
11
  from ...util.colors import BLACK
12
+ from ..animated_sprite import AnimatedSprite
6
13
  from ..effects.walking_on_grass import WalkingOnGrass
7
14
  from ..effects.walking_on_water import WalkingOnWater
8
15
 
9
16
 
10
17
  class Pickup(Dynamic):
11
18
  def __init__(
12
- self, px: float, py: float, item_name: str, tilemap, dyn_id=0
19
+ self,
20
+ px: float,
21
+ py: float,
22
+ item: Item,
23
+ *,
24
+ tilemap: Optional[Tilemap] = None,
25
+ dyn_id=0,
13
26
  ):
14
- super().__init__(px, py, "Pickup", tilemap, dyn_id)
27
+ super().__init__(
28
+ px,
29
+ py,
30
+ f"Pickup({item.name})",
31
+ sprite_name=item.sprite_name,
32
+ tilemap=tilemap,
33
+ dyn_id=dyn_id,
34
+ )
15
35
  self.type: ObjectType = ObjectType.PICKUP
16
- self.item = self.engine.get_item(item_name)
36
+ self.item = item
37
+ # if not sprite_name:
38
+ # sprite_name = self.item.sprite_name
39
+
17
40
  self.collected = False
18
41
  self.solid_vs_dyn = False
42
+ self.moves_on_collision = True
43
+ # self.sprite = AnimatedSprite(
44
+ # self.item.tileset_name,
45
+ # self.item.image_name,
46
+ # self.item.sprite_name,
47
+ # graphic_state,
48
+ # facing_direction,
49
+ # )
19
50
 
20
51
  def update(self, elapsed_time: float, target=None):
21
52
  if self.collected:
22
53
  self.kill()
23
54
  else:
24
55
  self._handle_terrain(elapsed_time)
56
+ self.sprite.update(
57
+ elapsed_time, self.facing_direction, self.graphic_state
58
+ )
25
59
 
26
60
  def on_interaction(self, target: Dynamic, nature: Nature):
27
61
  if self.collected:
@@ -38,29 +72,42 @@ class Pickup(Dynamic):
38
72
 
39
73
  return False
40
74
 
41
- def draw_self(self, ox: float, oy: float, camera_name: str = "display"):
75
+ def draw_self(
76
+ self,
77
+ ox: float,
78
+ oy: float,
79
+ camera_name: str = "display",
80
+ draw_to_ui: bool = False,
81
+ ):
42
82
  if self.collected:
43
83
  return
44
84
 
45
85
  if self.pz != 0:
86
+
87
+ # print("Draw item circle")
46
88
  self.engine.backend.fill_circle(
47
- (self.px - ox + 0.5) * self.item.sprite_width,
48
- (self.py - oy + 0.7) * self.item.sprite_height,
49
- 0.2875 * self.item.sprite_width,
89
+ (self.px - ox + 0.5) * self.sprite.width,
90
+ (self.py - oy + 0.7) * self.sprite.height,
91
+ 0.2875 * self.sprite.width,
50
92
  BLACK,
51
93
  camera_name,
52
94
  )
53
-
54
- self.engine.backend.draw_partial_sprite(
55
- (self.px - ox) * self.item.sprite_width,
56
- (self.py - oy - self.pz) * self.item.sprite_height,
57
- self.item.sprite_name,
58
- self.item.sprite_ox * self.item.sprite_width,
59
- self.item.sprite_oy * self.item.sprite_height,
60
- self.item.sprite_width,
61
- self.item.sprite_height,
95
+ self.sprite.draw_self(
96
+ self.px - ox,
97
+ self.py - oy - self.pz,
62
98
  camera_name,
99
+ draw_to_ui=draw_to_ui,
63
100
  )
101
+ # self.engine.backend.draw_partial_sprite(
102
+ # (self.px - ox) * self.item.sprite_width,
103
+ # (self.py - oy - self.pz) * self.item.sprite_height,
104
+ # self.item.sprite_name,
105
+ # self.item.sprite_ox * self.item.sprite_width,
106
+ # self.item.sprite_oy * self.item.sprite_height,
107
+ # self.item.sprite_width,
108
+ # self.item.sprite_height,
109
+ # camera_name,
110
+ # )
64
111
 
65
112
  def _handle_terrain(self, elapsed_time: float):
66
113
  """Method is duplicated."""
@@ -88,6 +135,23 @@ class Pickup(Dynamic):
88
135
  else:
89
136
  eff = WalkingOnWater(self)
90
137
  self.effects.append(eff)
91
- self.engine.scene.add_effect(eff)
138
+ self.engine.get_view().add_effect(eff, self.tilemap.name)
92
139
  # else:
93
140
  # self.attributes.speed_mod = 1.0
141
+
142
+ @staticmethod
143
+ def load_from_tiled_object(obj, px, py, width, height, tilemap):
144
+ item = Pickup.engine.get_item(obj.get_string("usable_id"))
145
+
146
+ pickup = Pickup(
147
+ px,
148
+ py,
149
+ item,
150
+ tilemap=tilemap,
151
+ dyn_id=obj.object_id,
152
+ )
153
+
154
+ # pickup.sprite.width = int(width * Pickup.engine.rtc.tile_width)
155
+ # pickup.sprite.height = int(height * Pickup.engine.rtc.tile_height)
156
+
157
+ return [pickup]