diff --git a/src/random.h b/src/random.h index 0e69993..4ddd5d8 100644 --- a/src/random.h +++ b/src/random.h @@ -6,7 +6,12 @@ enum { PLATE_COUNT=1, PLATE_JITTER_X, - PLATE_JITTER_Y + PLATE_JITTER_Y, + PLATE_PROP, + PLATE_IS_OCEAN, + PLATE_THICK, + PLATE_SPEED_X, + PLATE_SPEED_Y }; uint64_t game_hash(uint64_t seed,int type,int subtype); diff --git a/src/terrain.c b/src/terrain.c index 934ef91..a008da8 100644 --- a/src/terrain.c +++ b/src/terrain.c @@ -9,8 +9,8 @@ static void plate_seed(struct Plate_list _i,uint64_t seed){ double cw = WORLD_W/G; double ch = WORLD_H/G; for(int i=0;i<_i.count;i++){ - double jx = (double)game_hash(seed,PLATE_JITTER_X,i/G)/UINT64_MAX; - double jy = (double)game_hash(seed,PLATE_JITTER_Y,i%G)/UINT64_MAX; + double jx = (double)game_hash(seed,PLATE_JITTER_X,i)/UINT64_MAX; + double jy = (double)game_hash(seed,PLATE_JITTER_Y,i)/UINT64_MAX; double x = (i%G +jx)*cw; if(x>WORLD_W)x-=WORLD_W; (_i._p+i)->seed.x = x; @@ -77,6 +77,38 @@ static void lloyd_iterate(struct World_Block *_p,struct Plate_list _i,int _t){ return; } +static void plate_is_ocean(struct Plate_list _i,uint64_t seed){ + for(int i=0;i<_i.count;i++){ + if((double)game_hash(seed,PLATE_IS_OCEAN,i)/UINT64_MAX>0.4){ + (_i._p+i)->is_ocean = true; + }else{ + (_i._p+i)->is_ocean = false; + } + } +} + +static void plate_thick(struct Plate_list _i,uint64_t seed){ + for(int i=0;i<_i.count;i++){ + if((_i._p+i)->is_ocean){ + (_i._p+i)->thick=5+(double)game_hash(seed,PLATE_THICK,i)/UINT64_MAX*5; + }else{ + (_i._p+i)->thick=30+(double)game_hash(seed,PLATE_THICK,i)/UINT64_MAX*40; + } + } +} + +static void plate_speed(struct Plate_list _i,uint64_t seed){ + for(int i=0;i<_i.count;i++){ + if((_i._p+i)->is_ocean){ + (_i._p+i)->speed.x=1+(double)game_hash(seed,PLATE_SPEED_X,i)/UINT64_MAX*9; + (_i._p+i)->speed.y=1+(double)game_hash(seed,PLATE_SPEED_Y,i)/UINT64_MAX*9; + }else{ + (_i._p+i)->speed.x=(double)game_hash(seed,PLATE_SPEED_X,i)/UINT64_MAX*5; + (_i._p+i)->speed.y=(double)game_hash(seed,PLATE_SPEED_Y,i)/UINT64_MAX*5; + } + } +} + struct Plate_list plate_init(uint64_t seed,struct World_Block *block){ int count = plate_count(seed); struct Plate_list list;