summaryrefslogtreecommitdiff
path: root/src/game/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/game.cpp')
-rw-r--r--src/game/game.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp
index 5067df7..96f76d3 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -84,9 +84,20 @@ void state_t::command(v2f_t x)
void state_t::tick(double now_, double dt_)
{
+ union {
+ double d;
+ uint32_t i;
+ } u;
+
now = now_;
dt = dt_;
+ // FIXME: Is this non-deterministic enough?
+ u.d = now;
+ dice_prng.seed(dice_prng.next() ^ u.i);
+ u.d = dt;
+ dice_prng.seed(dice_prng.next() ^ u.i);
+
for (unit_t *unit : units) {
rectf_t wake_range;
@@ -136,6 +147,34 @@ void state_t::tick(double now_, double dt_)
}
}
+roll_params_t::roll_params_t(size_t sides_)
+{
+ sides = sides_;
+}
+
+roll_params_t::roll_params_t(size_t count_, size_t sides_)
+{
+ count = count_;
+ sides = sides_;
+}
+
+roll_params_t::roll_params_t(size_t count_, size_t sides_, size_t bonus_)
+{
+ count = count_;
+ sides = sides_;
+ bonus = bonus_;
+}
+
+size_t state_t::roll(roll_params_t *P)
+{
+ size_t total = 0;
+
+ for (size_t i = 0; i < P->count; i++)
+ total += dice_prng.next() % P->sides + 1;
+
+ return total + P->bonus;
+}
+
bool load_assets(void)
{
assets::load();