From: parking_turkeys Date: Mon, 27 Jul 2026 01:05:02 +0000 (-0400) Subject: it works?? like kinda?? the brick wont load tho... but im sure i can fix that!! more... X-Git-Tag: v1.0~5 X-Git-Url: http://git.p-t.hackclub.app/?a=commitdiff_plain;h=326dd3fde975d50091f56fb5cdfd0b143f36ff23;p=aichan-platformer.git it works?? like kinda?? the brick wont load tho... but im sure i can fix that!! more importantly i need to make some ART. every 'dialogue-img/aichan-default' MUST BE REMOVED. --- diff --git a/bossfight.c b/bossfight.c index ea909ac..56092e2 100644 --- a/bossfight.c +++ b/bossfight.c @@ -1,6 +1,7 @@ #include "game.h" #include "raylib.h" #include +#include #define DLGCOUNT 15 @@ -18,6 +19,15 @@ char *DEFAULTANIMFRAME = "dialogue-img/aichan-default.png"; //REPLACE LATER--thi #define ENEMYIMGWIDTH 280 #define ENEMYIMGHEIGHT 360 +#define ATKDISPLAYX 300 +#define ATKDISPLAYY 90 +#define ATKDISPLAYWIDTH 80 +#define ATKDISPLAYPADDING 10 +#define ATKDISPLAYFONTSIZE 10 +#define COOLDOWNDISPLAYCOLOUR (Color){0,0,0,64} + +#define ENABLE_BRICK_DEFAULT 1 //for debug purposes + //int player_atk = 64; //may seem little but. the whole point is to spam. also itll go up later //int brick_atk = 1024; @@ -39,7 +49,7 @@ Texture2D player_img_txtr; struct sp_attack { int keybind; char (*keybind_str); - char *filename; + char *filename; //attack thumbnail char *atkspritesheet; //spritesheet :D (320x240) int animframes; //yeah default to 1 float framelength; //in seconds @@ -62,12 +72,12 @@ struct enemy_attack { //really shouldnt do this all in here but idc static struct sp_attack skills[SKILLCOUNT] = { - { KEY_H, "H", "dialogue-img/aichan-default.png", "dialogue-img/aichan-default.png", 1, 0.0333, 64, 0, 0, 1}, - { KEY_ONE, "1", "dialogue-img/brick.png", "img/brickatk/sheet.png", 3, 0.2, 1024,0,5,0}, + { KEY_H, "H", "dialogue-img/aichan-default.png", "dialogue-img/aichan-default.png", 1, 0.0333, 256, 0, 0, 1}, + { KEY_ONE, "1", "img/brick.png", "img/brickatk/sheet.png", 3, 0.2, 1024,0,5,ENABLE_BRICK_DEFAULT}, }; static struct enemy_attack enemy_skills[ENEMYSKILLCOUNT] = { - { "dialogue-img/aichan-default.png", "attack!", 256, 0, 0.2, 1, 0.1} + { "dialogue-img/aichan-default.png", "attack!", 512, 0, 0.2, 1, 0.1} }; @@ -117,6 +127,7 @@ static int get_player_attack(void); static int get_enemy_attack(void); static int update_player_texture(void); static int update_enemy_texture(void); +static int execute_attack(int atk, int *target_hp); int update_boss_screen(float delta) { @@ -126,7 +137,13 @@ int update_boss_screen(float delta) curr_player_attack = get_player_attack(); curr_enemy_attack = get_enemy_attack(); update_player_texture(); - + update_enemy_texture(); + + if (prome_hp <= 0) { + frozen = 2; + } else if (player_hp <= 0) { + frozen = 3; + }; break; default: //nothing? @@ -135,6 +152,12 @@ int update_boss_screen(float delta) return 1; }; +static int execute_attack(int atk, int *hp) +{ + *hp -= atk; + return 1; +}; + static int update_enemy_texture(void) { static char *last_enemy_texture = ""; @@ -198,6 +221,7 @@ static int update_player_texture(void) last_player_frame = player_img_frame; Image img = LoadImage(player_img_name); ImageCrop(&img, (Rectangle){(PLAYERIMGWIDTH*player_img_frame), 0, PLAYERIMGWIDTH, PLAYERIMGHEIGHT}); + ImageResize(&img, PLAYERIMGWIDTH, PLAYERIMGHEIGHT); player_img_txtr = LoadTextureFromImage(img); UnloadImage(img); }; @@ -231,6 +255,7 @@ static int get_player_attack(void) player_img_time_shown = 0; player_img_frame = 0; skills[i].cooldown_left = skills[i].cooldown_max; + execute_attack(skills[i].atk, &prome_hp); return i; }; }; @@ -245,6 +270,7 @@ static int get_enemy_attack(void) //new attack so reset all of the animation and stuff enemy_img_time_shown = 0; enemy_skills[i].cooldown_left = enemy_skills[i].cooldown_max; + execute_attack(enemy_skills[i].atk, &player_hp); return i; }; }; @@ -287,7 +313,8 @@ int draw_boss_screen(void) static int draw_hp_bar(int hp, int max_hp, Vector2 position); static int draw_enemy_img(void); -static int draw_sp_attack(int cooldown_left, int cooldown_max, char *img_filename, char *keybind); +static int draw_player_img(void); +static int draw_attacks(struct sp_attack (*attack)[SKILLCOUNT]); static int draw_fight_screen(void) { @@ -296,6 +323,67 @@ static int draw_fight_screen(void) draw_hp_bar(prome_hp,PROMEMAXHP, (Vector2){300,40}); draw_enemy_img(); + //draw the player display next!! + draw_hp_bar(player_hp,PLAYERMAXHP,(Vector2){320,420}); + draw_player_img(); + draw_attacks(&skills); + + return 1; +}; + +static int draw_sp_attack(struct sp_attack *attack, Vector2 position); + +static int draw_attacks(struct sp_attack (*a)[SKILLCOUNT]) +{ + Vector2 position = {ATKDISPLAYX, ATKDISPLAYY}; + for (int i = 0; i < SKILLCOUNT; i++) { + if ((*a)[i].enabled) { + + draw_sp_attack((*a)+i, position); + position.x += ATKDISPLAYWIDTH + ATKDISPLAYPADDING; + }; + }; +}; + +static int draw_sp_attack(struct sp_attack *a, Vector2 p) +{ + //get the image, resize, and draw (too lazy to not get the new image each time + //uhhh later when cleaning up this code maybe grab the texture before starting to draw?? + Image img = LoadImage(a->filename); + ImageResize(&img, ATKDISPLAYWIDTH,ATKDISPLAYWIDTH); + Texture2D txtr = LoadTextureFromImage(img); + UnloadImage(img); + DrawTexture(txtr,p.x,p.y,WHITE); + UnloadTexture(txtr); + + //draw the border + Rectangle rect = {p.x,p.y,ATKDISPLAYWIDTH,ATKDISPLAYWIDTH}; + DrawRectangleLinesEx(rect,2,BLACK); + + //draw the cooldown + if (a->cooldown_left > 0) { //otherwise you're drawing nothing lol + rect.height = a->cooldown_left/a->cooldown_max * ATKDISPLAYWIDTH; + rect.y += ATKDISPLAYWIDTH - rect.height; + DrawRectangleRec(rect, COOLDOWNDISPLAYCOLOUR); + }; + + //draw the keybind + int text_width = MeasureText(a->keybind_str, ATKDISPLAYFONTSIZE); + int text_x = p.x + ATKDISPLAYWIDTH/2 - text_width/2; + int text_y = p.y - ATKDISPLAYFONTSIZE/2; + Rectangle text_bg_rec = {text_x - 1, text_y - 1, text_width + 2, ATKDISPLAYFONTSIZE + 2}; + DrawRectangleRec(text_bg_rec, WHITE); //maybe add a border... + DrawText(a->keybind_str, text_x, text_y, ATKDISPLAYFONTSIZE, BLACK); + + //... add it to a list of buttons? maybe later haha +}; + + + + +static int draw_player_img(void) +{ + DrawTexture(player_img_txtr,320,160,WHITE); return 1; };