fixed several memory leaks caused by not including virtual destructors, added a config for the visualizer, next up is lua
This commit is contained in:
@@ -1,14 +1,27 @@
|
||||
Dungeon generation algorithms are written in lua and dropped into scripting->algorithms. They are automatically parsed by the visualizer and assigned keys in the program to run them.
|
||||
Algorithms are made up of a single lua file (possibly more with requires) with the following functions:
|
||||
Algorithms are made up of a single lua file (possibly more with requires) with the following functionality:
|
||||
|
||||
initialize()
|
||||
Initializes the algorithm and returns a structure/table with the following fields:
|
||||
{
|
||||
updates_per_second: int // Number of times the algorithm's update function should be called per second. Minimum of 1, converted into frames per update with a minimum of 1.
|
||||
free_data: table // Free table that the developer can store necessary state data in
|
||||
}
|
||||
Provided:
|
||||
|
||||
update(state)
|
||||
global algorithm_manager.register_algorithm(name, init_function, update_function, updates_per_second)
|
||||
Registers an algorithm with the program with a given name, init function, update function, and updates per second
|
||||
|
||||
The following functions are available to algorithms in either their update or initialize functions:
|
||||
map.draw_floor(x, y)
|
||||
Draws a floor on the map at a given x, y position
|
||||
|
||||
map.draw_wall(x, y)
|
||||
draws a wall on the map at a given x, y position
|
||||
|
||||
map.fill(bool wall)
|
||||
Fills the map with either floors (false) or walls (true)
|
||||
|
||||
map.is_wall(x, y)
|
||||
returns true if map[x,y] is a wall, false otherwise
|
||||
|
||||
Necessary:
|
||||
|
||||
init_function(map_w, map_h)
|
||||
Should initialize the function fresh with a given width and height.
|
||||
|
||||
update(map)
|
||||
Called updates_per_second times per second. Should calculate new map state and draw on the map as needed. The map will have the previous state retained.
|
||||
|
||||
Reference in New Issue
Block a user