Skip to content

Commit 43834e3

Browse files
committed
Fix har_spawn_oil
1 parent 162d6fe commit 43834e3

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/game/objects/har.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,9 +837,16 @@ void har_spawn_oil(object *obj, vec2i pos, int amount, fixedpt gravityf, int lay
837837
// burning oil
838838
for(int i = 0; i < amount; i++) {
839839
// Calculate velocity etc.
840-
fixedpt rv = fixedpt_fromint(rand_int(100) - 50) / 100;
840+
#if 0
841+
float fvelx = (5 * cosf(90 + i - (amount) / 2 + frv)) * object_get_direction(obj);
842+
float fvely = -12 * sinf(i / amount + frv);
843+
fixedpt velx = fixedpt_rconst(fvelx);
844+
fixedpt vely = fixedpt_rconst(fvely);
845+
#else
846+
fixedpt rv = rand_fixedpt(FIXEDPT_ONE) - FIXEDPT_ONE_HALF;
841847
fixedpt velx = (5 * -fixedpt_cos(fixedpt_fromint(i - (amount) / 2) + rv)) * object_get_direction(obj);
842-
fixedpt vely = -12 * fixedpt_sin(fixedpt_fromint(i) / amount + rv);
848+
fixedpt vely = -12 * fixedpt_sin(rv);
849+
#endif
843850

844851
// Make sure the oil drops have somekind of velocity
845852
// (to prevent floating scrap objects)
@@ -873,7 +880,7 @@ void har_spawn_scrap(object *obj, vec2i pos, int amount) {
873880
// wild ass guess
874881
int oil_amount = amount / 3;
875882
har *h = object_get_userdata(obj);
876-
har_spawn_oil(obj, pos, oil_amount, 1, RENDER_LAYER_TOP);
883+
har_spawn_oil(obj, pos, oil_amount, FIXEDPT_ONE, RENDER_LAYER_TOP);
877884

878885
// scrap metal
879886
// TODO this assumes the default scrap level and does not consider BIG[1-9]

src/utils/random.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ uint32_t rand_intmax(void) {
4747
float rand_float(void) {
4848
return random_float(&rand_state);
4949
}
50+
fixedpt rand_fixedpt(fixedpt max) {
51+
return random_fixedpt(&rand_state, max);
52+
}

src/utils/random.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ uint32_t rand_get_seed(void);
3333
uint32_t rand_int(uint32_t upperbound);
3434
uint32_t rand_intmax(void);
3535
float rand_float(void);
36+
fixedpt rand_fixedpt(fixedpt max);
3637

3738
#endif // RANDOM_H

0 commit comments

Comments
 (0)