update enum, add ennemy_stats
This commit is contained in:
parent
b98d3731fa
commit
444b08c72f
|
@ -1,42 +1,77 @@
|
||||||
|
|
||||||
//Jobs
|
enum Jobs {
|
||||||
constexpr const int MAGE = 0;
|
MAGE = 0,
|
||||||
constexpr const int ALCHIMIST = 1;
|
ALCHIMIST = 1,
|
||||||
constexpr const int WARRIOR = 2;
|
WARRIOR = 2,
|
||||||
constexpr const int ENGINEER = 3;
|
ENGINEER = 3,
|
||||||
constexpr const int ARCHER = 4;
|
ARCHER = 4,
|
||||||
constexpr const int TAMER = 5;
|
TAMER = 5
|
||||||
|
};
|
||||||
|
|
||||||
//Elements
|
enum Elements {
|
||||||
constexpr const int FIRE = 0;
|
FIRE = 0,
|
||||||
constexpr const int AIR = 1;
|
AIR = 1,
|
||||||
constexpr const int WATER = 2;
|
WATER = 2,
|
||||||
constexpr const int EARTH = 3;
|
EARTH = 3,
|
||||||
constexpr const int EATHER = 4;
|
EATHER = 4
|
||||||
|
};
|
||||||
|
|
||||||
//Stats
|
enum Stats {
|
||||||
constexpr const int HEALTH = 0;
|
HEALTH,
|
||||||
constexpr const int SHIELD = 1;
|
SHIELD,
|
||||||
constexpr const int SPEED = 2;
|
SPEED,
|
||||||
constexpr const int MANA = 3;
|
MANA,
|
||||||
constexpr const int ENERGY = 4;
|
ENERGY,
|
||||||
constexpr const int TAME = 5;
|
TAME,
|
||||||
constexpr const int XP = 6;
|
XP
|
||||||
|
};
|
||||||
|
|
||||||
// Combinaisons
|
enum Button_types {
|
||||||
|
BUTTON_BASIC,
|
||||||
|
BUTTON_INACTIVE,
|
||||||
|
BUTTON_DANGER
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Button_sizes {
|
||||||
|
BUTTON_SMALL,
|
||||||
|
BUTTON_MEDIUM,
|
||||||
|
BUTTON_BIG
|
||||||
|
};
|
||||||
|
|
||||||
|
//Combinaisons
|
||||||
constexpr const int UP = 0;
|
constexpr const int UP = 0;
|
||||||
constexpr const int RIGHT = 1;
|
constexpr const int RIGHT = 1;
|
||||||
constexpr const int DOWN = 2;
|
constexpr const int DOWN = 2;
|
||||||
constexpr const int LEFT = 3;
|
constexpr const int LEFT = 3;
|
||||||
constexpr const int END_SPELL = 9;
|
constexpr const int END_SPELL = 9;
|
||||||
|
|
||||||
//Buttons style
|
|
||||||
constexpr int BUTTON_BASIC = 0;
|
|
||||||
constexpr int BUTTON_INACTIVE = 1;
|
|
||||||
constexpr int BUTTON_DANGER = 2;
|
|
||||||
|
|
||||||
//Buttons size
|
|
||||||
constexpr const int BUTTON_SMALL = 0;
|
|
||||||
constexpr const int BUTTON_MEDIUM = 1;
|
|
||||||
constexpr const int BUTTON_BIG = 2;
|
|
||||||
|
|
||||||
|
struct Spell {
|
||||||
|
std::string name;
|
||||||
|
int damage;
|
||||||
|
int cost_health, cost_mana;
|
||||||
|
float precision;
|
||||||
|
bool zone;
|
||||||
|
std::vector<Elements> elements;
|
||||||
|
std::vector<int> combinaison;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Ennemy {
|
||||||
|
std::string name;
|
||||||
|
int xp;
|
||||||
|
int health, shield, speed, tame;
|
||||||
|
int max_health, max_shield, max_speed, max_tame;
|
||||||
|
float escape, menace; //Menace comlpexifies the escape, the higher the value is, the less menace it is
|
||||||
|
std::vector<Spell> spells;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Player {
|
||||||
|
std::string name;
|
||||||
|
Jobs job;
|
||||||
|
int xp;
|
||||||
|
int health, shield, speed, mana, energy;
|
||||||
|
int max_health, max_shield, max_speed, max_mana, max_energy;
|
||||||
|
float escape, menace;
|
||||||
|
std::vector<Spell> spell_book;
|
||||||
|
};
|
|
@ -3,19 +3,19 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include "../define.h"
|
#include "../define.h"
|
||||||
#include "../logic/structs.h"
|
|
||||||
#include "../logic/player.h"
|
#include "../logic/player.h"
|
||||||
#include "ui_elements.h"
|
#include "ui_elements.h"
|
||||||
#include "combat_interface.h"
|
#include "combat_interface.h"
|
||||||
|
|
||||||
void display_combat_interface(Player& player_arg, std::vector<Ennemy>& ennemies_arg, const std::vector<int>& screen_arg) {
|
void display_combat_interface(Player& player_arg, std::vector<Ennemy>& ennemies_arg, const std::vector<int>& screen_arg) {
|
||||||
|
|
||||||
|
Ennemy ennemy = ennemies_arg[0];
|
||||||
std::vector<float> position = {0.5f, 0.5f};
|
std::vector<float> position = {0.5f, 0.5f};
|
||||||
Bar player_health = create_bar(HEALTH, player_arg.max_health, player_arg.health, position, screen_arg);
|
Ennemy_stats first_ennemy_stats = create_ennemy_stats(ennemy, position, screen_arg);
|
||||||
inc_health(player_arg, -5);*
|
|
||||||
|
|
||||||
//Dessin
|
//Dessin
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(BLACK);
|
ClearBackground(BLACK);
|
||||||
draw_bar(player_health);
|
draw_ennemy_stats(first_ennemy_stats);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "../logic/structs.h"
|
#include "../define.h"
|
||||||
#include "../logic/player.h"
|
#include "../logic/player.h"
|
||||||
#include "../logic/ennemy.h"
|
#include "../logic/ennemy.h"
|
||||||
#include "interfaces.h"
|
#include "interfaces.h"
|
||||||
|
|
|
@ -2,11 +2,10 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include "../logic/structs.h"
|
|
||||||
#include "../define.h"
|
#include "../define.h"
|
||||||
#include "ui_elements.h"
|
#include "ui_elements.h"
|
||||||
|
|
||||||
Button create_button(int type_arg, int size_arg, const std::vector<float>& position_arg, std::string text_arg, const std::vector<int>& screen_arg) {
|
Button create_button(Button_types type_arg, Button_sizes size_arg, const std::vector<float>& position_arg, std::string text_arg, const std::vector<int>& screen_arg) {
|
||||||
std::vector<float> size = button_size(size_arg, screen_arg);
|
std::vector<float> size = button_size(size_arg, screen_arg);
|
||||||
float position_x = screen_arg[0] * position_arg[0] - size[0] / 2;
|
float position_x = screen_arg[0] * position_arg[0] - size[0] / 2;
|
||||||
float position_y = screen_arg[1] * position_arg[1] - size[1] / 2;
|
float position_y = screen_arg[1] * position_arg[1] - size[1] / 2;
|
||||||
|
@ -52,11 +51,11 @@ Button create_button(int type_arg, int size_arg, const std::vector<float>& posit
|
||||||
void draw_buttons(const std::vector<Button>& buttons_arg) {
|
void draw_buttons(const std::vector<Button>& buttons_arg) {
|
||||||
for(Button button: buttons_arg) {
|
for(Button button: buttons_arg) {
|
||||||
DrawRectangleRec(button.rectangle, button.color);
|
DrawRectangleRec(button.rectangle, button.color);
|
||||||
DrawTextEx(button.text.font, button.text.text.c_str(), button.text.position, button.text.fontSize, button.text.spacing, button.text.tint);
|
draw_text(button.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<float> button_size(int size_arg, const std::vector<int>& screen_arg) {
|
std::vector<float> button_size(Button_sizes size_arg, const std::vector<int>& screen_arg) {
|
||||||
std::vector<float> size;
|
std::vector<float> size;
|
||||||
switch(size_arg) {
|
switch(size_arg) {
|
||||||
case BUTTON_BIG:
|
case BUTTON_BIG:
|
||||||
|
@ -78,7 +77,7 @@ std::vector<float> button_size(int size_arg, const std::vector<int>& screen_arg)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
float text_size(int size_arg) {
|
float text_size(Button_sizes size_arg) {
|
||||||
switch(size_arg) {
|
switch(size_arg) {
|
||||||
case BUTTON_BIG:
|
case BUTTON_BIG:
|
||||||
return 25.0f;
|
return 25.0f;
|
||||||
|
@ -94,7 +93,7 @@ float text_size(int size_arg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Color type_color(int type_arg) {
|
Color type_color(Stats type_arg) {
|
||||||
switch(type_arg) {
|
switch(type_arg) {
|
||||||
case HEALTH:
|
case HEALTH:
|
||||||
return RED;
|
return RED;
|
||||||
|
@ -114,23 +113,23 @@ Color type_color(int type_arg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bar create_bar(int type_arg, int& max_arg, int& actual_arg, const std::vector<float>& position_arg, const std::vector<int>& screen_arg) {
|
Bar create_bar(Stats type_arg, int& max_arg, int& actual_arg, const std::vector<float>& position_arg, const std::vector<int>& container_arg) {
|
||||||
float width = 150.0f;
|
float width = 150.0f;
|
||||||
float height = 15.0f;
|
float height = 15.0f;
|
||||||
float position_x = screen_arg[0] * position_arg[0] - width / 2;
|
float position_x = container_arg[0] * position_arg[0] - width / 2;
|
||||||
float position_y = screen_arg[1] * position_arg[1] - height / 2;
|
float position_y = container_arg[1] * position_arg[1] - height / 2;
|
||||||
Rectangle complete = {position_x, position_y, width, height};
|
Rectangle complete = {position_x, position_y, width, height};
|
||||||
|
|
||||||
float progression_width = (width - 2.0f) * (actual_arg / max_arg);
|
float progression_width = (width - 2.0f) * ((float)actual_arg / max_arg);
|
||||||
float progression_heigth = height - 2.0f;
|
float progression_heigth = height - 2.0f;
|
||||||
Rectangle progression = {position_x+1, position_y+1, progression_width, progression_heigth};
|
Rectangle progression = {position_x+1, position_y+1, progression_width, progression_heigth};
|
||||||
|
|
||||||
Font font = GetFontDefault();
|
Font font = GetFontDefault();
|
||||||
float font_size = 10.0f;
|
float font_size = 10.0f;
|
||||||
std::string value = std::to_string(actual_arg) + "/" + std::to_string(max_arg);
|
std::string value = std::to_string(actual_arg) + "/" + std::to_string(max_arg);
|
||||||
float text_x = screen_arg[0] * position_arg[0] - MeasureText(value.c_str(), font_size) / 2;
|
float text_x = container_arg[0] * position_arg[0] - MeasureText(value.c_str(), font_size) / 2;
|
||||||
float text_y = screen_arg[1] * position_arg[1] - font_size / 2;
|
float text_y = container_arg[1] * position_arg[1] - font_size / 2;
|
||||||
Text text = {font, value, Vector2{text_x, text_y}, font_size, 2.0f, YELLOW};
|
Text text = {font, value, Vector2{text_x, text_y}, font_size, 2.0f, WHITE};
|
||||||
Color color = type_color(type_arg);
|
Color color = type_color(type_arg);
|
||||||
|
|
||||||
return Bar{complete, progression, max_arg, actual_arg, text, color};
|
return Bar{complete, progression, max_arg, actual_arg, text, color};
|
||||||
|
@ -139,9 +138,49 @@ Bar create_bar(int type_arg, int& max_arg, int& actual_arg, const std::vector<fl
|
||||||
void draw_bar(const Bar& bar_arg) {
|
void draw_bar(const Bar& bar_arg) {
|
||||||
DrawRectangleRec(bar_arg.complete, WHITE);
|
DrawRectangleRec(bar_arg.complete, WHITE);
|
||||||
DrawRectangleRec(bar_arg.progression, bar_arg.color);
|
DrawRectangleRec(bar_arg.progression, bar_arg.color);
|
||||||
DrawTextEx(bar_arg.text.font, bar_arg.text.text.c_str(), bar_arg.text.position, bar_arg.text.fontSize, bar_arg.text.spacing, bar_arg.text.tint);
|
draw_text(bar_arg.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ennemy_stats create_bar(const Ennemy& ennemy_arg, const std::vector<float>& position_arg, const std::vector<int>& screen_arg) {
|
Ennemy_stats create_ennemy_stats(Ennemy& ennemy_arg, const std::vector<float>& position_arg, const std::vector<int>& container_arg) {
|
||||||
return Ennemy_stats{};
|
std::vector<float> size = {container_arg[0] * 0.2f, container_arg[1] * 0.1f};
|
||||||
|
float position_x = container_arg[0] * position_arg[0] - size[0] / 2;
|
||||||
|
float position_y = container_arg[1] * position_arg[1] - size[1] / 2;
|
||||||
|
Rectangle card = {position_x, position_y, size[0], size[1]};
|
||||||
|
|
||||||
|
Font font = GetFontDefault();
|
||||||
|
float font_size = 15.0f;
|
||||||
|
std::string value = ennemy_arg.name;
|
||||||
|
Vector2 text_position = {50.f, 0.0f};
|
||||||
|
Text name = {font, value, text_position, font_size, 2.0f, YELLOW};
|
||||||
|
|
||||||
|
text_position.x += MeasureText(value.c_str(), font_size) + value.size() * 2;
|
||||||
|
font_size = 10.0f;
|
||||||
|
value = std::to_string(ennemy_arg.xp);
|
||||||
|
Text level = {font, value, text_position, font_size, 2.0f, YELLOW};
|
||||||
|
|
||||||
|
std::vector<float> health_position = {0.5f, 0.3f};
|
||||||
|
std::vector<float> shield_position = {0.5f, 0.5f};
|
||||||
|
std::vector<float> speed_position = {0.5f, 0.7f};
|
||||||
|
std::vector<float> tame_position = {0.5f, 0.9f};
|
||||||
|
|
||||||
|
Bar health = create_bar(HEALTH, ennemy_arg.max_health, ennemy_arg.health, health_position, container_arg);
|
||||||
|
Bar shield = create_bar(SHIELD, ennemy_arg.max_shield, ennemy_arg.shield, shield_position, container_arg);
|
||||||
|
Bar speed = create_bar(SPEED, ennemy_arg.max_speed, ennemy_arg.speed, speed_position, container_arg);
|
||||||
|
Bar tame = create_bar(TAME, ennemy_arg.max_tame, ennemy_arg.tame, tame_position, container_arg);
|
||||||
|
|
||||||
|
return Ennemy_stats{card, name, level, health, shield, speed, tame};
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_ennemy_stats(const Ennemy_stats& ennemy_stats_arg) {
|
||||||
|
DrawRectangleRec(ennemy_stats_arg.card, BLUE);
|
||||||
|
draw_text(ennemy_stats_arg.name);
|
||||||
|
draw_text(ennemy_stats_arg.level);
|
||||||
|
draw_bar(ennemy_stats_arg.health);
|
||||||
|
draw_bar(ennemy_stats_arg.shield);
|
||||||
|
draw_bar(ennemy_stats_arg.speed);
|
||||||
|
draw_bar(ennemy_stats_arg.tame);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_text(const Text& text_arg) {
|
||||||
|
DrawTextEx(text_arg.font, text_arg.text.c_str(), text_arg.position, text_arg.fontSize, text_arg.spacing, text_arg.tint);
|
||||||
}
|
}
|
|
@ -21,16 +21,21 @@ struct Bar {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Ennemy_stats {
|
struct Ennemy_stats {
|
||||||
|
Rectangle card;
|
||||||
Text name, level;
|
Text name, level;
|
||||||
Bar health, shield, speed, tame;
|
Bar health, shield, speed, tame;
|
||||||
};
|
};
|
||||||
|
|
||||||
Button create_button(int type_arg, int size_arg, const std::vector<float>& position_arg, std::string text_arg, const std::vector<int>& screen_arg);
|
Button create_button(Button_types type_arg, Button_sizes size_arg, const std::vector<float>& position_arg, std::string text_arg, const std::vector<int>& screen_arg);
|
||||||
void draw_buttons(const std::vector<Button>& buttons_arg);
|
void draw_buttons(const std::vector<Button>& buttons_arg);
|
||||||
std::vector<float> button_size(int size_arg, const std::vector<int>& screen_arg);
|
std::vector<float> button_size(Button_sizes size_arg, const std::vector<int>& screen_arg);
|
||||||
float text_size(int size_arg);
|
float text_size(Button_sizes size_arg);
|
||||||
|
Color type_color(Stats type_arg);
|
||||||
|
|
||||||
Bar create_bar(int type_arg, int& max_arg, int& actual_arg, const std::vector<float>& position_arg, const std::vector<int>& screen_arg);
|
Bar create_bar(Stats type_arg, int& max_arg, int& actual_arg, const std::vector<float>& position_arg, const std::vector<int>& container_arg);
|
||||||
void draw_bar(const Bar& bar_arg);
|
void draw_bar(const Bar& bar_arg);
|
||||||
|
|
||||||
Ennemy_stats create_bar(const Ennemy& ennemy_arg, const std::vector<float>& position_arg, const std::vector<int>& screen_arg);
|
Ennemy_stats create_ennemy_stats(Ennemy& ennemy_arg, const std::vector<float>& position_arg, const std::vector<int>& container_arg);
|
||||||
|
void draw_ennemy_stats(const Ennemy_stats& ennemy_stats_arg);
|
||||||
|
|
||||||
|
void draw_text(const Text& text_arg);
|
|
@ -1,6 +1,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "structs.h"
|
#include "../define.h"
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "ennemy.h"
|
#include "ennemy.h"
|
||||||
|
@ -13,6 +13,7 @@ void init_combat(Player& player_arg, std::vector<Ennemy> ennemies_arg, const std
|
||||||
std::vector<Ennemy> ennemies;
|
std::vector<Ennemy> ennemies;
|
||||||
ennemies.push_back(ennemies_arg[1]);
|
ennemies.push_back(ennemies_arg[1]);
|
||||||
ennemies.push_back(ennemies_arg[2]);
|
ennemies.push_back(ennemies_arg[2]);
|
||||||
|
inc_health(player_arg,-5);
|
||||||
|
|
||||||
display_combat_interface(player_arg, ennemies, screen_arg);
|
display_combat_interface(player_arg, ennemies, screen_arg);
|
||||||
combat(player_arg, ennemies);
|
combat(player_arg, ennemies);
|
||||||
|
@ -92,7 +93,7 @@ void ennemy_turn(Player& player_arg, Ennemy& ennemy_arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void attack(Player& player_arg, std::vector<Ennemy>& ennemies_arg){
|
void attack(Player& player_arg, std::vector<Ennemy>& ennemies_arg){
|
||||||
if(player_arg.job == 0) {
|
if(player_arg.job == MAGE) {
|
||||||
casting_spell(player_arg, ennemies_arg);
|
casting_spell(player_arg, ennemies_arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "structs.h"
|
#include "../define.h"
|
||||||
#include "ennemy.h"
|
#include "ennemy.h"
|
||||||
#include "spells.h"
|
#include "spells.h"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "structs.h"
|
|
||||||
#include "../define.h"
|
#include "../define.h"
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
#include "structs.h"
|
|
||||||
#include "../define.h"
|
#include "../define.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "ennemy.h"
|
#include "ennemy.h"
|
||||||
|
@ -12,7 +11,7 @@
|
||||||
const std::vector<std::string> elements = {"Fire", "Air", "Water", "Earth", "Eather"};
|
const std::vector<std::string> elements = {"Fire", "Air", "Water", "Earth", "Eather"};
|
||||||
const std::vector<std::string> arrows = {"↑", "→", "↓", "←"};
|
const std::vector<std::string> arrows = {"↑", "→", "↓", "←"};
|
||||||
|
|
||||||
void init_spell(Spell& spell_arg, const std::string& name_arg, int damage_arg, int cost_arg, float precision_arg, bool zone_arg, std::vector<int> elements_arg, std::vector<int> combinaison_arg) {
|
void init_spell(Spell& spell_arg, const std::string& name_arg, int damage_arg, int cost_arg, float precision_arg, bool zone_arg, std::vector<Elements> elements_arg, std::vector<int> combinaison_arg) {
|
||||||
spell_arg.name = name_arg;
|
spell_arg.name = name_arg;
|
||||||
spell_arg.damage = damage_arg;
|
spell_arg.damage = damage_arg;
|
||||||
spell_arg.cost_mana = cost_arg;
|
spell_arg.cost_mana = cost_arg;
|
||||||
|
@ -32,7 +31,7 @@ void init_spells(std::vector<Spell>& spell_book_arg) {
|
||||||
5,
|
5,
|
||||||
0.8,
|
0.8,
|
||||||
1,
|
1,
|
||||||
std::vector<int>{FIRE},
|
std::vector<Elements>{FIRE},
|
||||||
std::vector<int>{UP, RIGHT, UP}
|
std::vector<int>{UP, RIGHT, UP}
|
||||||
);
|
);
|
||||||
spell_book_arg.push_back(fire_ball);
|
spell_book_arg.push_back(fire_ball);
|
||||||
|
@ -45,7 +44,7 @@ void init_spells(std::vector<Spell>& spell_book_arg) {
|
||||||
8,
|
8,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
std::vector<int>{WATER},
|
std::vector<Elements>{WATER},
|
||||||
std::vector<int>{UP, DOWN, RIGHT}
|
std::vector<int>{UP, DOWN, RIGHT}
|
||||||
);
|
);
|
||||||
spell_book_arg.push_back(tsunami);
|
spell_book_arg.push_back(tsunami);
|
||||||
|
@ -58,7 +57,7 @@ void init_spells(std::vector<Spell>& spell_book_arg) {
|
||||||
4,
|
4,
|
||||||
0.8,
|
0.8,
|
||||||
0,
|
0,
|
||||||
std::vector<int>{AIR},
|
std::vector<Elements>{AIR},
|
||||||
std::vector<int>{UP, UP, UP}
|
std::vector<int>{UP, UP, UP}
|
||||||
);
|
);
|
||||||
spell_book_arg.push_back(tailwind_css);
|
spell_book_arg.push_back(tailwind_css);
|
||||||
|
@ -71,7 +70,7 @@ void init_spells(std::vector<Spell>& spell_book_arg) {
|
||||||
13,
|
13,
|
||||||
0.7,
|
0.7,
|
||||||
0,
|
0,
|
||||||
std::vector<int>{EARTH},
|
std::vector<Elements>{EARTH},
|
||||||
std::vector<int>{DOWN, UP, LEFT}
|
std::vector<int>{DOWN, UP, LEFT}
|
||||||
);
|
);
|
||||||
spell_book_arg.push_back(rolling_rock);
|
spell_book_arg.push_back(rolling_rock);
|
||||||
|
@ -84,7 +83,7 @@ void init_spells(std::vector<Spell>& spell_book_arg) {
|
||||||
10,
|
10,
|
||||||
0.8,
|
0.8,
|
||||||
0,
|
0,
|
||||||
std::vector<int>{AIR, FIRE},
|
std::vector<Elements>{AIR, FIRE},
|
||||||
std::vector<int>{DOWN, UP, LEFT, UP}
|
std::vector<int>{DOWN, UP, LEFT, UP}
|
||||||
);
|
);
|
||||||
spell_book_arg.push_back(lightning);
|
spell_book_arg.push_back(lightning);
|
||||||
|
@ -97,7 +96,7 @@ void init_spells(std::vector<Spell>& spell_book_arg) {
|
||||||
2,
|
2,
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
std::vector<int>{AIR, WATER},
|
std::vector<Elements>{AIR, WATER},
|
||||||
std::vector<int>{UP, UP, UP, UP}
|
std::vector<int>{UP, UP, UP, UP}
|
||||||
);
|
);
|
||||||
spell_book_arg.push_back(bubble);
|
spell_book_arg.push_back(bubble);
|
||||||
|
|
|
@ -5,7 +5,7 @@ void init_spell(Spell& spell_arg,
|
||||||
int cost_arg,
|
int cost_arg,
|
||||||
float precision_arg,
|
float precision_arg,
|
||||||
bool zone_arg,
|
bool zone_arg,
|
||||||
std::vector<int> elements_arg,
|
std::vector<Elements> elements_arg,
|
||||||
std::vector<int> combinaison_arg
|
std::vector<int> combinaison_arg
|
||||||
);
|
);
|
||||||
void init_spells(std::vector<Spell>& spell_book_arg);
|
void init_spells(std::vector<Spell>& spell_book_arg);
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
|
|
||||||
struct Spell {
|
|
||||||
std::string name;
|
|
||||||
int damage;
|
|
||||||
int cost_health, cost_mana;
|
|
||||||
float precision;
|
|
||||||
bool zone;
|
|
||||||
std::vector<int> elements, combinaison;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Ennemy {
|
|
||||||
std::string name;
|
|
||||||
int xp;
|
|
||||||
int health, shield, speed, tame;
|
|
||||||
int max_health, max_shield, max_speed, max_tame;
|
|
||||||
float escape, menace; //Menace comlpexifies the escape, the higher the value is, the less menace it is
|
|
||||||
std::vector<Spell> spells;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Player {
|
|
||||||
std::string name;
|
|
||||||
int job, xp;
|
|
||||||
int health, shield, speed, mana, energy;
|
|
||||||
int max_health, max_shield, max_speed, max_mana, max_energy;
|
|
||||||
float escape, menace;
|
|
||||||
std::vector<Spell> spell_book;
|
|
||||||
};
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "logic/structs.h"
|
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
#include "logic/player.h"
|
#include "logic/player.h"
|
||||||
#include "logic/ennemy.h"
|
#include "logic/ennemy.h"
|
||||||
|
@ -10,11 +9,18 @@
|
||||||
#include "logic/combat.h"
|
#include "logic/combat.h"
|
||||||
#include "interface/ui_elements.h"
|
#include "interface/ui_elements.h"
|
||||||
|
|
||||||
|
void create_menu(std::vector<Button>& buttons_arg, const std::vector<int>& screen_arg) {
|
||||||
|
buttons_arg.push_back(create_button(BUTTON_BASIC, BUTTON_BIG, std::vector<float>{0.5, 0.5}, "Play", screen_arg));
|
||||||
|
buttons_arg.push_back(create_button(BUTTON_INACTIVE, BUTTON_MEDIUM, std::vector<float>{0.5, 0.6}, "Options", screen_arg));
|
||||||
|
buttons_arg.push_back(create_button(BUTTON_DANGER, BUTTON_MEDIUM, std::vector<float>{0.5, 0.7}, "Quit", screen_arg));
|
||||||
|
}
|
||||||
|
|
||||||
void handle_menu(std::vector<Button>& buttons_arg, Player& player_arg, std::vector<Ennemy>& ennemies_arg, bool& game_loop_arg, const std::vector<int>& screen_arg) {
|
void handle_menu(std::vector<Button>& buttons_arg, Player& player_arg, std::vector<Ennemy>& ennemies_arg, bool& game_loop_arg, const std::vector<int>& screen_arg) {
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
|
||||||
if (CheckCollisionPointRec(GetMousePosition(), buttons_arg[0].rectangle)) {
|
if (CheckCollisionPointRec(GetMousePosition(), buttons_arg[0].rectangle)) {
|
||||||
buttons_arg = {};
|
buttons_arg = {};
|
||||||
init_combat(player_arg, ennemies_arg, screen_arg);
|
init_combat(player_arg, ennemies_arg, screen_arg);
|
||||||
|
create_menu(buttons_arg, screen_arg);
|
||||||
} else if (CheckCollisionPointRec(GetMousePosition(), buttons_arg[2].rectangle)) {
|
} else if (CheckCollisionPointRec(GetMousePosition(), buttons_arg[2].rectangle)) {
|
||||||
game_loop_arg = 0;
|
game_loop_arg = 0;
|
||||||
}
|
}
|
||||||
|
@ -40,9 +46,7 @@ int main() {
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
|
|
||||||
std::vector<Button> buttons;
|
std::vector<Button> buttons;
|
||||||
buttons.push_back(create_button(BUTTON_BASIC, BUTTON_BIG, std::vector<float>{0.5, 0.5}, "Play", screen));
|
create_menu(buttons, screen);
|
||||||
buttons.push_back(create_button(BUTTON_INACTIVE, BUTTON_MEDIUM, std::vector<float>{0.5, 0.6}, "Options", screen));
|
|
||||||
buttons.push_back(create_button(BUTTON_DANGER, BUTTON_MEDIUM, std::vector<float>{0.5, 0.7}, "Quit", screen));
|
|
||||||
|
|
||||||
int arg;
|
int arg;
|
||||||
bool game_loop = 1;
|
bool game_loop = 1;
|
||||||
|
|
BIN
game/release
BIN
game/release
Binary file not shown.
Loading…
Reference in New Issue