diff options
author | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-24 18:01:08 +0100 |
---|---|---|
committer | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-24 18:01:08 +0100 |
commit | dad432566a5c74f86dc4ba874e631115e0f469d1 (patch) | |
tree | 0e282e874ef48658d87e82041afe7bba1db3704a /gst | |
parent | 0b338bbd007048551526ab4fa4130d53b414e650 (diff) |
level selector and fx fic
Diffstat (limited to 'gst')
-rw-r--r-- | gst/fxs.c | 5 | ||||
-rw-r--r-- | gst/gst.c | 10 | ||||
-rw-r--r-- | gst/info.c | 1 |
3 files changed, 11 insertions, 5 deletions
@@ -39,7 +39,10 @@ void fx_render (SDL_Renderer *rend, fxs *fx, float cam[], float time) { b->from[1] *(1-amt) + b->to[1] *amt }; float head[2]; vec2_sub(head, b->from, b->to); - vec2_norm(head); vec2_mul(head, head, 10); + float mag = 10; + float dist = amt*vec2_mag(head); + if (dist < 10) { mag = dist; } + vec2_norm(head); vec2_mul(head, head, mag); SDL_SetRenderDrawColor(rend, b->color[0], b->color[1], @@ -89,16 +89,18 @@ void gst_spawn_bullets (gamestate *gst, fxs *fx, a_dmg dmgs[], int dmgslen, gst_get_maparmy(gst, &m, &ar); bullet b; + + // for every unit count how many shots int counts[MAXUNITS]; for (int j=0;j<MAXUNITS; counts[j]=0, j++); - // for every unit count how many shots - for (int i=0; i<ar->uslen; i++) { for (int j=0; j<dmgslen; j++) { unit *u = ar->us+i; if (dmgs[j].u == u) { counts[i]++; } } } + + // then spawn a bullet for every shot int curr[MAXUNITS]; for (int j=0;j<MAXUNITS; curr[j]=0, j++); for (int i=0; i<ar->uslen; i++) { @@ -111,9 +113,10 @@ void gst_spawn_bullets (gamestate *gst, fxs *fx, a_dmg dmgs[], int dmgslen, b.to[0] = t->pos[0]+16; b.to[1] = t->pos[1]+16; float n = (float)curr[i]/counts[i]; + float travel_time = 0.1; float shot_time = time + n*gst->turnspeed; b.starttime = shot_time; - b.endtime = shot_time + 0.1; + b.endtime = shot_time + travel_time; if (u->owner == 0) { b.color[0] = 0; b.color[1] = 255; b.color[2] = 0; } else { @@ -155,7 +158,6 @@ void gst_process (gamestate *gst, infos *info, fxs *fx, float t) { a_dmg dmgs[1024*8]; int fire = army_fire(info, ar, m, dmgs); army_upkeep(info, ar, m); - printf("%d, %d\n", move, fire); if (move == 0 && fire == 0) { gst->turn_until_finish--; } else { gst->turn_until_finish = 5; } @@ -533,6 +533,7 @@ void info_chassis_parse (char *json, info_chassis *c, jsmntok_t *t, int r, if (strcmp(key, "slot_weapon") == 0) { int rt = json_parse_subtokens(json, t, r, i+1); json_parse_array(json, c->slot_weapon, t+i+2, rt-1, 'i'); + printf("%d %d %d\n", c->slot_weapon[0], c->slot_weapon[1], c->slot_weapon[2]); i += rt; } if (strcmp(key, "slot_armor") == 0) { |