#include "game.h"
#include "raylib.h"
#include <stdio.h>
+#include <math.h>
#define DLGCOUNT 15
#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;
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
//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}
};
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)
{
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?
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 = "";
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);
};
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;
};
};
//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;
};
};
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)
{
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;
};