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
|
@@ -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}")
|
|
@@ -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
|
|
@@ -15,34 +18,36 @@ class Gate(Dynamic):
|
|
|
15
18
|
self,
|
|
16
19
|
px: float,
|
|
17
20
|
py: float,
|
|
18
|
-
tileset_name: str,
|
|
19
|
-
image_name: str,
|
|
20
|
-
sprite_name: str,
|
|
21
|
-
graphic_state: GraphicState,
|
|
22
|
-
facing_direction: Direction,
|
|
23
|
-
bombable: bool = False,
|
|
24
|
-
tilemap=None,
|
|
25
|
-
dyn_id: int = 0,
|
|
26
21
|
name: str = "Gate",
|
|
22
|
+
*,
|
|
23
|
+
sprite_name: str = "",
|
|
24
|
+
tilemap: Optional[Tilemap] = None,
|
|
25
|
+
dyn_id: int = 0,
|
|
26
|
+
graphic_state: GraphicState = GraphicState.STANDING,
|
|
27
|
+
facing_direction: Direction = Direction.SOUTH,
|
|
28
|
+
bombable: bool = False,
|
|
27
29
|
):
|
|
28
|
-
|
|
30
|
+
if graphic_state not in (
|
|
29
31
|
GraphicState.OPEN,
|
|
30
32
|
GraphicState.CLOSED,
|
|
31
33
|
GraphicState.LOCKED,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
):
|
|
35
|
+
msg = (
|
|
36
|
+
f"graphic_state of Gate {name}{dyn_id} must be either 'open'"
|
|
37
|
+
f", 'closed', or 'locked', but it {graphic_state}"
|
|
38
|
+
)
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
raise ValueError(msg)
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
super().__init__(
|
|
43
|
+
px,
|
|
44
|
+
py,
|
|
45
|
+
name,
|
|
46
|
+
tilemap=tilemap,
|
|
47
|
+
sprite_name=sprite_name,
|
|
48
|
+
dyn_id=dyn_id,
|
|
45
49
|
)
|
|
50
|
+
|
|
46
51
|
self.type = ObjectType.GATE
|
|
47
52
|
|
|
48
53
|
self.graphic_state = graphic_state
|
|
@@ -126,9 +131,10 @@ class Gate(Dynamic):
|
|
|
126
131
|
Gate(
|
|
127
132
|
px=px,
|
|
128
133
|
py=py,
|
|
129
|
-
|
|
130
|
-
image_name=obj.get_string("tileset_name"),
|
|
134
|
+
name=obj.name,
|
|
131
135
|
sprite_name=obj.get_string("sprite_name"),
|
|
136
|
+
tilemap=tilemap,
|
|
137
|
+
dyn_id=obj.object_id,
|
|
132
138
|
graphic_state=GraphicState[
|
|
133
139
|
obj.get_string("graphic_state", "closed").upper()
|
|
134
140
|
],
|
|
@@ -136,9 +142,6 @@ class Gate(Dynamic):
|
|
|
136
142
|
obj.get_string("facing_direction", "south").upper()
|
|
137
143
|
],
|
|
138
144
|
bombable=obj.get_bool("bombable"),
|
|
139
|
-
tilemap=tilemap,
|
|
140
|
-
dyn_id=obj.object_id,
|
|
141
|
-
name=obj.name,
|
|
142
145
|
)
|
|
143
146
|
]
|
|
144
147
|
|
|
@@ -149,11 +152,12 @@ class Gate(Dynamic):
|
|
|
149
152
|
py -= 0.1
|
|
150
153
|
|
|
151
154
|
teleport = Teleport(
|
|
152
|
-
px
|
|
153
|
-
py
|
|
154
|
-
|
|
155
|
-
image_name="",
|
|
155
|
+
px,
|
|
156
|
+
py,
|
|
157
|
+
f"Teleport of {gate[0].name}",
|
|
156
158
|
sprite_name="",
|
|
159
|
+
tilemap=tilemap,
|
|
160
|
+
dyn_id=gate[0].dyn_id + 2000,
|
|
157
161
|
dst_map_name=obj.get_string("target_map"),
|
|
158
162
|
dst_px=obj.get_float("target_px"),
|
|
159
163
|
dst_py=obj.get_float("target_py"),
|
|
@@ -164,9 +168,6 @@ class Gate(Dynamic):
|
|
|
164
168
|
relative=False,
|
|
165
169
|
sliding=False,
|
|
166
170
|
vertical=False,
|
|
167
|
-
tilemap=tilemap,
|
|
168
|
-
dyn_id=gate[0].dyn_id + 2000,
|
|
169
|
-
name=f"Teleport of {gate[0].name}",
|
|
170
171
|
)
|
|
171
172
|
|
|
172
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:
|