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.
- mima/__init__.py +4 -1
- mima/backend/pygame_assets.py +67 -9
- mima/backend/pygame_backend.py +5 -2
- mima/backend/pygame_events.py +210 -194
- mima/backend/touch_control_scheme_a.py +126 -0
- mima/backend/touch_control_scheme_b.py +132 -0
- mima/core/__init__.py +0 -0
- mima/{collision.py → core/collision.py} +45 -28
- mima/core/database.py +58 -0
- mima/{engine.py → core/engine.py} +51 -33
- mima/{mode_engine.py → core/mode_engine.py} +7 -6
- 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 +20 -7
- mima/objects/dynamic.py +3 -1
- mima/objects/effects/colorize_screen.py +9 -1
- mima/objects/effects/debug_box.py +11 -2
- 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 +10 -15
- mima/objects/world/color_switch.py +18 -28
- mima/objects/world/container.py +32 -37
- mima/objects/world/floor_switch.py +22 -28
- mima/objects/world/gate.py +21 -24
- 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 +63 -41
- mima/objects/world/pickup.py +81 -17
- mima/objects/world/switch.py +46 -35
- mima/objects/world/teleport.py +21 -22
- mima/scripts/commands/oneway_move.py +4 -3
- 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/constants.py +3 -3
- mima/util/input_defaults.py +12 -0
- mima/util/runtime_config.py +8 -15
- mima/util/trading_item.py +4 -1
- mima/view/mima_mode.py +8 -2
- mima/view/mima_scene.py +6 -0
- mima/view/mima_window.py +91 -0
- {mima_engine-0.2.2.dist-info → mima_engine-0.2.4.dist-info}/METADATA +4 -4
- {mima_engine-0.2.2.dist-info → mima_engine-0.2.4.dist-info}/RECORD +57 -53
- {mima_engine-0.2.2.dist-info → mima_engine-0.2.4.dist-info}/WHEEL +1 -1
- {mima_engine-0.2.2.dist-info → mima_engine-0.2.4.dist-info}/top_level.txt +0 -0
mima/objects/projectile.py
CHANGED
|
@@ -16,14 +16,24 @@ class Projectile(Dynamic):
|
|
|
16
16
|
self,
|
|
17
17
|
px: float,
|
|
18
18
|
py: float,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
name: str = "Projectile",
|
|
20
|
+
*,
|
|
21
|
+
sprite_name: str = "",
|
|
22
|
+
tilemap: Tilemap = None,
|
|
23
|
+
dyn_id: int = 1000,
|
|
24
|
+
vx: float = 0.0,
|
|
25
|
+
vy: float = 0.0,
|
|
21
26
|
duration: float,
|
|
22
27
|
alignment: Alignment,
|
|
23
|
-
tilemap: Tilemap = None,
|
|
24
|
-
name: str = "Projectile",
|
|
25
28
|
):
|
|
26
|
-
super().__init__(
|
|
29
|
+
super().__init__(
|
|
30
|
+
px,
|
|
31
|
+
py,
|
|
32
|
+
name,
|
|
33
|
+
sprite_name=sprite_name,
|
|
34
|
+
tilemap=tilemap,
|
|
35
|
+
dyn_id=dyn_id,
|
|
36
|
+
)
|
|
27
37
|
|
|
28
38
|
self.type = ObjectType.PROJECTILE
|
|
29
39
|
self.vx = vx
|
mima/objects/sprite.py
CHANGED
|
@@ -72,7 +72,13 @@ class Sprite:
|
|
|
72
72
|
self.last_direction = direction
|
|
73
73
|
self.last_graphic_state = graphic_state
|
|
74
74
|
|
|
75
|
-
def draw_self(
|
|
75
|
+
def draw_self(
|
|
76
|
+
self,
|
|
77
|
+
px: float,
|
|
78
|
+
py: float,
|
|
79
|
+
camera_name: str = "display",
|
|
80
|
+
draw_to_ui: bool = False,
|
|
81
|
+
):
|
|
76
82
|
if self.name == "":
|
|
77
83
|
return
|
|
78
84
|
|
|
@@ -102,6 +108,7 @@ class Sprite:
|
|
|
102
108
|
self.width,
|
|
103
109
|
self.height,
|
|
104
110
|
camera_name,
|
|
111
|
+
draw_to_ui=draw_to_ui,
|
|
105
112
|
)
|
|
106
113
|
|
|
107
114
|
def reset(self):
|
mima/objects/world/color_gate.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.direction import Direction
|
|
4
5
|
from ...types.gate_color import GateColor
|
|
5
6
|
from ...types.graphic_state import GraphicState
|
|
@@ -17,24 +18,20 @@ class ColorGate(Gate):
|
|
|
17
18
|
py: float,
|
|
18
19
|
name: str = "ColorGate",
|
|
19
20
|
*,
|
|
20
|
-
|
|
21
|
-
tilemap=None,
|
|
21
|
+
sprite_name: str = "",
|
|
22
|
+
tilemap: Optional[Tilemap] = None,
|
|
22
23
|
dyn_id: int = -1,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
graphic_state: GraphicState,
|
|
27
|
-
facing_direction: Direction,
|
|
24
|
+
graphic_state: GraphicState = GraphicState.STANDING,
|
|
25
|
+
facing_direction: Direction = Direction.SOUTH,
|
|
26
|
+
color: GateColor = GateColor.RED,
|
|
28
27
|
):
|
|
29
28
|
super().__init__(
|
|
30
29
|
px,
|
|
31
30
|
py,
|
|
32
31
|
name,
|
|
32
|
+
sprite_name=sprite_name,
|
|
33
33
|
tilemap=tilemap,
|
|
34
34
|
dyn_id=dyn_id,
|
|
35
|
-
tileset_name=tileset_name,
|
|
36
|
-
image_name=image_name,
|
|
37
|
-
sprite_name=sprite_name,
|
|
38
35
|
graphic_state=graphic_state,
|
|
39
36
|
facing_direction=facing_direction,
|
|
40
37
|
bombable=False,
|
|
@@ -54,9 +51,10 @@ class ColorGate(Gate):
|
|
|
54
51
|
gate = ColorGate(
|
|
55
52
|
px=px,
|
|
56
53
|
py=py,
|
|
57
|
-
|
|
58
|
-
image_name=obj.get_string("tileset_name"),
|
|
54
|
+
name=obj.name,
|
|
59
55
|
sprite_name=obj.get_string("sprite_name"),
|
|
56
|
+
tilemap=tilemap,
|
|
57
|
+
dyn_id=obj.object_id,
|
|
60
58
|
graphic_state=GraphicState[
|
|
61
59
|
obj.get_string("graphic_state", "closed").upper()
|
|
62
60
|
],
|
|
@@ -64,9 +62,6 @@ class ColorGate(Gate):
|
|
|
64
62
|
obj.get_string("facing_direction", "south").upper()
|
|
65
63
|
],
|
|
66
64
|
color=GateColor[obj.get_string("color", "red").upper()],
|
|
67
|
-
tilemap=tilemap,
|
|
68
|
-
dyn_id=obj.object_id,
|
|
69
|
-
name=obj.name,
|
|
70
65
|
)
|
|
71
66
|
|
|
72
67
|
return [gate]
|
|
@@ -19,29 +19,24 @@ class ColorSwitch(Switch):
|
|
|
19
19
|
self,
|
|
20
20
|
px: float,
|
|
21
21
|
py: float,
|
|
22
|
-
tileset_name: str,
|
|
23
|
-
image_name: str,
|
|
24
|
-
sprite_name: str,
|
|
25
|
-
facing_direction: Direction,
|
|
26
|
-
graphic_state: GraphicState,
|
|
27
|
-
color: GateColor,
|
|
28
|
-
initial_signal=True,
|
|
29
|
-
tilemap: Tilemap = None,
|
|
30
|
-
dyn_id=-1,
|
|
31
22
|
name="ColorSwitch",
|
|
23
|
+
*,
|
|
24
|
+
sprite_name: str = "",
|
|
25
|
+
tilemap: Optional[Tilemap] = None,
|
|
26
|
+
dyn_id=-1,
|
|
27
|
+
graphic_state: GraphicState = GraphicState.OPEN,
|
|
28
|
+
initial_signal=False,
|
|
29
|
+
color: GateColor = GateColor.RED,
|
|
32
30
|
):
|
|
33
31
|
super().__init__(
|
|
34
32
|
px,
|
|
35
33
|
py,
|
|
36
|
-
tileset_name,
|
|
37
|
-
image_name,
|
|
38
|
-
sprite_name,
|
|
39
|
-
facing_direction,
|
|
40
|
-
graphic_state,
|
|
41
|
-
initial_signal,
|
|
42
|
-
tilemap,
|
|
43
|
-
dyn_id,
|
|
44
34
|
name,
|
|
35
|
+
sprite_name=sprite_name,
|
|
36
|
+
tilemap=tilemap,
|
|
37
|
+
dyn_id=dyn_id,
|
|
38
|
+
graphic_state=graphic_state,
|
|
39
|
+
initial_signal=initial_signal,
|
|
45
40
|
)
|
|
46
41
|
self.type = ObjectType.COLOR_SWITCH
|
|
47
42
|
|
|
@@ -52,7 +47,7 @@ class ColorSwitch(Switch):
|
|
|
52
47
|
else GraphicState.OPEN
|
|
53
48
|
)
|
|
54
49
|
# self.signal = self.graphic_state == GraphicState.CLOSED
|
|
55
|
-
self.send_initial_signal = False
|
|
50
|
+
# self.send_initial_signal = False
|
|
56
51
|
|
|
57
52
|
def update(self, elapsed_time: float, target: Optional[Dynamic] = None):
|
|
58
53
|
self.graphic_state = (
|
|
@@ -89,23 +84,18 @@ class ColorSwitch(Switch):
|
|
|
89
84
|
switch = ColorSwitch(
|
|
90
85
|
px=px,
|
|
91
86
|
py=py,
|
|
92
|
-
|
|
93
|
-
image_name=obj.get_string("tileset_name"),
|
|
87
|
+
name=obj.name,
|
|
94
88
|
sprite_name=obj.get_string("sprite_name"),
|
|
89
|
+
tilemap=tilemap,
|
|
90
|
+
dyn_id=obj.object_id,
|
|
95
91
|
graphic_state=GraphicState[
|
|
96
92
|
obj.get_string("graphic_state", "closed").upper()
|
|
97
93
|
],
|
|
98
|
-
facing_direction=Direction[
|
|
99
|
-
obj.get_string("facing_direction", "south").upper()
|
|
100
|
-
],
|
|
101
94
|
color=GateColor[obj.get_string("color", "red").upper()],
|
|
102
95
|
initial_signal=False,
|
|
103
|
-
tilemap=tilemap,
|
|
104
|
-
dyn_id=obj.object_id,
|
|
105
|
-
name=obj.name,
|
|
106
96
|
)
|
|
107
97
|
|
|
108
|
-
switch.sprite.width = int(width * ColorSwitch.engine.rtc.tile_width)
|
|
109
|
-
switch.sprite.height = int(height * ColorSwitch.engine.rtc.tile_height)
|
|
98
|
+
# switch.sprite.width = int(width * ColorSwitch.engine.rtc.tile_width)
|
|
99
|
+
# switch.sprite.height = int(height * ColorSwitch.engine.rtc.tile_height)
|
|
110
100
|
|
|
111
101
|
return [switch]
|
mima/objects/world/container.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.give_item import CommandGiveItem
|
|
7
8
|
from ...scripts.commands.give_resource import CommandGiveResource
|
|
8
9
|
from ...scripts.commands.parallel import CommandParallel
|
|
@@ -23,39 +24,38 @@ class Container(Dynamic):
|
|
|
23
24
|
self,
|
|
24
25
|
px: float,
|
|
25
26
|
py: float,
|
|
26
|
-
tileset_name: str,
|
|
27
|
-
image_name: str,
|
|
28
|
-
sprite_name: str,
|
|
29
|
-
graphic_state: GraphicState,
|
|
30
|
-
facing_direction: Direction,
|
|
31
|
-
item_name: str,
|
|
32
|
-
tilemap=None,
|
|
33
|
-
dyn_id: int = -1,
|
|
34
27
|
name: str = "Container",
|
|
28
|
+
*,
|
|
29
|
+
sprite_name: str = "",
|
|
30
|
+
tilemap: Optional[Tilemap] = None,
|
|
31
|
+
dyn_id: int = -1,
|
|
32
|
+
graphic_state: GraphicState = GraphicState.CLOSED,
|
|
33
|
+
item_name: str = "",
|
|
35
34
|
):
|
|
36
|
-
|
|
35
|
+
if graphic_state not in [
|
|
37
36
|
GraphicState.OPEN,
|
|
38
37
|
GraphicState.CLOSED,
|
|
39
|
-
]
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
]:
|
|
39
|
+
msg = (
|
|
40
|
+
f"graphic_state of Container {name}{dyn_id} must be either "
|
|
41
|
+
f"'open' or 'closed', but it is {graphic_state}"
|
|
42
|
+
)
|
|
43
|
+
raise ValueError(msg)
|
|
44
|
+
super().__init__(
|
|
45
|
+
px,
|
|
46
|
+
py,
|
|
47
|
+
name,
|
|
48
|
+
tilemap=tilemap,
|
|
49
|
+
sprite_name=sprite_name,
|
|
50
|
+
dyn_id=dyn_id,
|
|
51
51
|
)
|
|
52
52
|
|
|
53
53
|
self.type = ObjectType.CONTAINER
|
|
54
54
|
self.graphic_state = graphic_state
|
|
55
|
-
self.facing_direction = facing_direction
|
|
56
55
|
self.closed: bool = self.graphic_state != GraphicState.OPEN
|
|
57
56
|
|
|
58
57
|
self.item_name: str = item_name
|
|
58
|
+
self.item = self.engine.get_item(item_name)
|
|
59
59
|
self.solid_vs_dyn: bool = True
|
|
60
60
|
self.solid_vs_map: bool = True
|
|
61
61
|
self.visible: bool = True
|
|
@@ -102,19 +102,19 @@ class Container(Dynamic):
|
|
|
102
102
|
if self.is_resource:
|
|
103
103
|
text = "You received "
|
|
104
104
|
if self.amount > 1:
|
|
105
|
-
text += f"{self.amount} {self.
|
|
105
|
+
text += f"{self.amount} {self.item.name}s!"
|
|
106
106
|
elif self.amount == 1:
|
|
107
|
-
text += f"one {self.
|
|
107
|
+
text += f"one {self.item.name}!"
|
|
108
108
|
else:
|
|
109
109
|
text += "nothing. The chest was empty!"
|
|
110
110
|
|
|
111
|
-
if self.item_name == "
|
|
111
|
+
if self.item_name == "coin":
|
|
112
112
|
cgr = CommandGiveResource(target, coins=self.amount)
|
|
113
|
-
elif self.item_name == "
|
|
113
|
+
elif self.item_name == "bomb_refill":
|
|
114
114
|
cgr = CommandGiveResource(target, bombs=self.amount)
|
|
115
|
-
elif self.item_name == "
|
|
115
|
+
elif self.item_name == "arrow_refill":
|
|
116
116
|
cgr = CommandGiveResource(target, arrows=self.amount)
|
|
117
|
-
elif self.item_name == "
|
|
117
|
+
elif self.item_name == "key":
|
|
118
118
|
cgr = CommandGiveResource(target, keys=self.amount)
|
|
119
119
|
else:
|
|
120
120
|
LOG.error(f"Invalid resource type: {self.item_name}")
|
|
@@ -138,7 +138,7 @@ class Container(Dynamic):
|
|
|
138
138
|
CommandParallel(
|
|
139
139
|
[
|
|
140
140
|
CommandShowDialog(
|
|
141
|
-
[f"You received {self.
|
|
141
|
+
[f"You received {self.item.name}"],
|
|
142
142
|
),
|
|
143
143
|
CommandPresentItem(self.item_name, target),
|
|
144
144
|
CommandGiveItem(self.item_name, target),
|
|
@@ -160,19 +160,14 @@ class Container(Dynamic):
|
|
|
160
160
|
container = Container(
|
|
161
161
|
px=px,
|
|
162
162
|
py=py,
|
|
163
|
-
|
|
164
|
-
image_name=obj.get_string("tileset_name"),
|
|
163
|
+
name=obj.name,
|
|
165
164
|
sprite_name=obj.get_string("sprite_name"),
|
|
165
|
+
tilemap=tilemap,
|
|
166
|
+
dyn_id=obj.object_id,
|
|
166
167
|
graphic_state=GraphicState[
|
|
167
168
|
obj.get_string("graphic_state", "closed").upper()
|
|
168
169
|
],
|
|
169
|
-
facing_direction=Direction[
|
|
170
|
-
obj.get_string("facing_direction", "south").upper()
|
|
171
|
-
],
|
|
172
170
|
item_name=obj.get_string("item_name"),
|
|
173
|
-
tilemap=tilemap,
|
|
174
|
-
dyn_id=obj.object_id,
|
|
175
|
-
name=obj.name,
|
|
176
171
|
)
|
|
177
172
|
container.is_resource = obj.get_bool("is_resource", False)
|
|
178
173
|
container.amount = obj.get_int("amount", 1)
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from ...maps.tilemap import Tilemap
|
|
1
4
|
from ...types.direction import Direction
|
|
2
5
|
from ...types.graphic_state import GraphicState
|
|
3
6
|
from ...types.nature import Nature
|
|
@@ -11,28 +14,23 @@ class FloorSwitch(Switch):
|
|
|
11
14
|
self,
|
|
12
15
|
px: float,
|
|
13
16
|
py: float,
|
|
14
|
-
tileset_name: str,
|
|
15
|
-
image_name: str,
|
|
16
|
-
sprite_name: str,
|
|
17
|
-
facing_direction: Direction,
|
|
18
|
-
graphic_state: GraphicState,
|
|
19
|
-
initial_signal=True,
|
|
20
|
-
tilemap=None,
|
|
21
|
-
dyn_id=-1,
|
|
22
17
|
name="Floor Switch",
|
|
18
|
+
*,
|
|
19
|
+
sprite_name: str = "",
|
|
20
|
+
tilemap: Optional[Tilemap] = None,
|
|
21
|
+
dyn_id: int = -1,
|
|
22
|
+
graphic_state: GraphicState = GraphicState.OPEN,
|
|
23
|
+
initial_signal: bool = True,
|
|
23
24
|
):
|
|
24
25
|
super().__init__(
|
|
25
26
|
px,
|
|
26
27
|
py,
|
|
27
|
-
tileset_name,
|
|
28
|
-
image_name,
|
|
29
|
-
sprite_name,
|
|
30
|
-
facing_direction,
|
|
31
|
-
graphic_state,
|
|
32
|
-
initial_signal,
|
|
33
|
-
tilemap,
|
|
34
|
-
dyn_id,
|
|
35
28
|
name,
|
|
29
|
+
sprite_name=sprite_name,
|
|
30
|
+
tilemap=tilemap,
|
|
31
|
+
dyn_id=dyn_id,
|
|
32
|
+
graphic_state=graphic_state,
|
|
33
|
+
initial_signal=initial_signal,
|
|
36
34
|
)
|
|
37
35
|
self.layer = 0
|
|
38
36
|
|
|
@@ -84,24 +82,20 @@ class FloorSwitch(Switch):
|
|
|
84
82
|
fswitch = FloorSwitch(
|
|
85
83
|
px=px,
|
|
86
84
|
py=py,
|
|
87
|
-
|
|
88
|
-
image_name=obj.get_string("tileset_name"),
|
|
85
|
+
name=obj.name,
|
|
89
86
|
sprite_name=obj.get_string("sprite_name"),
|
|
87
|
+
tilemap=tilemap,
|
|
88
|
+
dyn_id=obj.object_id,
|
|
90
89
|
graphic_state=GraphicState[
|
|
91
90
|
obj.get_string("graphic_state", "closed").upper()
|
|
92
91
|
],
|
|
93
|
-
facing_direction=Direction[
|
|
94
|
-
obj.get_string("facing_direction", "south").upper()
|
|
95
|
-
],
|
|
96
92
|
initial_signal=obj.get_bool("initial_signal", True),
|
|
97
|
-
tilemap=tilemap,
|
|
98
|
-
dyn_id=obj.object_id,
|
|
99
|
-
name=obj.name,
|
|
100
|
-
)
|
|
101
|
-
fswitch.sprite.width = int(width * FloorSwitch.engine.rtc.tile_width)
|
|
102
|
-
fswitch.sprite.height = int(
|
|
103
|
-
height * FloorSwitch.engine.rtc.tile_height
|
|
104
93
|
)
|
|
94
|
+
# TODO: Why was this used?
|
|
95
|
+
# fswitch.sprite.width = int(width * FloorSwitch.engine.rtc.tile_width)
|
|
96
|
+
# fswitch.sprite.height = int(
|
|
97
|
+
# height * FloorSwitch.engine.rtc.tile_height
|
|
98
|
+
# )
|
|
105
99
|
|
|
106
100
|
ctr = 1
|
|
107
101
|
while True:
|
mima/objects/world/gate.py
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from ...maps.tilemap import Tilemap
|
|
3
6
|
from ...types.damage import Damage
|
|
4
7
|
from ...types.direction import Direction
|
|
5
8
|
from ...types.graphic_state import GraphicState
|
|
@@ -17,13 +20,11 @@ class Gate(Dynamic):
|
|
|
17
20
|
py: float,
|
|
18
21
|
name: str = "Gate",
|
|
19
22
|
*,
|
|
20
|
-
|
|
23
|
+
sprite_name: str = "",
|
|
24
|
+
tilemap: Optional[Tilemap] = None,
|
|
21
25
|
dyn_id: int = 0,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
sprite_name: str,
|
|
25
|
-
graphic_state: GraphicState,
|
|
26
|
-
facing_direction: Direction,
|
|
26
|
+
graphic_state: GraphicState = GraphicState.STANDING,
|
|
27
|
+
facing_direction: Direction = Direction.SOUTH,
|
|
27
28
|
bombable: bool = False,
|
|
28
29
|
):
|
|
29
30
|
if graphic_state not in (
|
|
@@ -38,15 +39,15 @@ class Gate(Dynamic):
|
|
|
38
39
|
|
|
39
40
|
raise ValueError(msg)
|
|
40
41
|
|
|
41
|
-
super().__init__(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
sprite_name,
|
|
47
|
-
|
|
48
|
-
facing_direction,
|
|
42
|
+
super().__init__(
|
|
43
|
+
px,
|
|
44
|
+
py,
|
|
45
|
+
name,
|
|
46
|
+
tilemap=tilemap,
|
|
47
|
+
sprite_name=sprite_name,
|
|
48
|
+
dyn_id=dyn_id,
|
|
49
49
|
)
|
|
50
|
+
|
|
50
51
|
self.type = ObjectType.GATE
|
|
51
52
|
|
|
52
53
|
self.graphic_state = graphic_state
|
|
@@ -131,11 +132,9 @@ class Gate(Dynamic):
|
|
|
131
132
|
px=px,
|
|
132
133
|
py=py,
|
|
133
134
|
name=obj.name,
|
|
135
|
+
sprite_name=obj.get_string("sprite_name"),
|
|
134
136
|
tilemap=tilemap,
|
|
135
137
|
dyn_id=obj.object_id,
|
|
136
|
-
tileset_name=obj.get_string("tileset_name"),
|
|
137
|
-
image_name=obj.get_string("tileset_name"),
|
|
138
|
-
sprite_name=obj.get_string("sprite_name"),
|
|
139
138
|
graphic_state=GraphicState[
|
|
140
139
|
obj.get_string("graphic_state", "closed").upper()
|
|
141
140
|
],
|
|
@@ -153,11 +152,12 @@ class Gate(Dynamic):
|
|
|
153
152
|
py -= 0.1
|
|
154
153
|
|
|
155
154
|
teleport = Teleport(
|
|
156
|
-
px
|
|
157
|
-
py
|
|
158
|
-
|
|
159
|
-
image_name="",
|
|
155
|
+
px,
|
|
156
|
+
py,
|
|
157
|
+
f"Teleport of {gate[0].name}",
|
|
160
158
|
sprite_name="",
|
|
159
|
+
tilemap=tilemap,
|
|
160
|
+
dyn_id=gate[0].dyn_id + 2000,
|
|
161
161
|
dst_map_name=obj.get_string("target_map"),
|
|
162
162
|
dst_px=obj.get_float("target_px"),
|
|
163
163
|
dst_py=obj.get_float("target_py"),
|
|
@@ -168,9 +168,6 @@ class Gate(Dynamic):
|
|
|
168
168
|
relative=False,
|
|
169
169
|
sliding=False,
|
|
170
170
|
vertical=False,
|
|
171
|
-
tilemap=tilemap,
|
|
172
|
-
dyn_id=gate[0].dyn_id + 2000,
|
|
173
|
-
name=f"Teleport of {gate[0].name}",
|
|
174
171
|
)
|
|
175
172
|
|
|
176
173
|
teleport.visible = False
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from typing import Optional
|
|
2
2
|
|
|
3
|
+
from ...maps.tilemap import Tilemap
|
|
3
4
|
from ...types.direction import Direction
|
|
4
5
|
from ...types.graphic_state import GraphicState
|
|
5
6
|
from ...types.nature import Nature
|
|
@@ -15,33 +16,32 @@ class LightSource(Dynamic):
|
|
|
15
16
|
self,
|
|
16
17
|
px: float,
|
|
17
18
|
py: float,
|
|
18
|
-
tileset_name: str,
|
|
19
|
-
image_name: str,
|
|
20
|
-
sprite_name: str,
|
|
21
|
-
graphic_state: GraphicState,
|
|
22
|
-
facing_direction: Direction,
|
|
23
|
-
max_size: int,
|
|
24
|
-
tilemap=None,
|
|
25
|
-
dyn_id: int = -1,
|
|
26
19
|
name: str = "LightSource",
|
|
20
|
+
*,
|
|
21
|
+
sprite_name: str = "",
|
|
22
|
+
tilemap: Optional[Tilemap] = None,
|
|
23
|
+
dyn_id: int = -1,
|
|
24
|
+
graphic_state: GraphicState = GraphicState.ON,
|
|
25
|
+
max_size: int = 32,
|
|
27
26
|
):
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
if graphic_state not in [GraphicState.OFF, GraphicState.ON]:
|
|
28
|
+
msg = (
|
|
29
|
+
f"graphic_state of LightSource {name}{dyn_id} must be either "
|
|
30
|
+
f"'off' or 'on', but it is {graphic_state}"
|
|
31
|
+
)
|
|
32
|
+
raise ValueError(msg)
|
|
33
|
+
|
|
34
|
+
super().__init__(
|
|
35
|
+
px,
|
|
36
|
+
py,
|
|
37
|
+
name,
|
|
38
|
+
sprite_name=sprite_name,
|
|
39
|
+
tilemap=tilemap,
|
|
40
|
+
dyn_id=dyn_id,
|
|
40
41
|
)
|
|
41
42
|
|
|
42
43
|
self.type = ObjectType.LIGHT_SOURCE
|
|
43
44
|
self.graphic_state = graphic_state
|
|
44
|
-
self.facing_direction = facing_direction
|
|
45
45
|
self._max_size = max_size
|
|
46
46
|
self.active = self.graphic_state == GraphicState.ON
|
|
47
47
|
self._light: Optional[Projectile] = None
|
|
@@ -105,22 +105,17 @@ class LightSource(Dynamic):
|
|
|
105
105
|
light = LightSource(
|
|
106
106
|
px=px,
|
|
107
107
|
py=py,
|
|
108
|
-
|
|
109
|
-
image_name=obj.get_string("tileset_name"),
|
|
108
|
+
name=obj.name,
|
|
110
109
|
sprite_name=obj.get_string("sprite_name"),
|
|
110
|
+
tilemap=tilemap,
|
|
111
|
+
dyn_id=obj.object_id,
|
|
111
112
|
graphic_state=GraphicState[
|
|
112
|
-
obj.get_string("graphic_state", "
|
|
113
|
-
],
|
|
114
|
-
facing_direction=Direction[
|
|
115
|
-
obj.get_string("facing_direction", "south").upper()
|
|
113
|
+
obj.get_string("graphic_state", "on").upper()
|
|
116
114
|
],
|
|
117
115
|
max_size=obj.get_int("max_size", 32),
|
|
118
|
-
tilemap=tilemap,
|
|
119
|
-
dyn_id=obj.object_id,
|
|
120
|
-
name=obj.name,
|
|
121
116
|
)
|
|
122
117
|
|
|
123
|
-
light.sprite.width = int(width * LightSource.engine.rtc.tile_width)
|
|
124
|
-
light.sprite.height = int(height * LightSource.engine.rtc.tile_height)
|
|
118
|
+
# light.sprite.width = int(width * LightSource.engine.rtc.tile_width)
|
|
119
|
+
# light.sprite.height = int(height * LightSource.engine.rtc.tile_height)
|
|
125
120
|
|
|
126
121
|
return [light]
|
mima/objects/world/logic_gate.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from enum import Enum
|
|
2
2
|
from typing import List, Optional, Union
|
|
3
3
|
|
|
4
|
+
from ...maps.tilemap import Tilemap
|
|
4
5
|
from ...types.alignment import Alignment
|
|
5
6
|
from ...types.direction import Direction
|
|
6
7
|
from ...types.graphic_state import GraphicState
|
|
@@ -27,31 +28,26 @@ class LogicGate(Dynamic):
|
|
|
27
28
|
self,
|
|
28
29
|
px: float,
|
|
29
30
|
py: float,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
sprite_name: str,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
mode=LogicFunction.LOGIC_PASS,
|
|
36
|
-
initial_signal=False,
|
|
37
|
-
visible=False,
|
|
38
|
-
tilemap=None,
|
|
39
|
-
dyn_id=-1,
|
|
40
|
-
name="Logic Gate",
|
|
31
|
+
name: str = "Logic Gate",
|
|
32
|
+
*,
|
|
33
|
+
sprite_name: str = "",
|
|
34
|
+
tilemap: Optional[Tilemap] = None,
|
|
35
|
+
dyn_id: int = -1,
|
|
36
|
+
mode: LogicFunction = LogicFunction.LOGIC_PASS,
|
|
37
|
+
initial_signal: bool = False,
|
|
38
|
+
visible: bool = False,
|
|
41
39
|
):
|
|
42
|
-
super().__init__(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
facing_direction,
|
|
40
|
+
super().__init__(
|
|
41
|
+
px,
|
|
42
|
+
py,
|
|
43
|
+
name,
|
|
44
|
+
sprite_name=sprite_name,
|
|
45
|
+
tilemap=tilemap,
|
|
46
|
+
dyn_id=dyn_id,
|
|
50
47
|
)
|
|
48
|
+
|
|
51
49
|
self.type = ObjectType.LOGIC_GATE
|
|
52
50
|
self.alignment = Alignment.NEUTRAL
|
|
53
|
-
self.graphic_state = graphic_state
|
|
54
|
-
self.facing_direction = facing_direction
|
|
55
51
|
self.visible = visible
|
|
56
52
|
|
|
57
53
|
self.input_id1: int = -1
|
|
@@ -130,28 +126,25 @@ class LogicGate(Dynamic):
|
|
|
130
126
|
@staticmethod
|
|
131
127
|
def load_from_tiled_object(obj, px, py, width, height, tilemap):
|
|
132
128
|
logic = LogicGate(
|
|
133
|
-
px
|
|
134
|
-
py
|
|
135
|
-
|
|
136
|
-
image_name=obj.get_string("tileset_name"),
|
|
129
|
+
px,
|
|
130
|
+
py,
|
|
131
|
+
obj.name,
|
|
137
132
|
sprite_name=obj.get_string("sprite_name"),
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
],
|
|
141
|
-
facing_direction=Direction[
|
|
142
|
-
obj.get_string("facing_direction", "south").upper()
|
|
143
|
-
],
|
|
133
|
+
tilemap=tilemap,
|
|
134
|
+
dyn_id=obj.object_id,
|
|
144
135
|
mode=LogicFunction[obj.get_string("mode", "logic_pass").upper()],
|
|
145
136
|
initial_signal=obj.get_bool("initial_signal", False),
|
|
146
137
|
visible=obj.get_bool("visible", True),
|
|
147
|
-
tilemap=tilemap,
|
|
148
|
-
dyn_id=obj.object_id,
|
|
149
|
-
name=obj.name,
|
|
150
138
|
)
|
|
151
|
-
|
|
139
|
+
logic.facing_direction = Direction[
|
|
140
|
+
obj.get_string("facing_direction", "south").upper()
|
|
141
|
+
]
|
|
142
|
+
logic.graphic_state = GraphicState[
|
|
143
|
+
obj.get_string("graphic_state", "closed").upper()
|
|
144
|
+
]
|
|
152
145
|
# logic.send_initial_signal =
|
|
153
|
-
logic.sprite.width = int(width * LogicGate.engine.rtc.tile_width)
|
|
154
|
-
logic.sprite.height = int(height * LogicGate.engine.rtc.tile_height)
|
|
146
|
+
# logic.sprite.width = int(width * LogicGate.engine.rtc.tile_width)
|
|
147
|
+
# logic.sprite.height = int(height * LogicGate.engine.rtc.tile_height)
|
|
155
148
|
|
|
156
149
|
ctr = 1
|
|
157
150
|
while True:
|