mima-engine 0.4.0__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.
- mima/__init__.py +4 -0
- mima/backend/__init__.py +1 -0
- mima/backend/pygame_assets.py +401 -0
- mima/backend/pygame_audio.py +78 -0
- mima/backend/pygame_backend.py +603 -0
- mima/backend/pygame_camera.py +63 -0
- mima/backend/pygame_events.py +695 -0
- 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/core/collision.py +325 -0
- mima/core/database.py +58 -0
- mima/core/engine.py +367 -0
- mima/core/mode_engine.py +81 -0
- mima/core/scene_engine.py +81 -0
- mima/integrated/__init__.py +0 -0
- mima/integrated/entity.py +183 -0
- mima/integrated/layered_map.py +351 -0
- mima/integrated/sprite.py +156 -0
- mima/layered/__init__.py +0 -0
- mima/layered/assets.py +56 -0
- mima/layered/scene.py +415 -0
- mima/layered/shape.py +99 -0
- mima/layered/shaped_sprite.py +78 -0
- mima/layered/virtual_input.py +302 -0
- mima/maps/__init__.py +0 -0
- mima/maps/template.py +71 -0
- mima/maps/tile.py +20 -0
- mima/maps/tile_animation.py +7 -0
- mima/maps/tile_info.py +10 -0
- mima/maps/tile_layer.py +52 -0
- mima/maps/tiled/__init__.py +0 -0
- mima/maps/tiled/tiled_layer.py +48 -0
- mima/maps/tiled/tiled_map.py +95 -0
- mima/maps/tiled/tiled_object.py +79 -0
- mima/maps/tiled/tiled_objectgroup.py +25 -0
- mima/maps/tiled/tiled_template.py +49 -0
- mima/maps/tiled/tiled_tile.py +90 -0
- mima/maps/tiled/tiled_tileset.py +51 -0
- mima/maps/tilemap.py +216 -0
- mima/maps/tileset.py +39 -0
- mima/maps/tileset_info.py +9 -0
- mima/maps/transition_map.py +146 -0
- mima/objects/__init__.py +0 -0
- mima/objects/animated_sprite.py +217 -0
- mima/objects/attribute_effect.py +26 -0
- mima/objects/attributes.py +126 -0
- mima/objects/creature.py +384 -0
- mima/objects/dynamic.py +206 -0
- mima/objects/effects/__init__.py +0 -0
- mima/objects/effects/colorize_screen.py +60 -0
- mima/objects/effects/debug_box.py +133 -0
- mima/objects/effects/light.py +103 -0
- mima/objects/effects/show_sprite.py +50 -0
- mima/objects/effects/walking_on_grass.py +70 -0
- mima/objects/effects/walking_on_water.py +57 -0
- mima/objects/loader.py +111 -0
- mima/objects/projectile.py +111 -0
- mima/objects/sprite.py +116 -0
- mima/objects/world/__init__.py +0 -0
- mima/objects/world/color_gate.py +67 -0
- mima/objects/world/color_switch.py +101 -0
- mima/objects/world/container.py +175 -0
- mima/objects/world/floor_switch.py +109 -0
- mima/objects/world/gate.py +178 -0
- mima/objects/world/light_source.py +121 -0
- mima/objects/world/logic_gate.py +157 -0
- mima/objects/world/movable.py +399 -0
- mima/objects/world/oneway.py +195 -0
- mima/objects/world/pickup.py +157 -0
- mima/objects/world/switch.py +179 -0
- mima/objects/world/teleport.py +308 -0
- mima/py.typed +0 -0
- mima/scripts/__init__.py +2 -0
- mima/scripts/command.py +38 -0
- mima/scripts/commands/__init__.py +0 -0
- mima/scripts/commands/add_quest.py +19 -0
- mima/scripts/commands/change_map.py +34 -0
- mima/scripts/commands/close_dialog.py +9 -0
- mima/scripts/commands/equip_weapon.py +23 -0
- mima/scripts/commands/give_item.py +26 -0
- mima/scripts/commands/give_resource.py +51 -0
- mima/scripts/commands/move_map.py +152 -0
- mima/scripts/commands/move_to.py +49 -0
- mima/scripts/commands/oneway_move.py +58 -0
- mima/scripts/commands/parallel.py +66 -0
- mima/scripts/commands/play_sound.py +13 -0
- mima/scripts/commands/present_item.py +53 -0
- mima/scripts/commands/progress_quest.py +12 -0
- mima/scripts/commands/quit_game.py +8 -0
- mima/scripts/commands/save_game.py +14 -0
- mima/scripts/commands/screen_fade.py +83 -0
- mima/scripts/commands/serial.py +69 -0
- mima/scripts/commands/set_facing_direction.py +21 -0
- mima/scripts/commands/set_spawn_map.py +17 -0
- mima/scripts/commands/show_choices.py +52 -0
- mima/scripts/commands/show_dialog.py +118 -0
- mima/scripts/commands/take_coins.py +23 -0
- mima/scripts/script_processor.py +61 -0
- mima/standalone/__init__.py +0 -0
- mima/standalone/camera.py +153 -0
- mima/standalone/geometry.py +1318 -0
- mima/standalone/multicolumn_list.py +54 -0
- mima/standalone/pixel_font.py +84 -0
- mima/standalone/scripting.py +145 -0
- mima/standalone/spatial.py +186 -0
- mima/standalone/sprite.py +158 -0
- mima/standalone/tiled_map.py +1247 -0
- mima/standalone/transformed_view.py +433 -0
- mima/standalone/user_input.py +563 -0
- mima/states/__init__.py +0 -0
- mima/states/game_state.py +189 -0
- mima/states/memory.py +28 -0
- mima/states/quest.py +71 -0
- mima/types/__init__.py +0 -0
- mima/types/alignment.py +7 -0
- mima/types/blend.py +8 -0
- mima/types/damage.py +42 -0
- mima/types/direction.py +44 -0
- mima/types/gate_color.py +7 -0
- mima/types/graphic_state.py +23 -0
- mima/types/keys.py +64 -0
- mima/types/mode.py +9 -0
- mima/types/nature.py +12 -0
- mima/types/object.py +22 -0
- mima/types/player.py +9 -0
- mima/types/position.py +13 -0
- mima/types/start.py +7 -0
- mima/types/terrain.py +9 -0
- mima/types/tile_collision.py +11 -0
- mima/types/weapon_slot.py +6 -0
- mima/types/window.py +44 -0
- mima/usables/__init__.py +0 -0
- mima/usables/item.py +51 -0
- mima/usables/weapon.py +68 -0
- mima/util/__init__.py +1 -0
- mima/util/colors.py +50 -0
- mima/util/constants.py +55 -0
- mima/util/functions.py +38 -0
- mima/util/input_defaults.py +170 -0
- mima/util/logging.py +51 -0
- mima/util/property.py +8 -0
- mima/util/runtime_config.py +327 -0
- mima/util/trading_item.py +23 -0
- mima/view/__init__.py +0 -0
- mima/view/camera.py +192 -0
- mima/view/mima_mode.py +618 -0
- mima/view/mima_scene.py +231 -0
- mima/view/mima_view.py +12 -0
- mima/view/mima_window.py +244 -0
- mima_engine-0.4.0.dist-info/METADATA +47 -0
- mima_engine-0.4.0.dist-info/RECORD +153 -0
- mima_engine-0.4.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
import os
|
|
4
|
+
from os import PathLike
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any, Dict, Union
|
|
7
|
+
|
|
8
|
+
# from typing_extensions import overload
|
|
9
|
+
from ..util.constants import SAVE_FILE_NAME
|
|
10
|
+
from ..util.functions import strtobool
|
|
11
|
+
|
|
12
|
+
LOG = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class GameState:
|
|
16
|
+
def __init__(self, save_path: PathLike, state_name: str = "autosave.json"):
|
|
17
|
+
self.state_name = state_name
|
|
18
|
+
self._save_path = save_path
|
|
19
|
+
self._state: Dict[str, Any] = {}
|
|
20
|
+
|
|
21
|
+
def save_value(
|
|
22
|
+
self, key: str, value: Union[int, float, bool, str, dict, list]
|
|
23
|
+
):
|
|
24
|
+
parts = key.split("__")
|
|
25
|
+
state = self._state
|
|
26
|
+
for idx, part in enumerate(parts):
|
|
27
|
+
if idx < len(parts) - 1:
|
|
28
|
+
state = state.setdefault(part, {})
|
|
29
|
+
else:
|
|
30
|
+
state[part] = value
|
|
31
|
+
|
|
32
|
+
# @overload
|
|
33
|
+
# def load_value(
|
|
34
|
+
# self, key: str, default: str, astype: str | None
|
|
35
|
+
# ) -> str | None: ...
|
|
36
|
+
|
|
37
|
+
# @overload
|
|
38
|
+
# def load_value(
|
|
39
|
+
# self, key: str, default: int, astype: str | None
|
|
40
|
+
# ) -> int | None: ...
|
|
41
|
+
|
|
42
|
+
def load_value(
|
|
43
|
+
self,
|
|
44
|
+
key: str,
|
|
45
|
+
default: int | float | bool | str | dict | list | None = None,
|
|
46
|
+
astype: str | None = None,
|
|
47
|
+
) -> int | float | bool | str | dict | list | None:
|
|
48
|
+
parts = key.split("__")
|
|
49
|
+
state = self._state
|
|
50
|
+
for idx, part in enumerate(parts):
|
|
51
|
+
if idx >= len(parts) - 1:
|
|
52
|
+
# state = state.get(part)
|
|
53
|
+
if state is None:
|
|
54
|
+
return default
|
|
55
|
+
else:
|
|
56
|
+
state = state.get(part)
|
|
57
|
+
if state is None:
|
|
58
|
+
return default
|
|
59
|
+
if astype is not None:
|
|
60
|
+
return convert(state, astype)
|
|
61
|
+
return state
|
|
62
|
+
|
|
63
|
+
state = state.get(part)
|
|
64
|
+
|
|
65
|
+
def load_group(self, key: str, *more_keys: str):
|
|
66
|
+
data = self._state.get(key, {})
|
|
67
|
+
for key in more_keys:
|
|
68
|
+
data = data.get(key, {})
|
|
69
|
+
return data
|
|
70
|
+
|
|
71
|
+
def load_from_disk(self, autosave: bool = False):
|
|
72
|
+
# filename = self.filename
|
|
73
|
+
# if autosave:
|
|
74
|
+
# filename = os.path.join(self._save_path, "autosave.json")
|
|
75
|
+
# else:
|
|
76
|
+
filename = Path(self._save_path) / self.state_name
|
|
77
|
+
try:
|
|
78
|
+
with open(filename, "r") as fp:
|
|
79
|
+
self._state = json.load(fp)
|
|
80
|
+
except FileNotFoundError:
|
|
81
|
+
LOG.info("No saved state found!")
|
|
82
|
+
except json.decoder.JSONDecodeError:
|
|
83
|
+
LOG.info("No saved state found or state corrupted.")
|
|
84
|
+
|
|
85
|
+
if autosave:
|
|
86
|
+
self.state_name = self.load_value("savefile_name", "")
|
|
87
|
+
# if autosave:
|
|
88
|
+
# self.filename = os.path.join(
|
|
89
|
+
# os.path.split(filename)[0],
|
|
90
|
+
# f"{self._state['savefile_name']}.json",
|
|
91
|
+
# )
|
|
92
|
+
|
|
93
|
+
def save_to_disk(self, autosave: bool = False):
|
|
94
|
+
# filename = self.filename
|
|
95
|
+
if autosave:
|
|
96
|
+
filename = Path(self._save_path) / "autosave.json"
|
|
97
|
+
self.save_value("savefile_name", self.state_name)
|
|
98
|
+
self.save_value("player__pos_x", 5.0)
|
|
99
|
+
self.save_value("player__pos_y", 5.0)
|
|
100
|
+
self.save_value(
|
|
101
|
+
"player__map_name", self.load_value("player__spawn_map")
|
|
102
|
+
)
|
|
103
|
+
else:
|
|
104
|
+
if self.state_name == "autosave.json":
|
|
105
|
+
self.state_name = chose_filename(self._save_path)
|
|
106
|
+
self.save_value("savefile_name", self.state_name)
|
|
107
|
+
filename = Path(self._save_path) / self.state_name
|
|
108
|
+
self._state["savefile_name"] = self.state_name
|
|
109
|
+
|
|
110
|
+
# Auto save file will be removed after a successful save
|
|
111
|
+
try:
|
|
112
|
+
os.remove(Path(self._save_path) / "autosave.json")
|
|
113
|
+
except FileNotFoundError:
|
|
114
|
+
pass
|
|
115
|
+
|
|
116
|
+
with open(filename, "w") as fp:
|
|
117
|
+
json.dump(self._state, fp, sort_keys=False, indent=4)
|
|
118
|
+
|
|
119
|
+
def delete_keys(self, scope, keypart, exceptions):
|
|
120
|
+
k2d = []
|
|
121
|
+
for k in self._state[scope]:
|
|
122
|
+
if keypart in k and k not in exceptions:
|
|
123
|
+
k2d.append(k)
|
|
124
|
+
for k in k2d:
|
|
125
|
+
del self._state[scope][k]
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def chose_filename(save_path: PathLike):
|
|
129
|
+
|
|
130
|
+
files = os.listdir(save_path)
|
|
131
|
+
game_idx = 0
|
|
132
|
+
while True:
|
|
133
|
+
savegame = f"{SAVE_FILE_NAME}_{game_idx:03d}.json"
|
|
134
|
+
if savegame not in files:
|
|
135
|
+
return savegame
|
|
136
|
+
game_idx += 1
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def convert(value, astype):
|
|
140
|
+
if astype == "int":
|
|
141
|
+
try:
|
|
142
|
+
return int(value)
|
|
143
|
+
except TypeError:
|
|
144
|
+
return value
|
|
145
|
+
if astype == "float":
|
|
146
|
+
try:
|
|
147
|
+
return float(value)
|
|
148
|
+
except TypeError:
|
|
149
|
+
return value
|
|
150
|
+
if astype == "bool":
|
|
151
|
+
try:
|
|
152
|
+
return strtobool(value)
|
|
153
|
+
except AttributeError:
|
|
154
|
+
value
|
|
155
|
+
return value
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def load_saved_games(save_path, save_file_name):
|
|
159
|
+
os.makedirs(save_path, exist_ok=True)
|
|
160
|
+
all_games = {}
|
|
161
|
+
if not os.path.isdir(save_path):
|
|
162
|
+
LOG.warning(f"Save folder does not exist: {save_path}")
|
|
163
|
+
return all_games
|
|
164
|
+
|
|
165
|
+
files = os.listdir(save_path)
|
|
166
|
+
if not files:
|
|
167
|
+
LOG.info(f"No save files found at {save_path}")
|
|
168
|
+
return all_games
|
|
169
|
+
|
|
170
|
+
if "autosave.json" in files:
|
|
171
|
+
all_games["autosave.json"] = GameState(save_path)
|
|
172
|
+
all_games["autosave.json"].load_from_disk(autosave=True)
|
|
173
|
+
LOG.debug(
|
|
174
|
+
"Loading saved game from autosave.json (%s)",
|
|
175
|
+
all_games["autosave.json"].state_name,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
game_idx = 0
|
|
179
|
+
while True:
|
|
180
|
+
savegame = f"{save_file_name}_{game_idx:03d}.json"
|
|
181
|
+
if savegame in files:
|
|
182
|
+
all_games[savegame] = GameState(save_path, savegame)
|
|
183
|
+
all_games[savegame].load_from_disk()
|
|
184
|
+
LOG.debug(f"Loading saved game from {savegame}")
|
|
185
|
+
game_idx += 1
|
|
186
|
+
if game_idx >= len(files):
|
|
187
|
+
break
|
|
188
|
+
|
|
189
|
+
return all_games
|
mima/states/memory.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Any, Dict, List
|
|
4
|
+
|
|
5
|
+
from ..types.player import Player
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from ..objects.creature import Creature
|
|
9
|
+
from ..usables.item import Item
|
|
10
|
+
from .quest import Quest
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Memory:
|
|
14
|
+
def __init__(self):
|
|
15
|
+
self.player: Dict[Player, Creature] = {}
|
|
16
|
+
self.items: Dict[str, Any] = {}
|
|
17
|
+
self.quests: List[Quest] = []
|
|
18
|
+
self.teleport_active: Dict[Player, bool] = {p: False for p in Player}
|
|
19
|
+
self.dialog_active: Dict[Player, bool] = {p: False for p in Player}
|
|
20
|
+
self.script_active: Dict[Player, bool] = {p: False for p in Player}
|
|
21
|
+
self.player_collision_active: Dict[Player, bool] = {
|
|
22
|
+
p: False for p in Player
|
|
23
|
+
}
|
|
24
|
+
self.bag: Dict[Player, List[Item]] = {p: [] for p in Player}
|
|
25
|
+
self.map_name: Dict[Player, str] = {}
|
|
26
|
+
|
|
27
|
+
self.last_spawn_px: Dict[Player, float] = {p: 0.0 for p in Player}
|
|
28
|
+
self.last_spawn_py: Dict[Player, float] = {p: 0.0 for p in Player}
|
mima/states/quest.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, List
|
|
4
|
+
|
|
5
|
+
from ..util.functions import strtobool
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from ..engine.mima_engine import MimaEngine
|
|
9
|
+
from ..objects.dynamic import Dynamic
|
|
10
|
+
from ..types.nature import Nature
|
|
11
|
+
from ..types.player import Player
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Quest:
|
|
15
|
+
engine: MimaEngine
|
|
16
|
+
|
|
17
|
+
def __init__(self):
|
|
18
|
+
self.name: str = "Unnamed Quest"
|
|
19
|
+
self.accepted: bool = False
|
|
20
|
+
self.reward_unlocked: bool = False
|
|
21
|
+
self.reward_received: bool = False
|
|
22
|
+
self.completed: bool = False
|
|
23
|
+
self.state: int = 0
|
|
24
|
+
|
|
25
|
+
def on_interaction(self, target: Dynamic, nature: Nature, player: Player):
|
|
26
|
+
return False
|
|
27
|
+
|
|
28
|
+
def populate_dynamics(self, dynamics: List[Dynamic], map_name: str):
|
|
29
|
+
return False
|
|
30
|
+
|
|
31
|
+
def load_state(self):
|
|
32
|
+
state = self.engine.game_state.load_group("quest", self.name)
|
|
33
|
+
# key = f"quest__{self.name}__"
|
|
34
|
+
self.accepted = state.get("accepted", False)
|
|
35
|
+
self.reward_unlocked = state.get("reward_unlocked", False)
|
|
36
|
+
self.reward_received = state.get("reward_received", False)
|
|
37
|
+
self.completed = state.get("completed", False)
|
|
38
|
+
self.state = state.get("state", 0)
|
|
39
|
+
|
|
40
|
+
def save_state(self):
|
|
41
|
+
key = f"quest__{self.name}__"
|
|
42
|
+
self.clean_up()
|
|
43
|
+
self.engine.game_state.save_value(f"{key}accepted", self.accepted)
|
|
44
|
+
self.engine.game_state.save_value(f"{key}completed", self.completed)
|
|
45
|
+
self.engine.game_state.save_value(
|
|
46
|
+
f"{key}reward_received", self.reward_received
|
|
47
|
+
)
|
|
48
|
+
self.engine.game_state.save_value(
|
|
49
|
+
f"{key}reward_unlocked", self.reward_unlocked
|
|
50
|
+
)
|
|
51
|
+
self.engine.game_state.save_value(f"{key}state", self.state)
|
|
52
|
+
|
|
53
|
+
def clean_up(self):
|
|
54
|
+
if self.accepted is None or not isinstance(self.accepted, bool):
|
|
55
|
+
self.accepted = False
|
|
56
|
+
|
|
57
|
+
if self.completed is None or not isinstance(self.completed, bool):
|
|
58
|
+
self.completed = False
|
|
59
|
+
|
|
60
|
+
if self.reward_unlocked is None or not isinstance(
|
|
61
|
+
self.reward_unlocked, bool
|
|
62
|
+
):
|
|
63
|
+
self.reward_unlocked = False
|
|
64
|
+
|
|
65
|
+
if self.reward_received is None or not isinstance(
|
|
66
|
+
self.reward_received, bool
|
|
67
|
+
):
|
|
68
|
+
self.reward_received = False
|
|
69
|
+
|
|
70
|
+
if self.state is None or not isinstance(self.state, int):
|
|
71
|
+
self.state = 0
|
mima/types/__init__.py
ADDED
|
File without changes
|
mima/types/alignment.py
ADDED
mima/types/blend.py
ADDED
mima/types/damage.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Damage(Enum):
|
|
5
|
+
NO_DAMAGE = 0
|
|
6
|
+
BODY = 1
|
|
7
|
+
SLICING = 2
|
|
8
|
+
PIERCING = 3
|
|
9
|
+
HEAVY = 4
|
|
10
|
+
EXPLOSION = 5
|
|
11
|
+
MAGIC = 6
|
|
12
|
+
FIRE = 7
|
|
13
|
+
WATER = 8
|
|
14
|
+
WIND = 9
|
|
15
|
+
EARTH = 10
|
|
16
|
+
HEAL = 11
|
|
17
|
+
DARK = 12
|
|
18
|
+
FRONT = 13
|
|
19
|
+
SIDE = 14
|
|
20
|
+
BACK = 15
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
PHYSICAL = [
|
|
24
|
+
Damage.BODY,
|
|
25
|
+
Damage.SLICING,
|
|
26
|
+
Damage.PIERCING,
|
|
27
|
+
Damage.HEAVY,
|
|
28
|
+
Damage.EXPLOSION,
|
|
29
|
+
Damage.FRONT,
|
|
30
|
+
Damage.SIDE,
|
|
31
|
+
Damage.BACK,
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
MAGICAL = [
|
|
35
|
+
Damage.MAGIC,
|
|
36
|
+
Damage.FIRE,
|
|
37
|
+
Damage.WATER,
|
|
38
|
+
Damage.WIND,
|
|
39
|
+
Damage.EARTH,
|
|
40
|
+
Damage.HEAL,
|
|
41
|
+
Damage.DARK,
|
|
42
|
+
]
|
mima/types/direction.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Tuple
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Direction(Enum):
|
|
8
|
+
SOUTH = 0
|
|
9
|
+
WEST = 1
|
|
10
|
+
NORTH = 2
|
|
11
|
+
EAST = 3
|
|
12
|
+
|
|
13
|
+
def from_velocity(vx: float, vy: float):
|
|
14
|
+
direction = None
|
|
15
|
+
if abs(vx) >= abs(vy):
|
|
16
|
+
if vx > 0:
|
|
17
|
+
direction = Direction.EAST
|
|
18
|
+
elif vx < 0:
|
|
19
|
+
direction = Direction.WEST
|
|
20
|
+
else:
|
|
21
|
+
# TODO: Check for up and down
|
|
22
|
+
pass
|
|
23
|
+
elif abs(vx) < abs(vy):
|
|
24
|
+
if vy > 0:
|
|
25
|
+
direction = Direction.SOUTH
|
|
26
|
+
elif vy < 0:
|
|
27
|
+
direction = Direction.NORTH
|
|
28
|
+
else:
|
|
29
|
+
# TODO: Check for left and right
|
|
30
|
+
pass
|
|
31
|
+
return direction
|
|
32
|
+
|
|
33
|
+
def to_velocity(direction: Direction) -> Tuple[int, int]:
|
|
34
|
+
vx = vy = 0
|
|
35
|
+
|
|
36
|
+
if direction == Direction.SOUTH:
|
|
37
|
+
vy = 1
|
|
38
|
+
elif direction == Direction.EAST:
|
|
39
|
+
vx = 1
|
|
40
|
+
elif direction == Direction.NORTH:
|
|
41
|
+
vy = -1
|
|
42
|
+
elif direction == Direction.WEST:
|
|
43
|
+
vx = -1
|
|
44
|
+
return vx, vy
|
mima/types/gate_color.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class GraphicState(Enum):
|
|
5
|
+
STANDING = 0
|
|
6
|
+
WALKING = 1
|
|
7
|
+
ATTACKING = 2
|
|
8
|
+
DAMAGED = 3
|
|
9
|
+
CELEBRATING = 4
|
|
10
|
+
DEAD = 5
|
|
11
|
+
DEFEATED = 6
|
|
12
|
+
PUSHING = 7
|
|
13
|
+
OPEN = 8
|
|
14
|
+
CLOSED = 9
|
|
15
|
+
LOCKED = 10
|
|
16
|
+
OFF = 11
|
|
17
|
+
ON = 12
|
|
18
|
+
ICON = 13
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Until(Enum):
|
|
22
|
+
UNLOCK = 0
|
|
23
|
+
NEXT_UPDATE = 1
|
mima/types/keys.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Key(Enum):
|
|
5
|
+
UP = 0
|
|
6
|
+
DOWN = 1
|
|
7
|
+
LEFT = 2
|
|
8
|
+
RIGHT = 3
|
|
9
|
+
A = 4
|
|
10
|
+
B = 5
|
|
11
|
+
X = 6
|
|
12
|
+
Y = 7
|
|
13
|
+
R = 8
|
|
14
|
+
L = 9
|
|
15
|
+
START = 10
|
|
16
|
+
SELECT = 11
|
|
17
|
+
P1_UP = 12
|
|
18
|
+
P1_DOWN = 13
|
|
19
|
+
P1_LEFT = 14
|
|
20
|
+
P1_RIGHT = 15
|
|
21
|
+
P1_A = 16
|
|
22
|
+
P1_B = 17
|
|
23
|
+
P1_X = 18
|
|
24
|
+
P1_Y = 19
|
|
25
|
+
P1_R = 20
|
|
26
|
+
P1_L = 21
|
|
27
|
+
P1_START = 22
|
|
28
|
+
P1_SELECT = 23
|
|
29
|
+
P2_UP = 24
|
|
30
|
+
P2_DOWN = 25
|
|
31
|
+
P2_LEFT = 26
|
|
32
|
+
P2_RIGHT = 27
|
|
33
|
+
P2_A = 28
|
|
34
|
+
P2_B = 29
|
|
35
|
+
P2_X = 30
|
|
36
|
+
P2_Y = 31
|
|
37
|
+
P2_R = 32
|
|
38
|
+
P2_L = 33
|
|
39
|
+
P2_START = 34
|
|
40
|
+
P2_SELECT = 35
|
|
41
|
+
P3_UP = 36
|
|
42
|
+
P3_DOWN = 37
|
|
43
|
+
P3_LEFT = 38
|
|
44
|
+
P3_RIGHT = 39
|
|
45
|
+
P3_A = 40
|
|
46
|
+
P3_B = 41
|
|
47
|
+
P3_X = 42
|
|
48
|
+
P3_Y = 43
|
|
49
|
+
P3_R = 44
|
|
50
|
+
P3_L = 45
|
|
51
|
+
P3_START = 46
|
|
52
|
+
P3_SELECT = 47
|
|
53
|
+
P4_UP = 48
|
|
54
|
+
P4_DOWN = 49
|
|
55
|
+
P4_LEFT = 50
|
|
56
|
+
P4_RIGHT = 51
|
|
57
|
+
P4_A = 52
|
|
58
|
+
P4_B = 53
|
|
59
|
+
P4_X = 54
|
|
60
|
+
P4_Y = 55
|
|
61
|
+
P4_R = 56
|
|
62
|
+
P4_L = 57
|
|
63
|
+
P4_START = 58
|
|
64
|
+
P4_SELECT = 59
|
mima/types/mode.py
ADDED
mima/types/nature.py
ADDED
mima/types/object.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ObjectType(Enum):
|
|
5
|
+
UNDEFINED = -1
|
|
6
|
+
PLAYER = 0
|
|
7
|
+
DYNAMIC = 1
|
|
8
|
+
PROJECTILE = 2
|
|
9
|
+
CREATURE = 3
|
|
10
|
+
SCRIPTED_CREATURE = 4
|
|
11
|
+
TELEPORT = 5
|
|
12
|
+
PICKUP = 6
|
|
13
|
+
MOVABLE = 7
|
|
14
|
+
GATE = 8
|
|
15
|
+
CONTAINER = 9
|
|
16
|
+
SWITCH = 10
|
|
17
|
+
FLOOR_SWITCH = 11
|
|
18
|
+
ONEWAY = 12
|
|
19
|
+
LOGIC_GATE = 13
|
|
20
|
+
LIGHT_SOURCE = 14
|
|
21
|
+
COLOR_SWITCH = 15
|
|
22
|
+
COLOR_GATE = 16
|
mima/types/player.py
ADDED
mima/types/position.py
ADDED
mima/types/start.py
ADDED
mima/types/terrain.py
ADDED
mima/types/window.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Window(Enum):
|
|
5
|
+
PLACEHOLDER = -1
|
|
6
|
+
LOADING = 0
|
|
7
|
+
TITLE = 1
|
|
8
|
+
SELECT_GAME = 2
|
|
9
|
+
SETTINGS = 3
|
|
10
|
+
CONTROLS = 4
|
|
11
|
+
TOP_DOWN_MAP_1 = 5
|
|
12
|
+
TOP_DOWN_MAP_2 = 6
|
|
13
|
+
TOP_DOWN_MAP_3 = 7
|
|
14
|
+
SIDE_MAP_1 = 8
|
|
15
|
+
SIDE_MAP_2 = 9
|
|
16
|
+
SIDE_MAP_3 = 10
|
|
17
|
+
WORLD_MAP_1 = 11
|
|
18
|
+
WORLD_MAP_2 = 12
|
|
19
|
+
WORLD_MAP_3 = 13
|
|
20
|
+
INVENTORY_START = 14
|
|
21
|
+
INVENTORY_STATUS = 15
|
|
22
|
+
INVENTORY_ITEMS = 16
|
|
23
|
+
INVENTORY_EQUIPMENT = 17
|
|
24
|
+
INVENTORY_MAGIC = 18
|
|
25
|
+
INVENTORY_SKILLS = 19
|
|
26
|
+
INVENTORY_QUESTS = 20
|
|
27
|
+
INVENTORY_PROGRESS = 21
|
|
28
|
+
COMBAT = 22
|
|
29
|
+
TEAM_ACTION = 23
|
|
30
|
+
CHANGE_POSITION = 24
|
|
31
|
+
ESCAPCE = 25
|
|
32
|
+
CHARACTER_ACTION = 26
|
|
33
|
+
ITEM_SELECT = 27
|
|
34
|
+
MAGIC_SELECT = 28
|
|
35
|
+
SPECIAL_SELECT = 29
|
|
36
|
+
TARGET_SELECT = 30
|
|
37
|
+
OPPONENTS = 31
|
|
38
|
+
THEATRE = 32
|
|
39
|
+
VICTORY = 33
|
|
40
|
+
SHOP = 34
|
|
41
|
+
GAME_OVER = 35
|
|
42
|
+
CONTROLS_1 = 36
|
|
43
|
+
CONTROLS_2 = 37
|
|
44
|
+
CONTROLS_3 = 38
|
mima/usables/__init__.py
ADDED
|
File without changes
|