mima-engine 0.2.2__tar.gz → 0.2.3__tar.gz
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_engine-0.2.2 → mima_engine-0.2.3}/PKG-INFO +1 -1
- mima_engine-0.2.3/src/mima/__init__.py +4 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/backend/pygame_assets.py +67 -9
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/backend/pygame_backend.py +5 -2
- {mima_engine-0.2.2/src/mima/maps → mima_engine-0.2.3/src/mima/core}/__init__.py +0 -0
- {mima_engine-0.2.2/src/mima → mima_engine-0.2.3/src/mima/core}/collision.py +11 -17
- mima_engine-0.2.3/src/mima/core/database.py +58 -0
- {mima_engine-0.2.2/src/mima → mima_engine-0.2.3/src/mima/core}/engine.py +51 -45
- {mima_engine-0.2.2/src/mima → mima_engine-0.2.3/src/mima/core}/mode_engine.py +8 -12
- {mima_engine-0.2.2/src/mima → mima_engine-0.2.3/src/mima/core}/scene_engine.py +3 -7
- mima_engine-0.2.3/src/mima/maps/template.py +71 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/tiled/tiled_object.py +1 -1
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/tiled/tiled_tileset.py +10 -5
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/tilemap.py +4 -10
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/tileset.py +5 -4
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/animated_sprite.py +79 -68
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/creature.py +14 -7
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/dynamic.py +3 -1
- {mima_engine-0.2.2/src/mima/objects/world → mima_engine-0.2.3/src/mima/objects/effects}/__init__.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/effects/colorize_screen.py +9 -1
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/effects/light.py +6 -1
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/effects/show_sprite.py +17 -6
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/effects/walking_on_grass.py +27 -13
- mima_engine-0.2.3/src/mima/objects/effects/walking_on_water.py +57 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/loader.py +6 -9
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/projectile.py +15 -5
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/sprite.py +8 -1
- {mima_engine-0.2.2/src/mima/scripts/commands → mima_engine-0.2.3/src/mima/objects/world}/__init__.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/world/color_gate.py +10 -15
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/world/color_switch.py +18 -28
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/world/container.py +31 -36
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/world/floor_switch.py +22 -28
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/world/gate.py +21 -24
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/world/light_source.py +27 -32
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/world/logic_gate.py +30 -37
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/world/movable.py +106 -89
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/world/oneway.py +29 -33
- mima_engine-0.2.3/src/mima/objects/world/pickup.py +151 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/world/switch.py +26 -31
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/world/teleport.py +21 -22
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/present_item.py +10 -10
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/graphic_state.py +1 -0
- mima_engine-0.2.3/src/mima/usables/item.py +51 -0
- mima_engine-0.2.3/src/mima/usables/weapon.py +68 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/util/runtime_config.py +8 -15
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/util/trading_item.py +4 -1
- mima_engine-0.2.3/src/mima/view/__init__.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/view/mima_mode.py +19 -54
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima_engine.egg-info/PKG-INFO +1 -1
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima_engine.egg-info/SOURCES.txt +6 -4
- mima_engine-0.2.2/src/mima/__init__.py +0 -1
- mima_engine-0.2.2/src/mima/maps/template.py +0 -41
- mima_engine-0.2.2/src/mima/objects/effects/walking_on_water.py +0 -52
- mima_engine-0.2.2/src/mima/objects/world/pickup.py +0 -93
- mima_engine-0.2.2/src/mima/usables/item.py +0 -32
- mima_engine-0.2.2/src/mima/usables/weapon.py +0 -48
- {mima_engine-0.2.2 → mima_engine-0.2.3}/README.md +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/pyproject.toml +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/setup.cfg +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/backend/__init__.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/backend/pygame_audio.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/backend/pygame_camera.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/backend/pygame_events.py +0 -0
- {mima_engine-0.2.2/src/mima/maps/tiled → mima_engine-0.2.3/src/mima/maps}/__init__.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/tile.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/tile_animation.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/tile_info.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/tile_layer.py +0 -0
- {mima_engine-0.2.2/src/mima/objects → mima_engine-0.2.3/src/mima/maps/tiled}/__init__.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/tiled/tiled_layer.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/tiled/tiled_map.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/tiled/tiled_objectgroup.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/tiled/tiled_template.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/tiled/tiled_tile.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/tileset_info.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/maps/transition_map.py +0 -0
- {mima_engine-0.2.2/src/mima/objects/effects → mima_engine-0.2.3/src/mima/objects}/__init__.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/attribute_effect.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/attributes.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/objects/effects/debug_box.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/__init__.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/command.py +0 -0
- {mima_engine-0.2.2/src/mima/states → mima_engine-0.2.3/src/mima/scripts/commands}/__init__.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/add_quest.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/change_map.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/close_dialog.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/equip_weapon.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/give_item.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/give_resource.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/move_map.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/move_to.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/oneway_move.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/parallel.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/play_sound.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/progress_quest.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/quit_game.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/save_game.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/screen_fade.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/serial.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/set_facing_direction.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/set_spawn_map.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/show_choices.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/show_dialog.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/commands/take_coins.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/scripts/script_processor.py +0 -0
- {mima_engine-0.2.2/src/mima/types → mima_engine-0.2.3/src/mima/states}/__init__.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/states/game_state.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/states/memory.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/states/quest.py +0 -0
- {mima_engine-0.2.2/src/mima/usables → mima_engine-0.2.3/src/mima/types}/__init__.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/alignment.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/blend.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/damage.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/direction.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/gate_color.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/keys.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/mode.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/nature.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/object.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/player.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/position.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/start.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/terrain.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/tile_collision.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/weapon_slot.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/types/window.py +0 -0
- {mima_engine-0.2.2/src/mima/view → mima_engine-0.2.3/src/mima/usables}/__init__.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/util/__init__.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/util/colors.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/util/constants.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/util/functions.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/util/input_defaults.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/util/logging.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/util/property.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/view/camera.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/view/mima_scene.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/view/mima_view.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima/view/mima_window.py +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima_engine.egg-info/dependency_links.txt +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima_engine.egg-info/requires.txt +0 -0
- {mima_engine-0.2.2 → mima_engine-0.2.3}/src/mima_engine.egg-info/top_level.txt +0 -0
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import csv
|
|
4
4
|
import logging
|
|
5
5
|
import os
|
|
6
|
-
from typing import TYPE_CHECKING, Dict, Optional
|
|
6
|
+
from typing import TYPE_CHECKING, Any, Dict, Optional
|
|
7
7
|
|
|
8
8
|
import pygame
|
|
9
9
|
|
|
@@ -21,9 +21,10 @@ LOG = logging.getLogger(__name__)
|
|
|
21
21
|
class PygameAssets:
|
|
22
22
|
def __init__(self, rtc: RuntimeConfig, init_file: str):
|
|
23
23
|
self.rtc = rtc
|
|
24
|
-
self.
|
|
24
|
+
self._images: Dict[str, pygame.Surface] = {}
|
|
25
25
|
self._tilesets: Dict[str, TiledTileset] = {}
|
|
26
26
|
self._templates: Dict[str, TiledTemplate] = {}
|
|
27
|
+
self._sprite_sheets: Dict[str, Dict[Any]] = {}
|
|
27
28
|
self._maps: Dict[str, TiledMap] = {}
|
|
28
29
|
self._music: Dict[str, str] = {}
|
|
29
30
|
self._sound: Dict[str, str] = {}
|
|
@@ -145,17 +146,17 @@ class PygameAssets:
|
|
|
145
146
|
# print(name, filename)
|
|
146
147
|
|
|
147
148
|
possible_name = os.path.split(filename)[-1][:-4]
|
|
148
|
-
if possible_name in self.
|
|
149
|
+
if possible_name in self._images:
|
|
149
150
|
LOG.warning(
|
|
150
151
|
"Sprite '%s' is possibly already loaded with name %s.",
|
|
151
152
|
filename,
|
|
152
153
|
possible_name,
|
|
153
154
|
)
|
|
154
|
-
elif name in self.
|
|
155
|
+
elif name in self._images:
|
|
155
156
|
LOG.debug("Sprite '%s' already loaded. Skipping.")
|
|
156
157
|
return name
|
|
157
158
|
|
|
158
|
-
self.
|
|
159
|
+
self._images[name] = self._load_sprite_from_disk(filename)
|
|
159
160
|
|
|
160
161
|
return name
|
|
161
162
|
|
|
@@ -182,7 +183,59 @@ class PygameAssets:
|
|
|
182
183
|
elif name in self._tilesets:
|
|
183
184
|
LOG.debug("Tileset at '%s' already loaded. Skipping", filename)
|
|
184
185
|
return name
|
|
185
|
-
|
|
186
|
+
ts = TiledTileset(name, filename)
|
|
187
|
+
self._tilesets[name] = ts
|
|
188
|
+
|
|
189
|
+
# Load sprite sheets
|
|
190
|
+
for tile in ts.tiles:
|
|
191
|
+
if not tile.sprite_name:
|
|
192
|
+
continue
|
|
193
|
+
|
|
194
|
+
self._sprite_sheets.setdefault(tile.sprite_name, {})
|
|
195
|
+
data = {
|
|
196
|
+
"duration": [],
|
|
197
|
+
"ox": [],
|
|
198
|
+
"oy": [],
|
|
199
|
+
"image": [],
|
|
200
|
+
"width": [],
|
|
201
|
+
"height": [],
|
|
202
|
+
}
|
|
203
|
+
if tile.animated:
|
|
204
|
+
for frame in tile._frames:
|
|
205
|
+
data["duration"].append(frame.duration)
|
|
206
|
+
data["ox"].append(frame.frame_id % ts.columns)
|
|
207
|
+
data["oy"].append(frame.frame_id // ts.columns)
|
|
208
|
+
data["image"].append(ts.image_name)
|
|
209
|
+
data["width"].append(ts.tile_width)
|
|
210
|
+
data["height"].append(ts.tile_height)
|
|
211
|
+
else:
|
|
212
|
+
data["duration"].append(1000)
|
|
213
|
+
data["ox"].append(tile.tile_id % ts.columns)
|
|
214
|
+
data["oy"].append(tile.tile_id // ts.columns)
|
|
215
|
+
data["image"].append(ts.image_name)
|
|
216
|
+
data["width"].append(ts.tile_width)
|
|
217
|
+
data["height"].append(ts.tile_height)
|
|
218
|
+
|
|
219
|
+
self._sprite_sheets[tile.sprite_name].setdefault(
|
|
220
|
+
tile.graphic_state, {}
|
|
221
|
+
)
|
|
222
|
+
self._sprite_sheets[tile.sprite_name][tile.graphic_state][
|
|
223
|
+
tile.facing_direction
|
|
224
|
+
] = data
|
|
225
|
+
LOG.debug(
|
|
226
|
+
"%s",
|
|
227
|
+
{
|
|
228
|
+
"operation": "add frames",
|
|
229
|
+
"image": ts.image_name,
|
|
230
|
+
"sprite": tile.sprite_name,
|
|
231
|
+
"graphic_state": tile.graphic_state.name,
|
|
232
|
+
"direction": tile.facing_direction.name,
|
|
233
|
+
"frame_data": data,
|
|
234
|
+
},
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
# for sprite_name in ts.sprite_names:
|
|
238
|
+
# self._sprites[sprite_name] = {}
|
|
186
239
|
return name
|
|
187
240
|
|
|
188
241
|
def _load_template(self, name, filename=None):
|
|
@@ -191,7 +244,7 @@ class PygameAssets:
|
|
|
191
244
|
|
|
192
245
|
if not os.path.isfile(filename):
|
|
193
246
|
filename = os.path.join(
|
|
194
|
-
self.
|
|
247
|
+
self.data_path, "templates", os.path.split(filename)[-1]
|
|
195
248
|
)
|
|
196
249
|
|
|
197
250
|
possible_name = os.path.split(filename)[-1][:-3]
|
|
@@ -287,13 +340,18 @@ class PygameAssets:
|
|
|
287
340
|
name_color = f"{name}_color"
|
|
288
341
|
else:
|
|
289
342
|
name_color = name
|
|
290
|
-
return self.
|
|
343
|
+
return self._images.get(name_color, self._images[name])
|
|
344
|
+
|
|
345
|
+
def get_sprite_data(self, sprite_id):
|
|
346
|
+
if not sprite_id:
|
|
347
|
+
return {}
|
|
348
|
+
return self._sprite_sheets[sprite_id]
|
|
291
349
|
|
|
292
350
|
def new_map(self, name, tilemap: Tilemap):
|
|
293
351
|
self._maps[name] = tilemap
|
|
294
352
|
|
|
295
353
|
def new_sprite(self, name, surface: pygame.Surface):
|
|
296
|
-
self.
|
|
354
|
+
self._images[name] = surface
|
|
297
355
|
|
|
298
356
|
def get_tileset(self, name):
|
|
299
357
|
if name not in self._tilesets:
|
|
@@ -464,8 +464,11 @@ class PygameBackend:
|
|
|
464
464
|
)
|
|
465
465
|
idx += 1
|
|
466
466
|
|
|
467
|
-
def draw_pixel(
|
|
468
|
-
self
|
|
467
|
+
def draw_pixel(
|
|
468
|
+
self, px: float, py: float, color: Color, camera_name=C_DISPLAY
|
|
469
|
+
):
|
|
470
|
+
display = self._cameras[camera_name].view
|
|
471
|
+
display.set_at((int(px), int(py)), color.getRGB())
|
|
469
472
|
|
|
470
473
|
def draw_camera(self, name, px, py, scale):
|
|
471
474
|
self.display.blit(
|
|
File without changes
|
|
@@ -3,17 +3,17 @@ from __future__ import annotations
|
|
|
3
3
|
import math
|
|
4
4
|
from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple
|
|
5
5
|
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from
|
|
6
|
+
from ..maps.tilemap import Tilemap
|
|
7
|
+
from ..types.direction import Direction
|
|
8
|
+
from ..types.graphic_state import GraphicState, Until
|
|
9
|
+
from ..types.nature import Nature
|
|
10
|
+
from ..types.object import ObjectType
|
|
11
|
+
from ..types.tile_collision import TileCollision
|
|
12
12
|
|
|
13
13
|
if TYPE_CHECKING:
|
|
14
14
|
# from .engine import MimaEngine
|
|
15
|
-
from
|
|
16
|
-
from
|
|
15
|
+
from ..objects.dynamic import Dynamic
|
|
16
|
+
from ..states.quest import Quest
|
|
17
17
|
|
|
18
18
|
# from .view.view import View
|
|
19
19
|
|
|
@@ -35,9 +35,7 @@ def check_object_to_map_collision(
|
|
|
35
35
|
|
|
36
36
|
collided_with_map = False
|
|
37
37
|
if obj.solid_vs_map:
|
|
38
|
-
if collision_with_map(
|
|
39
|
-
tilemap, left, right, top, bottom, layer, collision
|
|
40
|
-
):
|
|
38
|
+
if collision_with_map(tilemap, left, right, top, bottom, layer, collision):
|
|
41
39
|
# On rare occasions, the object might be pushed towards
|
|
42
40
|
# the wall, i.e. old and new pos are equal
|
|
43
41
|
# Decide depending on the decimal part of the position
|
|
@@ -68,9 +66,7 @@ def check_object_to_map_collision(
|
|
|
68
66
|
top = new_py + obj.hitbox_py
|
|
69
67
|
bottom = top + obj.hitbox_height
|
|
70
68
|
|
|
71
|
-
if collision_with_map(
|
|
72
|
-
tilemap, left, right, top, bottom, layer, collision
|
|
73
|
-
):
|
|
69
|
+
if collision_with_map(tilemap, left, right, top, bottom, layer, collision):
|
|
74
70
|
# See comment above
|
|
75
71
|
if new_py == obj.py:
|
|
76
72
|
decimal_dif = new_py - int(new_py)
|
|
@@ -287,9 +283,7 @@ def add_to_collision_chunk(
|
|
|
287
283
|
return chunk_ids
|
|
288
284
|
|
|
289
285
|
|
|
290
|
-
def _test_chunk_position(
|
|
291
|
-
collision_chunks, obj, px, py, chunk_size, chunks_per_row
|
|
292
|
-
):
|
|
286
|
+
def _test_chunk_position(collision_chunks, obj, px, py, chunk_size, chunks_per_row):
|
|
293
287
|
chidx = _chunk_index(px, py, chunk_size, chunks_per_row)
|
|
294
288
|
collision_chunks.setdefault(chidx, [])
|
|
295
289
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import TYPE_CHECKING, Any, Dict
|
|
5
|
+
|
|
6
|
+
from ..objects.animated_sprite import AnimatedSprite
|
|
7
|
+
from ..types.damage import Damage
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from .engine import MimaEngine
|
|
11
|
+
|
|
12
|
+
LOG = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Database:
|
|
16
|
+
engine: MimaEngine
|
|
17
|
+
|
|
18
|
+
def __init__(self):
|
|
19
|
+
self._cache = {}
|
|
20
|
+
self._known_locale = ""
|
|
21
|
+
self._active_sprites = []
|
|
22
|
+
|
|
23
|
+
def get_usable_data(self, usable_id) -> Dict[str, Any]:
|
|
24
|
+
if usable_id in self._cache:
|
|
25
|
+
return self._cache[usable_id]
|
|
26
|
+
|
|
27
|
+
data = {}
|
|
28
|
+
tpl = self.engine.assets.get_template(usable_id)
|
|
29
|
+
|
|
30
|
+
data["usable_id"] = tpl.get_string("usable_id")
|
|
31
|
+
data["name"] = tpl.get_string(f"display_name_{self.engine.rtc.locale}")
|
|
32
|
+
data["description"] = tpl.get_string(f"description_{self.engine.rtc.locale}")
|
|
33
|
+
data["sprite_name"] = tpl.get_string("sprite_name")
|
|
34
|
+
data["dtype"] = Damage[tpl.get_string("dtype", "body").upper()]
|
|
35
|
+
for pid, prop in tpl.properties.items():
|
|
36
|
+
if not pid.startswith("attr_"):
|
|
37
|
+
continue
|
|
38
|
+
_, attr = pid.split("_", 1)
|
|
39
|
+
data[attr] = tpl.get(pid)
|
|
40
|
+
# data["attr_price"] = tpl.get_int("attr_price")
|
|
41
|
+
# data["attr_swing_timer"] = tpl.get_float("attr_swing_timer")
|
|
42
|
+
# data["attr_damage"] = tpl.get_int("attr_damage")
|
|
43
|
+
# data["attr_health_cost"] = tpl.get_int("attr_health_cost")
|
|
44
|
+
# data["attr_magic_cost"] = tpl.get_int("attr_magic_cost")
|
|
45
|
+
# data["attr_stamina_cost"] = tpl.get_int("attr_stamina_cost")
|
|
46
|
+
# data["attr_bomb_cost"] = tpl.get_int("attr_bomb_cost")
|
|
47
|
+
# data["attr_arrow_cost"] = tpl.get_int("attr_arrow_cost")
|
|
48
|
+
|
|
49
|
+
self._cache[usable_id] = data
|
|
50
|
+
return data
|
|
51
|
+
|
|
52
|
+
def get_object_data(self, object_id) -> Dict[str, Any]:
|
|
53
|
+
return {}
|
|
54
|
+
|
|
55
|
+
def get_sprite(self, sprite_id):
|
|
56
|
+
sprite = AnimatedSprite(sprite_id)
|
|
57
|
+
self._active_sprites.append(sprite)
|
|
58
|
+
return sprite
|
|
@@ -4,30 +4,32 @@ import logging
|
|
|
4
4
|
from abc import ABC, abstractmethod
|
|
5
5
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
|
6
6
|
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from
|
|
12
|
-
from
|
|
13
|
-
from
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
from
|
|
17
|
-
from
|
|
18
|
-
from
|
|
19
|
-
from
|
|
20
|
-
from
|
|
21
|
-
from
|
|
22
|
-
from
|
|
23
|
-
from
|
|
24
|
-
from
|
|
25
|
-
from .
|
|
26
|
-
from
|
|
27
|
-
from .
|
|
7
|
+
from ..backend.pygame_assets import PygameAssets
|
|
8
|
+
from ..backend.pygame_audio import PygameAudio
|
|
9
|
+
from ..backend.pygame_backend import PygameBackend
|
|
10
|
+
from ..backend.pygame_events import PygameUserInput
|
|
11
|
+
from ..maps.template import Template
|
|
12
|
+
from ..maps.tilemap import Tilemap
|
|
13
|
+
from ..objects.animated_sprite import AnimatedSprite
|
|
14
|
+
from ..objects.creature import Creature
|
|
15
|
+
from ..objects.dynamic import Dynamic
|
|
16
|
+
from ..objects.loader import ObjectLoader
|
|
17
|
+
from ..objects.sprite import Sprite
|
|
18
|
+
from ..scripts import Command, ScriptProcessor
|
|
19
|
+
from ..states.memory import Memory
|
|
20
|
+
from ..states.quest import Quest
|
|
21
|
+
from ..types.gate_color import GateColor
|
|
22
|
+
from ..types.mode import Mode
|
|
23
|
+
from ..types.player import Player
|
|
24
|
+
from ..usables.item import Item
|
|
25
|
+
from ..usables.weapon import Weapon
|
|
26
|
+
from ..util import RuntimeConfig
|
|
27
|
+
from ..util.logging import install_trace_logger
|
|
28
|
+
from ..view.camera import Camera
|
|
28
29
|
|
|
29
30
|
# from .view.game_mode import GameMode
|
|
30
|
-
from
|
|
31
|
+
from ..view.mima_view import MimaView
|
|
32
|
+
from .database import Database
|
|
31
33
|
|
|
32
34
|
# from .view.scene import Scene
|
|
33
35
|
|
|
@@ -49,10 +51,8 @@ class MimaEngine(ABC):
|
|
|
49
51
|
self.rtc = RuntimeConfig(config_path, default_config)
|
|
50
52
|
install_trace_logger()
|
|
51
53
|
|
|
52
|
-
self.backend: PygameBackend = PygameBackend(
|
|
53
|
-
|
|
54
|
-
)
|
|
55
|
-
|
|
54
|
+
self.backend: PygameBackend = PygameBackend(self.rtc, init_file, platform)
|
|
55
|
+
self.db: Database
|
|
56
56
|
self._caption: str = caption
|
|
57
57
|
self.seconds_total: float = 0.0
|
|
58
58
|
self.app_fps: float = 0.0
|
|
@@ -86,6 +86,7 @@ class MimaEngine(ABC):
|
|
|
86
86
|
AnimatedSprite.engine = self
|
|
87
87
|
Camera.engine = self
|
|
88
88
|
Command.engine = self
|
|
89
|
+
Database.engine = self
|
|
89
90
|
Dynamic.engine = self
|
|
90
91
|
# GameMode.engine = self
|
|
91
92
|
Item.engine = self
|
|
@@ -100,6 +101,7 @@ class MimaEngine(ABC):
|
|
|
100
101
|
MimaView.engine = self
|
|
101
102
|
|
|
102
103
|
self.script = ScriptProcessor()
|
|
104
|
+
self.db = Database()
|
|
103
105
|
self.backend.init(
|
|
104
106
|
keyboard_map=self.rtc.get_keyboard_map(),
|
|
105
107
|
joystick_map=self.rtc.get_joystick_map(),
|
|
@@ -124,8 +126,7 @@ class MimaEngine(ABC):
|
|
|
124
126
|
if self.on_user_create():
|
|
125
127
|
while self.backend.keep_running():
|
|
126
128
|
self.backend.set_caption(
|
|
127
|
-
f"{self._caption} ({self.game_fps:.2f}/"
|
|
128
|
-
f"{self.app_fps:.2f} fps)"
|
|
129
|
+
f"{self._caption} ({self.game_fps:.2f}/" f"{self.app_fps:.2f} fps)"
|
|
129
130
|
)
|
|
130
131
|
self.backend.process_events()
|
|
131
132
|
|
|
@@ -159,10 +160,7 @@ class MimaEngine(ABC):
|
|
|
159
160
|
app_frames = 0
|
|
160
161
|
app_seconds -= 1.0
|
|
161
162
|
|
|
162
|
-
print(
|
|
163
|
-
f"App/Game Frames total: {app_frames_total}/"
|
|
164
|
-
f"{game_frames_total}"
|
|
165
|
-
)
|
|
163
|
+
print(f"App/Game Frames total: {app_frames_total}/" f"{game_frames_total}")
|
|
166
164
|
print(f"Seconds total: {self.seconds_total:.3f}")
|
|
167
165
|
print(
|
|
168
166
|
"Average App/Game FPS: "
|
|
@@ -200,9 +198,24 @@ class MimaEngine(ABC):
|
|
|
200
198
|
def get_map(self, map_name: str):
|
|
201
199
|
return self.backend.assets.get_map(map_name)
|
|
202
200
|
|
|
203
|
-
def
|
|
204
|
-
LOG.debug(
|
|
205
|
-
self.
|
|
201
|
+
def load_usable(self, item: Item, item_id) -> None:
|
|
202
|
+
LOG.debug("Loading usable %s.", item_id)
|
|
203
|
+
item.init(self.db.get_usable_data(item_id))
|
|
204
|
+
self.memory.items[item_id] = item
|
|
205
|
+
|
|
206
|
+
# def load_weapon(self, weapon: Weapon, weapon_id: str) -> None:
|
|
207
|
+
# LOG.debug("Loading weapon %s.", weapon_id)
|
|
208
|
+
# weapon.init(self.db.get_weapon_data(weapon_id))
|
|
209
|
+
# self.memory.items[weapon_id] = weapon
|
|
210
|
+
|
|
211
|
+
# def load_item(self, item: Item, item_id: str) -> None:
|
|
212
|
+
# LOG.debug("Loading item %s.", item_id)
|
|
213
|
+
# item.init(self.db.get_item_data(item_id))
|
|
214
|
+
# self.memory.items[item_id] = item
|
|
215
|
+
|
|
216
|
+
# def load_item(self, item: Item):
|
|
217
|
+
# LOG.debug(f"Loading item {item.name}.")
|
|
218
|
+
# self.memory.items[item.name] = item
|
|
206
219
|
|
|
207
220
|
def get_item(self, item_id: str):
|
|
208
221
|
try:
|
|
@@ -263,9 +276,7 @@ class MimaEngine(ABC):
|
|
|
263
276
|
def set_player(self, creature: Creature, player: Player = Player.P1):
|
|
264
277
|
self.memory.player[player] = creature
|
|
265
278
|
|
|
266
|
-
def trigger_teleport(
|
|
267
|
-
self, active: bool = True, player: Player = Player.P1
|
|
268
|
-
):
|
|
279
|
+
def trigger_teleport(self, active: bool = True, player: Player = Player.P1):
|
|
269
280
|
self.memory.teleport_active[player] = active
|
|
270
281
|
|
|
271
282
|
def is_teleport_active(self, player: Player = Player.P1):
|
|
@@ -277,9 +288,7 @@ class MimaEngine(ABC):
|
|
|
277
288
|
def is_dialog_active(self, player: Player = Player.P1):
|
|
278
289
|
return self.memory.dialog_active[player]
|
|
279
290
|
|
|
280
|
-
def trigger_script(
|
|
281
|
-
self, active: bool = True, player: Player = Player.P1
|
|
282
|
-
) -> None:
|
|
291
|
+
def trigger_script(self, active: bool = True, player: Player = Player.P1) -> None:
|
|
283
292
|
self.memory.script_active[player] = active
|
|
284
293
|
|
|
285
294
|
def is_script_active(self, player: Player = Player.P1) -> bool:
|
|
@@ -328,10 +337,7 @@ class MimaEngine(ABC):
|
|
|
328
337
|
|
|
329
338
|
@dialog_active.setter
|
|
330
339
|
def dialog_active(self, val):
|
|
331
|
-
print(
|
|
332
|
-
"dialog_active is deprecated; use "
|
|
333
|
-
"'trigger_dialog(active)' instead."
|
|
334
|
-
)
|
|
340
|
+
print("dialog_active is deprecated; use " "'trigger_dialog(active)' instead.")
|
|
335
341
|
self.memory.dialog_active = val
|
|
336
342
|
|
|
337
343
|
@property
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
|
3
3
|
|
|
4
|
+
from ..states.game_state import GameState
|
|
5
|
+
from ..types.keys import Key as K
|
|
6
|
+
from ..types.mode import Mode
|
|
7
|
+
from ..types.nature import Nature
|
|
8
|
+
from ..types.player import Player
|
|
9
|
+
from ..view.mima_mode import MimaMode
|
|
4
10
|
from .engine import MimaEngine
|
|
5
|
-
from .states.game_state import GameState
|
|
6
|
-
from .types.keys import Key as K
|
|
7
|
-
from .types.mode import Mode
|
|
8
|
-
from .types.nature import Nature
|
|
9
|
-
from .types.player import Player
|
|
10
|
-
from .view.mima_mode import MimaMode
|
|
11
11
|
|
|
12
12
|
# from .view.mima_scene import MimaScene
|
|
13
13
|
LOG = logging.getLogger(__name__)
|
|
@@ -22,9 +22,7 @@ class MimaModeEngine(MimaEngine):
|
|
|
22
22
|
platform="PC",
|
|
23
23
|
caption: str = "MimaEngine",
|
|
24
24
|
):
|
|
25
|
-
super().__init__(
|
|
26
|
-
init_file, config_path, default_config, platform, caption
|
|
27
|
-
)
|
|
25
|
+
super().__init__(init_file, config_path, default_config, platform, caption)
|
|
28
26
|
|
|
29
27
|
self.modes: Dict[Mode, MimaMode] = {}
|
|
30
28
|
self.mode: Optional[MimaMode] = None
|
|
@@ -69,9 +67,7 @@ class MimaModeEngine(MimaEngine):
|
|
|
69
67
|
self.mode.load()
|
|
70
68
|
|
|
71
69
|
def return_mode(self):
|
|
72
|
-
LOG.debug(
|
|
73
|
-
"Returning to previous mode. Stack: %s", str(self.mode_stack)
|
|
74
|
-
)
|
|
70
|
+
LOG.debug("Returning to previous mode. Stack: %s", str(self.mode_stack))
|
|
75
71
|
self.mode_stack.pop()
|
|
76
72
|
self.mode = self.modes[self.mode_stack[-1]]
|
|
77
73
|
self.mode.load()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import TYPE_CHECKING, Dict, List, Optional, Union
|
|
1
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
|
2
2
|
|
|
3
3
|
from .engine import MimaEngine
|
|
4
4
|
from .states.game_state import GameState
|
|
@@ -18,9 +18,7 @@ class MimaSceneEngine(MimaEngine):
|
|
|
18
18
|
platform: str = "PC",
|
|
19
19
|
caption: str = "MimaEngine",
|
|
20
20
|
):
|
|
21
|
-
super().__init__(
|
|
22
|
-
init_file, config_path, default_config, platform, caption
|
|
23
|
-
)
|
|
21
|
+
super().__init__(init_file, config_path, default_config, platform, caption)
|
|
24
22
|
|
|
25
23
|
self.scene_stack: List[str] = []
|
|
26
24
|
self._scenes: Dict[str, Scene] = {}
|
|
@@ -46,9 +44,7 @@ class MimaSceneEngine(MimaEngine):
|
|
|
46
44
|
if self._current_scene.autosave:
|
|
47
45
|
for quest in self.quests:
|
|
48
46
|
for obj in self.scene.dynamics:
|
|
49
|
-
quest.on_interaction(
|
|
50
|
-
self.scene.dynamics, obj, Nature.SAVE
|
|
51
|
-
)
|
|
47
|
+
quest.on_interaction(self.scene.dynamics, obj, Nature.SAVE)
|
|
52
48
|
quest.save_state()
|
|
53
49
|
if self.keys.new_key_press(K.SELECT):
|
|
54
50
|
self.game_state.save_to_disk()
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Dict, Optional, Union
|
|
4
|
+
|
|
5
|
+
from ..util.functions import strtobool
|
|
6
|
+
from ..util.property import Property
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from ..engine import MimaEngine
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Template:
|
|
13
|
+
engine: MimaEngine
|
|
14
|
+
|
|
15
|
+
def __init__(self, name: str):
|
|
16
|
+
self.name: str = name
|
|
17
|
+
self.properties: Dict[str, Property] = {}
|
|
18
|
+
|
|
19
|
+
def get_string(self, key: str, default_val: str = "") -> str:
|
|
20
|
+
if key in self.properties:
|
|
21
|
+
return self.properties[key].value
|
|
22
|
+
else:
|
|
23
|
+
return default_val
|
|
24
|
+
|
|
25
|
+
def get_int(self, key: str, default_val: int = 0) -> int:
|
|
26
|
+
if key in self.properties:
|
|
27
|
+
return int(self.properties[key].value)
|
|
28
|
+
else:
|
|
29
|
+
return default_val
|
|
30
|
+
|
|
31
|
+
def get_float(self, key: str, default_val: float = 0.0) -> float:
|
|
32
|
+
if key in self.properties:
|
|
33
|
+
return float(self.properties[key].value)
|
|
34
|
+
else:
|
|
35
|
+
return default_val
|
|
36
|
+
|
|
37
|
+
def get_bool(self, key: str, default_val: bool = False) -> bool:
|
|
38
|
+
if key in self.properties:
|
|
39
|
+
return bool(strtobool(self.properties[key].value))
|
|
40
|
+
else:
|
|
41
|
+
return default_val
|
|
42
|
+
|
|
43
|
+
def get(
|
|
44
|
+
self, key: str, default_val: Optional[str, int, float, bool] = None
|
|
45
|
+
) -> Union[str, int, float, bool]:
|
|
46
|
+
|
|
47
|
+
if key in self.properties:
|
|
48
|
+
if self.properties[key].dtype == "str":
|
|
49
|
+
if default_val is None:
|
|
50
|
+
return self.get_string(key)
|
|
51
|
+
return self.get_string(key, default_val)
|
|
52
|
+
if self.properties[key].dtype == "int":
|
|
53
|
+
if default_val is None:
|
|
54
|
+
return self.get_int(key)
|
|
55
|
+
return self.get_int(key, int(default_val))
|
|
56
|
+
if self.properties[key].dtype == "float":
|
|
57
|
+
if default_val is None:
|
|
58
|
+
return self.get_float(key)
|
|
59
|
+
return self.get_float(key, float(default_val))
|
|
60
|
+
if self.properties[key].dtype == "bool":
|
|
61
|
+
if default_val is None:
|
|
62
|
+
return self.get_bool(key)
|
|
63
|
+
elif not isinstance(default_val, bool):
|
|
64
|
+
msg = (
|
|
65
|
+
"Trying to access a bool value but default value "
|
|
66
|
+
f"{default_val} is of type {type(default_val)}"
|
|
67
|
+
)
|
|
68
|
+
raise TypeError(msg)
|
|
69
|
+
return self.get_bool(key, default_val)
|
|
70
|
+
|
|
71
|
+
return default_val
|
|
@@ -47,7 +47,7 @@ class TiledObject(Template):
|
|
|
47
47
|
name="tileset_name", dtype="str", value=tpl.tileset_name
|
|
48
48
|
)
|
|
49
49
|
self.properties["image_name"] = Property(
|
|
50
|
-
name="image_name", dtype="str", value=
|
|
50
|
+
name="image_name", dtype="str", value=""
|
|
51
51
|
)
|
|
52
52
|
self.properties["sprite_offset_x"] = Property(
|
|
53
53
|
name="sprite_offset_x",
|
|
@@ -33,14 +33,19 @@ class TiledTileset(Tileset):
|
|
|
33
33
|
|
|
34
34
|
LOG.debug("Loading image properties ...")
|
|
35
35
|
image = root.findall("image")[0]
|
|
36
|
-
self.
|
|
36
|
+
self.image_name: str = os.path.split(image.attrib["source"])[-1][:-4]
|
|
37
37
|
self.sprite_width: int = int(image.attrib["width"])
|
|
38
38
|
self.sprite_height: int = int(image.attrib["height"])
|
|
39
39
|
|
|
40
40
|
LOG.debug("Loading tiles ...")
|
|
41
41
|
tiles = root.findall("tile")
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
for tile in tiles:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
t_obj = TiledTile(tile)
|
|
45
|
+
self.tiles.append(t_obj)
|
|
46
|
+
if t_obj.animated:
|
|
47
|
+
self.animated_tiles.append(t_obj)
|
|
48
|
+
if t_obj.sprite_name:
|
|
49
|
+
self.sprite_names.setdefault(t_obj.sprite_name, []).append(
|
|
50
|
+
t_obj.tile_id
|
|
51
|
+
)
|
|
@@ -64,12 +64,8 @@ class Tilemap(Template):
|
|
|
64
64
|
if layer.layer_pos != layer_pos:
|
|
65
65
|
continue
|
|
66
66
|
|
|
67
|
-
layer_ox = (
|
|
68
|
-
|
|
69
|
-
) * self.tile_width
|
|
70
|
-
layer_oy = (
|
|
71
|
-
layer.layer_oy - math.floor(layer.layer_oy)
|
|
72
|
-
) * self.tile_height
|
|
67
|
+
layer_ox = (layer.layer_ox - math.floor(layer.layer_ox)) * self.tile_width
|
|
68
|
+
layer_oy = (layer.layer_oy - math.floor(layer.layer_oy)) * self.tile_height
|
|
73
69
|
|
|
74
70
|
layer_visible_tiles_sx = int(visible_tiles_sx)
|
|
75
71
|
layer_visible_tiles_sy = int(visible_tiles_sy)
|
|
@@ -81,9 +77,7 @@ class Tilemap(Template):
|
|
|
81
77
|
|
|
82
78
|
# Draw visible tiles of the map
|
|
83
79
|
for x in range(layer_visible_tiles_sx, int(visible_tiles_ex) + 2):
|
|
84
|
-
for y in range(
|
|
85
|
-
layer_visible_tiles_sy, int(visible_tiles_ey) + 2
|
|
86
|
-
):
|
|
80
|
+
for y in range(layer_visible_tiles_sy, int(visible_tiles_ey) + 2):
|
|
87
81
|
tile_index = layer.get_index(
|
|
88
82
|
int(x + math.floor(ox)), int(y + math.floor(oy))
|
|
89
83
|
)
|
|
@@ -103,7 +97,7 @@ class Tilemap(Template):
|
|
|
103
97
|
self.engine.backend.draw_partial_sprite(
|
|
104
98
|
math.floor(x * self.tile_width - tile_ox + layer_ox),
|
|
105
99
|
math.floor(y * self.tile_height - tile_oy + layer_oy),
|
|
106
|
-
info.tileset.
|
|
100
|
+
info.tileset.image_name,
|
|
107
101
|
sx * self.tile_width,
|
|
108
102
|
sy * self.tile_height,
|
|
109
103
|
self.tile_width,
|