My Project
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
main.MapEditor Class Reference

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)
 

Public Attributes

 root
 
 drag_data
 
 enemies
 
 enemy_id
 
 foods
 
 food_id
 
 selected_enemy
 
 selected_food
 
 current_level
 
 canvas_width
 
 canvas_height
 
 canvas
 
 background_image
 
 enemy_button
 
 food_button
 
 save_button
 
 delete_button
 
 level_selector
 
 load_level
 
 on_drag_start
 
 on_drag_move
 
 on_drag_stop
 

Detailed Description

\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.

Constructor & Destructor Documentation

◆ __init__()

main.MapEditor.__init__ ( self,
root )
\brief Initialize the MapEditor with a given Tkinter root.
\param root The Tkinter root widget.

Member Function Documentation

◆ add_enemy()

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.

◆ add_food()

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.

◆ delete_selected()

main.MapEditor.delete_selected ( self)
\brief Deletes the currently selected enemy or food item from the canvas.

◆ init_ui()

main.MapEditor.init_ui ( self)
\brief Initializes the user interface components for the map editor.

◆ load_level()

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.

◆ on_drag_move()

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.

◆ on_drag_start()

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.

◆ on_drag_stop()

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.

◆ reassign_ids()

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.

◆ save_enemies_and_foods()

main.MapEditor.save_enemies_and_foods ( self)
\brief Saves the current configuration of enemies and foods to a file.

The documentation for this class was generated from the following file: