mima-engine 0.2.1__py3-none-any.whl → 0.2.3__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.
- mima/__init__.py +4 -1
- mima/backend/pygame_assets.py +67 -9
- mima/backend/pygame_backend.py +5 -2
- mima/core/__init__.py +0 -0
- mima/{collision.py → core/collision.py} +11 -17
- mima/core/database.py +58 -0
- mima/{engine.py → core/engine.py} +51 -45
- mima/{mode_engine.py → core/mode_engine.py} +8 -12
- mima/{scene_engine.py → core/scene_engine.py} +3 -7
- mima/maps/template.py +31 -1
- mima/maps/tiled/tiled_object.py +1 -1
- mima/maps/tiled/tiled_tileset.py +10 -5
- mima/maps/tilemap.py +4 -10
- mima/maps/tileset.py +5 -4
- mima/objects/animated_sprite.py +79 -68
- mima/objects/creature.py +14 -7
- mima/objects/dynamic.py +3 -1
- mima/objects/effects/colorize_screen.py +9 -1
- mima/objects/effects/light.py +6 -1
- mima/objects/effects/show_sprite.py +17 -6
- mima/objects/effects/walking_on_grass.py +27 -13
- mima/objects/effects/walking_on_water.py +36 -31
- mima/objects/loader.py +6 -9
- mima/objects/projectile.py +15 -5
- mima/objects/sprite.py +8 -1
- mima/objects/world/color_gate.py +17 -21
- mima/objects/world/color_switch.py +18 -28
- mima/objects/world/container.py +31 -36
- mima/objects/world/floor_switch.py +22 -28
- mima/objects/world/gate.py +33 -32
- mima/objects/world/light_source.py +27 -32
- mima/objects/world/logic_gate.py +30 -37
- mima/objects/world/movable.py +106 -89
- mima/objects/world/oneway.py +29 -33
- mima/objects/world/pickup.py +75 -17
- mima/objects/world/switch.py +26 -31
- mima/objects/world/teleport.py +21 -22
- mima/scripts/commands/close_dialog.py +2 -1
- mima/scripts/commands/present_item.py +10 -10
- mima/types/graphic_state.py +1 -0
- mima/usables/item.py +28 -9
- mima/usables/weapon.py +28 -8
- mima/util/runtime_config.py +8 -15
- mima/util/trading_item.py +4 -1
- mima/view/mima_mode.py +19 -54
- {mima_engine-0.2.1.dist-info → mima_engine-0.2.3.dist-info}/METADATA +3 -3
- {mima_engine-0.2.1.dist-info → mima_engine-0.2.3.dist-info}/RECORD +49 -47
- {mima_engine-0.2.1.dist-info → mima_engine-0.2.3.dist-info}/WHEEL +1 -1
- {mima_engine-0.2.1.dist-info → mima_engine-0.2.3.dist-info}/top_level.txt +0 -0
mima/objects/world/movable.py
CHANGED
|
@@ -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
|
-
|
|
23
|
-
|
|
23
|
+
name="Movable",
|
|
24
|
+
*,
|
|
24
25
|
sprite_name: str,
|
|
25
|
-
|
|
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
|
-
|
|
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__(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
sprite_name,
|
|
43
|
-
|
|
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 =
|
|
278
|
+
self.vy = self._vy_throw = 1
|
|
269
279
|
if self.actor.facing_direction == Direction.WEST:
|
|
270
|
-
self.vx = -
|
|
280
|
+
self.vx = self._vx_throw = -1
|
|
271
281
|
if self.actor.facing_direction == Direction.NORTH:
|
|
272
|
-
self.vy = -
|
|
282
|
+
self.vy = self._vy_throw = -1
|
|
273
283
|
if self.actor.facing_direction == Direction.EAST:
|
|
274
|
-
self.vx =
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
)
|
|
310
|
-
|
|
311
|
-
Projectile(
|
|
312
|
-
self.px
|
|
313
|
-
self.py +
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
self.alignment,
|
|
318
|
-
|
|
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
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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
|
-
|
|
357
|
-
image_name=obj.get_string("tileset_name"),
|
|
381
|
+
name=obj.name,
|
|
358
382
|
sprite_name=obj.get_string("sprite_name"),
|
|
359
|
-
|
|
360
|
-
|
|
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()}"
|
mima/objects/world/oneway.py
CHANGED
|
@@ -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,25 @@ 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__(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
|
40
38
|
self.sprite.width = int(width * self.engine.rtc.tile_width)
|
|
41
39
|
self.sprite.height = int(height * self.engine.rtc.tile_height)
|
|
42
40
|
|
|
@@ -151,23 +149,21 @@ class Oneway(Dynamic):
|
|
|
151
149
|
@staticmethod
|
|
152
150
|
def load_from_tiled_object(obj, px, py, width, height, tilemap):
|
|
153
151
|
oneway = Oneway(
|
|
154
|
-
px
|
|
155
|
-
py
|
|
156
|
-
|
|
157
|
-
image_name=obj.get_string("tileset_name"),
|
|
152
|
+
px,
|
|
153
|
+
py,
|
|
154
|
+
obj.name,
|
|
158
155
|
sprite_name=obj.get_string("sprite_name"),
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
],
|
|
162
|
-
facing_direction=Direction[
|
|
163
|
-
obj.get_string("facing_direction", "south").upper()
|
|
164
|
-
],
|
|
156
|
+
tilemap=tilemap,
|
|
157
|
+
dyn_id=obj.object_id,
|
|
165
158
|
jump_vx=obj.get_float("jump_vx"),
|
|
166
159
|
jump_vy=obj.get_float("jump_vy"),
|
|
167
160
|
width=width,
|
|
168
161
|
height=height,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
162
|
+
)
|
|
163
|
+
oneway.graphic_state = (
|
|
164
|
+
GraphicState[obj.get_string("graphic_state", "standing").upper()],
|
|
165
|
+
)
|
|
166
|
+
oneway.facing_direction = (
|
|
167
|
+
Direction[obj.get_string("facing_direction", "south").upper()],
|
|
172
168
|
)
|
|
173
169
|
return [oneway]
|
mima/objects/world/pickup.py
CHANGED
|
@@ -1,27 +1,60 @@
|
|
|
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,
|
|
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__(
|
|
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 =
|
|
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.sprite = AnimatedSprite(
|
|
43
|
+
# self.item.tileset_name,
|
|
44
|
+
# self.item.image_name,
|
|
45
|
+
# self.item.sprite_name,
|
|
46
|
+
# graphic_state,
|
|
47
|
+
# facing_direction,
|
|
48
|
+
# )
|
|
19
49
|
|
|
20
50
|
def update(self, elapsed_time: float, target=None):
|
|
21
51
|
if self.collected:
|
|
22
52
|
self.kill()
|
|
23
53
|
else:
|
|
24
54
|
self._handle_terrain(elapsed_time)
|
|
55
|
+
self.sprite.update(
|
|
56
|
+
elapsed_time, self.facing_direction, self.graphic_state
|
|
57
|
+
)
|
|
25
58
|
|
|
26
59
|
def on_interaction(self, target: Dynamic, nature: Nature):
|
|
27
60
|
if self.collected:
|
|
@@ -38,29 +71,37 @@ class Pickup(Dynamic):
|
|
|
38
71
|
|
|
39
72
|
return False
|
|
40
73
|
|
|
41
|
-
def draw_self(
|
|
74
|
+
def draw_self(
|
|
75
|
+
self,
|
|
76
|
+
ox: float,
|
|
77
|
+
oy: float,
|
|
78
|
+
camera_name: str = "display",
|
|
79
|
+
draw_to_ui: bool = False,
|
|
80
|
+
):
|
|
42
81
|
if self.collected:
|
|
43
82
|
return
|
|
44
83
|
|
|
45
84
|
if self.pz != 0:
|
|
46
85
|
self.engine.backend.fill_circle(
|
|
47
|
-
(self.px - ox + 0.5) * self.
|
|
48
|
-
(self.py - oy + 0.7) * self.
|
|
49
|
-
0.2875 * self.
|
|
86
|
+
(self.px - ox + 0.5) * self.sprite.width,
|
|
87
|
+
(self.py - oy + 0.7) * self.sprite.height,
|
|
88
|
+
0.2875 * self.sprite.width,
|
|
50
89
|
BLACK,
|
|
51
90
|
camera_name,
|
|
52
91
|
)
|
|
53
|
-
|
|
54
|
-
|
|
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,
|
|
62
|
-
camera_name,
|
|
92
|
+
self.sprite.draw_self(
|
|
93
|
+
self.px - ox, self.py - oy, camera_name, draw_to_ui=draw_to_ui
|
|
63
94
|
)
|
|
95
|
+
# self.engine.backend.draw_partial_sprite(
|
|
96
|
+
# (self.px - ox) * self.item.sprite_width,
|
|
97
|
+
# (self.py - oy - self.pz) * self.item.sprite_height,
|
|
98
|
+
# self.item.sprite_name,
|
|
99
|
+
# self.item.sprite_ox * self.item.sprite_width,
|
|
100
|
+
# self.item.sprite_oy * self.item.sprite_height,
|
|
101
|
+
# self.item.sprite_width,
|
|
102
|
+
# self.item.sprite_height,
|
|
103
|
+
# camera_name,
|
|
104
|
+
# )
|
|
64
105
|
|
|
65
106
|
def _handle_terrain(self, elapsed_time: float):
|
|
66
107
|
"""Method is duplicated."""
|
|
@@ -91,3 +132,20 @@ class Pickup(Dynamic):
|
|
|
91
132
|
self.engine.scene.add_effect(eff)
|
|
92
133
|
# else:
|
|
93
134
|
# self.attributes.speed_mod = 1.0
|
|
135
|
+
|
|
136
|
+
@staticmethod
|
|
137
|
+
def load_from_tiled_object(obj, px, py, width, height, tilemap):
|
|
138
|
+
item = Pickup.engine.get_item(obj.get_string("usable_id"))
|
|
139
|
+
|
|
140
|
+
pickup = Pickup(
|
|
141
|
+
px,
|
|
142
|
+
py,
|
|
143
|
+
item,
|
|
144
|
+
tilemap=tilemap,
|
|
145
|
+
dyn_id=obj.object_id,
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
# pickup.sprite.width = int(width * Pickup.engine.rtc.tile_width)
|
|
149
|
+
# pickup.sprite.height = int(height * Pickup.engine.rtc.tile_height)
|
|
150
|
+
|
|
151
|
+
return [pickup]
|
mima/objects/world/switch.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from typing import List, Optional, Union
|
|
2
2
|
|
|
3
|
+
from ...maps.tilemap import Tilemap
|
|
3
4
|
from ...types.alignment import Alignment
|
|
4
5
|
from ...types.direction import Direction
|
|
5
6
|
from ...types.graphic_state import GraphicState
|
|
@@ -14,34 +15,33 @@ class Switch(Dynamic):
|
|
|
14
15
|
self,
|
|
15
16
|
px: float,
|
|
16
17
|
py: float,
|
|
17
|
-
tileset_name: str,
|
|
18
|
-
image_name: str,
|
|
19
|
-
sprite_name: str,
|
|
20
|
-
facing_direction: Direction,
|
|
21
|
-
graphic_state: GraphicState,
|
|
22
|
-
initial_signal=True,
|
|
23
|
-
tilemap=None,
|
|
24
|
-
dyn_id=0,
|
|
25
18
|
name="Switch",
|
|
19
|
+
*,
|
|
20
|
+
sprite_name: str = "",
|
|
21
|
+
tilemap: Optional[Tilemap] = None,
|
|
22
|
+
dyn_id=0,
|
|
23
|
+
graphic_state: GraphicState = GraphicState.OPEN,
|
|
24
|
+
initial_signal=True,
|
|
26
25
|
):
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
if graphic_state not in [GraphicState.OPEN, GraphicState.CLOSED]:
|
|
27
|
+
msg = (
|
|
28
|
+
f"graphic_state of Switch {name}{dyn_id} must be either "
|
|
29
|
+
f" 'open' or 'closed', but it is {graphic_state.name}"
|
|
30
|
+
)
|
|
31
|
+
raise ValueError(msg)
|
|
32
|
+
|
|
33
|
+
super().__init__(
|
|
34
|
+
px,
|
|
35
|
+
py,
|
|
36
|
+
name,
|
|
37
|
+
tilemap=tilemap,
|
|
38
|
+
sprite_name=sprite_name,
|
|
39
|
+
dyn_id=dyn_id,
|
|
39
40
|
)
|
|
40
41
|
|
|
41
42
|
self.type = ObjectType.SWITCH
|
|
42
43
|
self.alignment = Alignment.NEUTRAL
|
|
43
44
|
self.graphic_state = graphic_state
|
|
44
|
-
self.facing_direction = facing_direction
|
|
45
45
|
self.signal = self.graphic_state == GraphicState.CLOSED
|
|
46
46
|
self.listener_ids: List[int] = []
|
|
47
47
|
self.listeners: List[Dynamic] = []
|
|
@@ -138,23 +138,18 @@ class Switch(Dynamic):
|
|
|
138
138
|
switch = Switch(
|
|
139
139
|
px=px,
|
|
140
140
|
py=py,
|
|
141
|
-
|
|
142
|
-
image_name=obj.get_string("tileset_name"),
|
|
141
|
+
name=obj.name,
|
|
143
142
|
sprite_name=obj.get_string("sprite_name"),
|
|
143
|
+
tilemap=tilemap,
|
|
144
|
+
dyn_id=obj.object_id,
|
|
144
145
|
graphic_state=GraphicState[
|
|
145
146
|
obj.get_string("graphic_state", "closed").upper()
|
|
146
147
|
],
|
|
147
|
-
facing_direction=Direction[
|
|
148
|
-
obj.get_string("facing_direction", "south").upper()
|
|
149
|
-
],
|
|
150
148
|
initial_signal=obj.get_bool("initial_signal", True),
|
|
151
|
-
tilemap=tilemap,
|
|
152
|
-
dyn_id=obj.object_id,
|
|
153
|
-
name=obj.name,
|
|
154
149
|
)
|
|
155
150
|
|
|
156
|
-
switch.sprite.width = int(width * Switch.engine.rtc.tile_width)
|
|
157
|
-
switch.sprite.height = int(height * Switch.engine.rtc.tile_height)
|
|
151
|
+
# switch.sprite.width = int(width * Switch.engine.rtc.tile_width)
|
|
152
|
+
# switch.sprite.height = int(height * Switch.engine.rtc.tile_height)
|
|
158
153
|
|
|
159
154
|
ctr = 1
|
|
160
155
|
while True:
|
mima/objects/world/teleport.py
CHANGED
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import logging
|
|
4
4
|
from typing import List, Optional
|
|
5
5
|
|
|
6
|
+
from ...maps.tilemap import Tilemap
|
|
6
7
|
from ...scripts.commands.change_map import CommandChangeMap
|
|
7
8
|
from ...scripts.commands.move_map import CommandMoveMap
|
|
8
9
|
from ...scripts.commands.parallel import CommandParallel
|
|
@@ -25,9 +26,11 @@ class Teleport(Dynamic):
|
|
|
25
26
|
self,
|
|
26
27
|
px: float,
|
|
27
28
|
py: float,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
sprite_name: str,
|
|
29
|
+
name="Teleport",
|
|
30
|
+
*,
|
|
31
|
+
sprite_name: str = "str",
|
|
32
|
+
tilemap: Optional[Tilemap] = None,
|
|
33
|
+
dyn_id: int = -1,
|
|
31
34
|
facing_direction: Direction,
|
|
32
35
|
graphic_state: GraphicState,
|
|
33
36
|
dst_map_name: str,
|
|
@@ -38,20 +41,24 @@ class Teleport(Dynamic):
|
|
|
38
41
|
relative: bool = False,
|
|
39
42
|
sliding: bool = False,
|
|
40
43
|
vertical: bool = False,
|
|
41
|
-
tilemap=None,
|
|
42
|
-
dyn_id: int = -1,
|
|
43
|
-
name="Teleport",
|
|
44
44
|
):
|
|
45
|
-
super().__init__(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
facing_direction,
|
|
45
|
+
super().__init__(
|
|
46
|
+
px,
|
|
47
|
+
py,
|
|
48
|
+
name,
|
|
49
|
+
sprite_name=sprite_name,
|
|
50
|
+
tilemap=tilemap,
|
|
51
|
+
dyn_id=dyn_id,
|
|
53
52
|
)
|
|
54
53
|
|
|
54
|
+
# self.sprite = AnimatedSprite(
|
|
55
|
+
# tileset_name,
|
|
56
|
+
# image_name,
|
|
57
|
+
# sprite_name,
|
|
58
|
+
# graphic_state,
|
|
59
|
+
# facing_direction,
|
|
60
|
+
# )
|
|
61
|
+
|
|
55
62
|
self.type = ObjectType.TELEPORT
|
|
56
63
|
self.graphic_state = graphic_state
|
|
57
64
|
self.facing_direction = facing_direction
|
|
@@ -176,8 +183,6 @@ class Teleport(Dynamic):
|
|
|
176
183
|
obj, px, py, width, height, tilemap
|
|
177
184
|
) -> List[Teleport]:
|
|
178
185
|
sprite_name = obj.get_string("sprite_name")
|
|
179
|
-
tileset_name = obj.get_string("tileset_name")
|
|
180
|
-
image_name = obj.get_string("tileset_name")
|
|
181
186
|
graphic_state = GraphicState[
|
|
182
187
|
obj.get_string("graphic_state", "closed").upper()
|
|
183
188
|
]
|
|
@@ -214,8 +219,6 @@ class Teleport(Dynamic):
|
|
|
214
219
|
Teleport(
|
|
215
220
|
px=from_px,
|
|
216
221
|
py=from_py,
|
|
217
|
-
tileset_name=tileset_name,
|
|
218
|
-
image_name=image_name,
|
|
219
222
|
sprite_name=sprite_name,
|
|
220
223
|
graphic_state=graphic_state,
|
|
221
224
|
facing_direction=facing_direction,
|
|
@@ -253,8 +256,6 @@ class Teleport(Dynamic):
|
|
|
253
256
|
Teleport(
|
|
254
257
|
px=from_px,
|
|
255
258
|
py=from_py,
|
|
256
|
-
tileset_name=tileset_name,
|
|
257
|
-
image_name=image_name,
|
|
258
259
|
sprite_name=sprite_name,
|
|
259
260
|
graphic_state=graphic_state,
|
|
260
261
|
facing_direction=facing_direction,
|
|
@@ -285,8 +286,6 @@ class Teleport(Dynamic):
|
|
|
285
286
|
Teleport(
|
|
286
287
|
px=px,
|
|
287
288
|
py=py,
|
|
288
|
-
tileset_name=tileset_name,
|
|
289
|
-
image_name=image_name,
|
|
290
289
|
sprite_name=sprite_name,
|
|
291
290
|
graphic_state=graphic_state,
|
|
292
291
|
facing_direction=facing_direction,
|