From eb2a4def6a5ca0198bcb7b60ca03e31115b77e46 Mon Sep 17 00:00:00 2001 From: stevenhowes <38082088+stevenhowes@users.noreply.github.com> Date: Mon, 22 Mar 2021 22:25:00 +0000 Subject: [PATCH] Varying projectile speeds and styles --- !RunImage,ff8 | Bin 14484 -> 14784 bytes Spr,ff9 | Bin 77784 -> 79376 bytes c/CTheEscape | 80 ++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 67 insertions(+), 13 deletions(-) diff --git a/!RunImage,ff8 b/!RunImage,ff8 index 42fea0239562a09f94c5322147f30fc7f071239c..0a86b97da522add9b45ad8c7d8a0fe564a4e89ec 100644 GIT binary patch delta 6088 zcma)A3vg6bn*Q(Y?xYhs^bP4Goure#2_Xas(!?Nf3ZVn6BLOkI93C|oM%3UkRv4Lw zvohTsI|#erBsmF>GE6QrTEmPw#Y+SQ3`%Bj939wN)LC%6x37nXtqzv#7Rw5~-|4;` zy4;;DQ+0Cw$9K;8&wu{&pZ|96y1~b*h%`eq7g0RwqIf>h-;_q8y%Ht=mKN`;YL-T} zuU+-{_g77(RL>rjD&~CXqSq*>nRe35k8&ygvH#~W3G_wK251@d$DscT+6LMHeGat1 z{}r@j1bFw)V}0z5RFIPc?ku=x*lxKXPX>1?sG09VvN5T@juEH8g_8O&!IjL{%oC9O zIH`|A@*24Iq+YDM?LN&s2uWK~e;$(Gfm@Z-p9NQs@xO*-SyKNFBs;(@OzM9R?mEWr zgrr&M^NvF@7bAKgnJF;&hag!Aj5IeI`)5e+6u8h!kp2LcXU&VoegWMzotXMz1xOhN%u*|Q?22r}XM?~!Kyhb8aJr81LM zI(`*;cLbujWv?N%Ylhsa8MdHic*D~nNbBFao#KCOLBP-p!$r;wO zDX3o?L7_OVl2He6?bpCwfXM=90sNUbHQLH$s*aJe3lml1+J*H=*d8gGk%I*W1f~l? z2fkm>m|MsNeut$SBp6|>l}(`*gMzEyu%F%<+moSKja_9?i*ekwOG0`8%#zdX@ zo%)mN0GIMRbfOdd+jh;6&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c/CTheEscape b/c/CTheEscape index b01ad5a..baeb5e7 100644 --- a/c/CTheEscape +++ b/c/CTheEscape @@ -24,8 +24,8 @@ extern int current_element; #define MAX_STARS 49 #define MAX_PROJECTILES 10 -enum sprite_e{player_ship, durno_ship, ship_trgt, durno_ship2, ship2_trgt, player_shipl,player_shipr,explode_start,explode_shp2,explode_shp3,explode_shp4,explode_shp5,explode_shp6,explode_shp7,explode_end,photon1,photon2}; -char *sprites[] = {"player_ship","durno_ship","ship_trgt","durno_ship2","ship2_trgt","player_shipl","player_shipr","explode_shp1","explode_shp2","explode_shp3","explode_shp4","explode_shp5","explode_shp6","explode_shp7","explode_shp8","photon1","photon2"}; +enum sprite_e{player_ship, durno_ship, ship_trgt, durno_ship2, ship2_trgt, player_shipl,player_shipr,explode_start,explode_shp2,explode_shp3,explode_shp4,explode_shp5,explode_shp6,explode_shp7,explode_end,photon1,photon2,plasma1,plasma2}; +char *sprites[] = {"player_ship","durno_ship","ship_trgt","durno_ship2","ship2_trgt","player_shipl","player_shipr","explode_shp1","explode_shp2","explode_shp3","explode_shp4","explode_shp5","explode_shp6","explode_shp7","explode_shp8","photon1","photon2","plasma1","plasma2"}; char hudbuffer[63]; @@ -48,6 +48,8 @@ struct NPC_s { struct EntityLocation_s location; enum sprite_e idlesprite; enum sprite_e sprite; + enum sprite_e weaponspritestart; + enum sprite_e weaponspriteend; enum npctype_e npctype; struct EntityLocation_s velocity; int health; @@ -58,6 +60,7 @@ struct NPC_s { int explodenextframe; int nextfire; int fireinterval; + int firewidth; }; struct Star_s { @@ -90,6 +93,8 @@ struct Player_s { struct Projectile_s { struct EntityLocation_s location; enum sprite_e sprite; + enum sprite_e spritestart; + enum sprite_e spriteend; struct EntityLocation_s velocity; int collidable; int nextframe; @@ -102,6 +107,7 @@ struct NPC_s NPCS[MAX_NPCS]; struct Projectile_s Projectiles[MAX_PROJECTILES]; struct Player_s Player; +extern void game_respawn_npc(int id); int tick = 0; int lasttick = 0; @@ -182,7 +188,7 @@ void intro() } } -void game_spawn_projectile(int id, int Px, int Py, int Vx, int Vy,enum sprite_e sprite, int damage) +void game_spawn_projectile(int id, int Px, int Py, int Vx, int Vy, enum sprite_e spritestart, enum sprite_e spriteend, int damage) { int i; @@ -198,17 +204,20 @@ void game_spawn_projectile(int id, int Px, int Py, int Vx, int Vy,enum sprite_e // If no velocity X specified we're targetting the player if(Vx == 0) { + int V; int Xdistance = abs((Player.location.X + (Player.hitbox_tr.X/2)) - Px); int Ydistance = abs((Player.location.Y + (Player.hitbox_tr.Y/2)) - Py); int distance = sqrt((Xdistance^2) + (Ydistance^2)); - Vx = Xdistance / (distance / 10); - Vy = Ydistance / (distance / 10); + V = Vy; + Vx = Xdistance / (distance / Vy); + Vy = Ydistance / (distance / Vy); + if(Player.location.X > Px) Vx = 0 - Vx; } // If it's too close to horizontal you can't dodge - if(Vy < 2) + if(Py < (Player.location.X + 100)) id = -1; //If no free IDs then we go without @@ -219,7 +228,9 @@ void game_spawn_projectile(int id, int Px, int Py, int Vx, int Vy,enum sprite_e Projectiles[id].velocity.X = Vx; Projectiles[id].velocity.Y = Vy; Projectiles[id].active = 1; - Projectiles[id].sprite = sprite; + Projectiles[id].sprite = spritestart; + Projectiles[id].spritestart = spritestart; + Projectiles[id].spriteend = spriteend; Projectiles[id].nextframe = tick + 10; Projectiles[id].damage = damage; Projectiles[id].collidable = 1; @@ -372,6 +383,9 @@ void game_draw_projectiles() continue; draw_sprite(sprites[Projectiles[i].sprite], Projectiles[i].location.X,Projectiles[i].location.Y); + Projectiles[i].sprite++; + if(Projectiles[i].sprite > Projectiles[i].spriteend) + Projectiles[i].sprite = Projectiles[i].spritestart; } } @@ -452,9 +466,11 @@ void game_respawn_npc(int id) { NPCS[id].location.X = rand() % DISPLAY_X; NPCS[id].location.Y = DISPLAY_Y + (rand() % (DISPLAY_Y/2)); - NPCS[id].npctype = rand() % (maxnpctype); + if((rand() % 10) > 3) + NPCS[id].npctype = littledurno; + else + NPCS[id].npctype = bigdurno; NPCS[id].collidable = 1; - NPCS[id].fireinterval = 200; NPCS[id].nextfire = tick + (rand() % 100); switch(NPCS[id].npctype) { @@ -469,18 +485,26 @@ void game_respawn_npc(int id) NPCS[id].hitbox_tr.X = 48; NPCS[id].hitbox_tr.Y = 74; NPCS[id].collideforce = 1000; + NPCS[id].weaponspritestart = photon1; + NPCS[id].weaponspriteend = photon2; + NPCS[id].fireinterval = 200; + NPCS[id].firewidth = 400; break; case littledurno: NPCS[id].idlesprite = durno_ship2; NPCS[id].sprite = durno_ship2; - NPCS[id].velocity.X = (rand() % 3) - 1; - NPCS[id].velocity.Y = (rand() % 2) + 6; + NPCS[id].velocity.X = (rand() % 3) + 2; + NPCS[id].velocity.Y = (rand() % 2) + 3; NPCS[id].health = 30; NPCS[id].hitbox_bl.X = 0; NPCS[id].hitbox_bl.Y = 0; NPCS[id].hitbox_tr.X = 38; NPCS[id].hitbox_tr.Y = 56; NPCS[id].collideforce = 50; + NPCS[id].weaponspritestart = plasma1; + NPCS[id].weaponspriteend = plasma2; + NPCS[id].fireinterval = 10; + NPCS[id].firewidth = 60; break; }; } @@ -502,6 +526,25 @@ void game_tick_npcs() NPCS[i].location.Y -= (tick - lasttick) * NPCS[i].velocity.Y; NPCS[i].location.X -= (tick - lasttick) * NPCS[i].velocity.X; + if(NPCS[i].npctype == littledurno) + { + if(NPCS[i].location.Y > (Player.location.Y + 500)) + { + if(abs(NPCS[i].location.X - Player.location.X) > 100) + { + if(NPCS[i].location.X < Player.location.X) + NPCS[i].velocity.X = 0 - abs(NPCS[i].velocity.X); + else + NPCS[i].velocity.X = abs(NPCS[i].velocity.X); + } + }else{ + if(NPCS[i].velocity.X > 0) + NPCS[i].velocity.X = 1; + else + NPCS[i].velocity.X = -1; + } + } + if(NPCS[i].location.Y + NPCS[i].hitbox_tr.Y <= 0) game_respawn_npc(i); @@ -510,12 +553,21 @@ void game_tick_npcs() if((NPCS[i].location.X + NPCS[i].hitbox_bl.X) < 0) game_respawn_npc(i); + if(tick > NPCS[i].nextfire) { // Dont fire if off screen if((NPCS[i].location.Y < DISPLAY_Y)) - game_spawn_projectile(-1,NPCS[i].location.X, NPCS[i].location.Y, 0, NPCS[i].velocity.Y, photon1, 30); - NPCS[i].nextfire = tick + NPCS[i].fireinterval; + { + if((NPCS[i].firewidth == -1) || (abs(Player.location.X - NPCS[i].location.X) < NPCS[i].firewidth)) + { + if(NPCS[i].weaponspritestart == photon1) + game_spawn_projectile(-1,NPCS[i].location.X, NPCS[i].location.Y, 0, 10, NPCS[i].weaponspritestart, NPCS[i].weaponspriteend, 50); + else + game_spawn_projectile(-1,NPCS[i].location.X, NPCS[i].location.Y, 0, 40, NPCS[i].weaponspritestart, NPCS[i].weaponspriteend, 5); + NPCS[i].nextfire = tick + NPCS[i].fireinterval; + } + } } } } @@ -653,6 +705,8 @@ void game_player_targets_tick() { if(!NPCS[i].collidable) continue; + if(NPCS[i].location.Y > (DISPLAY_Y-200)) + continue; LeftCornerX = NPCS[i].location.X + NPCS[i].hitbox_bl.X; LeftCornerY = NPCS[i].location.Y + NPCS[i].hitbox_bl.Y; RightCornerX = NPCS[i].location.X + NPCS[i].hitbox_tr.X;