-
Notifications
You must be signed in to change notification settings - Fork 219
Description
Hi, it is me again.
I am working on a roguelike game these days, and turn out to use easyrpg as my game engine since it is open source so that I can use cpp as my scripting languages.
What I am going to do is to generate a map as well as some map events(boxes, monsters, etcs)
I don't know how to create a event class mannually, so I copy a existing map event and events.emplace_back() it into the list. But when I pushed more than 20 boxes, it crashed :(
// Add One Box
for (const auto& ev : map->events) {
events.emplace_back(GetMapId(), &ev);
if (events.back().GetName() != "Box") {
events.pop_back();
} else {
auto& t = events.back();
t.SetId(events.size());
Scene_Map* scene = (Scene_Map*)Scene::Find(Scene::Map).get();
scene->spriteset->CreateSprite(&t, LoopHorizontal(), LoopVertical());
break;
}
}

(But reset the position of the exising one is safe, so what I do now it copy them as many as possible in the editor, and then randomize their position in the code.)
So my question is is there a way that I can dynamic add a map event? (e.g. regenerate monsters)
My code is here: lychees@eed14c0#diff-178bf271cafc0ba6a7f089f62f3aef281fac6d750b47e38eb2e6a1aae2945f86.
