Skip to content
Snippets Groups Projects
Verified Commit ef849704 authored by TORTEROTOT THOMAS's avatar TORTEROTOT THOMAS
Browse files

Added overload for Cell::update_sprite_handle to simplify Terrain::clear_fruit

parent d43fe334
Branches
No related merge requests found
......@@ -51,6 +51,11 @@ void Cell::update_type(const ECellType new_type)
type = new_type;
}
void Cell::update_sprite_handle(SpriteHandle new_sprite_handle)
{
sprite_handle = new_sprite_handle;
}
void Cell::update_sprite_handle(
const std::unordered_map<ECellType, SpriteHandle>& cell_sprite_handles,
const std::unordered_map<EItemType, SpriteHandle>& item_sprite_handles,
......
......@@ -65,6 +65,10 @@ public:
[[nodiscard]] EItemType get_item() const;
void update_type(const ECellType new_type);
// Update the cell's sprite handle to be the provided one
// (called update instead of set for consistency with the other overload)
void update_sprite_handle(SpriteHandle new_sprite_handle);
// Update the cell's sprite handle based on its nature
// from the provided data structures
void update_sprite_handle(
......
......@@ -144,12 +144,9 @@ void Terrain::eat(const Vector2I& pos)
void Terrain::clear_fruit()
{
const std::unordered_map<ECellType, SpriteHandle> sprite_handle = {
{ECellType::Void, SpriteHandle{}}
};
Cell& fruit_cell = get_cell({10, 15});
fruit_cell.update_type(ECellType::Void);
fruit_cell.update_sprite_handle(sprite_handle, {}, {});
fruit_cell.update_sprite_handle(SpriteHandle{});
}
Vector2I Terrain::closest_free_point(const Vector2I& location) const
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment