td-wavegen

Crates.iotd-wavegen
lib.rstd-wavegen
version2.0.0
created_at2024-11-29 10:54:58.976214+00
updated_at2025-12-19 14:51:30.860983+00
descriptionTower Defense mob wave generator
homepage
repositoryhttps://gitlab.com/Aconitin/td-wavegen
max_upload_size
id1465506
size15,983
Sven (Aconitin)

documentation

README

td-wavegen

A helper library for generating waves of mobs for e.g. TD-type levels.

Specify a cost for each mob and a budget function (giving you a certain budget per wave) and this will provide a set of mobs for each wave. E.g. if you create a waves generator like this:

use td_wavegen::mobs::MobType;
use td_wavegen::wave_generator::WaveGenerator;

let mob_type_a: MobType = MobType { index: 1, cost: 1 };
let mob_type_b: MobType = MobType { index: 2, cost: 3 };
let mob_type_c: MobType = MobType { index: 3, cost: 5 };

let mut wave_generator = WaveGenerator::builder()
    .add_mob_type(mob_type_a)
    .add_mob_types(Vec::from([mob_type_b, mob_type_c, mob_type_d]))
    .with_budget_function(|concrete_difficulty| concrete_difficulty * 2)
    .build();

... then you can use it to generate waves with a certain base difficulty:

use td_wavegen::wave::Wave;

let wave_1 = wave_generator.next(1);
let wave_2 = wave_generator.next(2);
let wave_3 = wave_generator.next(3);

The budget function defined above sets a budget for each wave, and the library will, for each wave, keep trying to "buy" mobs into the current wave set until it runs out of budget. The difficulty value you provide will be used to calculate the current budget. Note that currently, it starts buying at the most expensive mob and moves downwards from there. Different buying strategies are WIP.

Commit count: 21

cargo fmt