My Project
|
Public Member Functions | |
__init__ (self, root) | |
init_ui (self) | |
load_level (self, event=None) | |
add_enemy (self, x=0, y=0, tag=None) | |
add_food (self, x=0, y=0, tag=None) | |
on_drag_start (self, event) | |
on_drag_move (self, event) | |
on_drag_stop (self, event) | |
delete_selected (self) | |
reassign_ids (self, items, prefix) | |
save_enemies_and_foods (self) | |
\class MapEditor \brief A graphical map editor for creating and modifying game levels. This class provides a GUI for adding, moving, and deleting 'enemy' and 'food' items on a game level. Users can select levels to edit, add enemies and foods, drag these items around the canvas, and save their configurations.
main.MapEditor.__init__ | ( | self, | |
root ) |
\brief Initialize the MapEditor with a given Tkinter root. \param root The Tkinter root widget.
main.MapEditor.add_enemy | ( | self, | |
x = 0, | |||
y = 0, | |||
tag = None ) |
\brief Adds an enemy to the canvas at the specified location. \param x The x-coordinate on the canvas where the enemy should be placed. \param y The y-coordinate on the canvas where the enemy should be placed. \param tag An optional unique identifier for the enemy. If none is provided, an id is generated.
main.MapEditor.add_food | ( | self, | |
x = 0, | |||
y = 0, | |||
tag = None ) |
\brief Adds a food item to the canvas at the specified location. \param x The x-coordinate on the canvas where the food should be placed. \param y The y-coordinate on the canvas where the food should be placed. \param tag An optional unique identifier for the food. If none is provided, an id is generated.
main.MapEditor.delete_selected | ( | self | ) |
\brief Deletes the currently selected enemy or food item from the canvas.
main.MapEditor.init_ui | ( | self | ) |
\brief Initializes the user interface components for the map editor.
main.MapEditor.load_level | ( | self, | |
event = None ) |
\brief Loads the enemies and foods from a configuration file for the current level. \param event Optional event parameter for Tkinter event handling compatibility.
main.MapEditor.on_drag_move | ( | self, | |
event ) |
\brief Handles the dragging movement of an item. \param event The Tkinter event containing the new mouse coordinates.
main.MapEditor.on_drag_start | ( | self, | |
event ) |
\brief Initiates dragging of an enemy or food item on the canvas. \param event The Tkinter event containing the mouse coordinates.
main.MapEditor.on_drag_stop | ( | self, | |
event ) |
\brief Finalizes the drag operation, updating the item's position. \param event The Tkinter event signaling the release of the mouse button.
main.MapEditor.reassign_ids | ( | self, | |
items, | |||
prefix ) |
\brief Reassigns IDs to items in the canvas, useful after deletion operations. \param items The dictionary of items (either enemies or foods) to reassign. \param prefix The prefix string used to generate new tags for items.
main.MapEditor.save_enemies_and_foods | ( | self | ) |
\brief Saves the current configuration of enemies and foods to a file.