Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

naming convention #79

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions include/entity/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "../utils/random.h"

#define _DEFAULT_INVULNERABILITY_TIME_ 1000;
#define _REPULSIVE_FORCE_ 10;

// Entity structure for storing the required information
typedef struct Entity {
Expand All @@ -33,8 +34,6 @@ typedef struct Entity {
// Vector2 velocity
ivec2 vel;

//TODO create function to calc max hp and max mana, cause as i assume similar function will be used for all entities

// Stats
Statblock base_stats;
// Layer
Expand Down
104 changes: 52 additions & 52 deletions include/entity/entity_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,63 +19,63 @@
#include "prototypes/necromancer.h"

// Macros for creating ninja skeleton entity
#define _SKELETON_NINJA_ENTITY_(X, Y) \
entityReload((Entity){ \
.position = newIVec2(X << POSITION_FIXED_SCALAR, Y << POSITION_FIXED_SCALAR), \
\
.layer = ENEMY, \
.base_stats = stats(1, 3, 0, 0, 0), \
.sprite_offset = 24, \
.update_callback = &skeletonNinjaUpdate, \
.on_collision_enter = &checkCollision, \
.die_callback = &skeletonNinjaKill, \
.calculate_damage_callback = &skeletonNinjaCalculateDamage, \
.dodge_callback = &skeletonNinjaTryDodge \
}) \
#define _SKELETON_NINJA_ENTITY_(X, Y) \
entityReload((Entity){ \
.position = newIVec2(X << _POSITION_FIXED_SCALAR_, Y << _POSITION_FIXED_SCALAR_), \
\
.layer = ENEMY, \
.base_stats = statsInit(1, 3, 0, 0, 0), \
.sprite_offset = 24, \
.update_callback = &skeletonNinjaUpdate, \
.on_collision_enter = &checkCollision, \
.die_callback = &skeletonNinjaKill, \
.calculate_damage_callback = &skeletonNinjaCalculateDamage, \
.dodge_callback = &skeletonNinjaTryDodge \
}) \

// Macros for creating king skeleton entity
#define _SKELETON_KING_ENTITY_(X, Y) \
entityReload((Entity){ \
.position = newIVec2(X << POSITION_FIXED_SCALAR, Y << POSITION_FIXED_SCALAR), \
\
.layer = ENEMY, \
.base_stats = stats(3, 0, 0, 1, 0), \
.sprite_offset = 48, \
.update_callback = &skeletonKingUpdate, \
.on_collision_enter = &checkCollision, \
.die_callback = &skeletonKingKill, \
.calculate_damage_callback = &skeletonKingCalculateDamage, \
.dodge_callback = &skeletonKingTryDodge \
}) \
#define _SKELETON_KING_ENTITY_(X, Y) \
entityReload((Entity){ \
.position = newIVec2(X << _POSITION_FIXED_SCALAR_, Y << _POSITION_FIXED_SCALAR_), \
\
.layer = ENEMY, \
.base_stats = statsInit(3, 0, 0, 1, 0), \
.sprite_offset = 48, \
.update_callback = &skeletonKingUpdate, \
.on_collision_enter = &checkCollision, \
.die_callback = &skeletonKingKill, \
.calculate_damage_callback = &skeletonKingCalculateDamage, \
.dodge_callback = &skeletonKingTryDodge \
}) \

// Macros for creating ancient skeleton entity
#define _SKELETON_ANCIENT_ENTITY_(X, Y) \
entityReload((Entity){ \
.position = newIVec2(X << POSITION_FIXED_SCALAR, Y << POSITION_FIXED_SCALAR), \
\
.layer = ENEMY, \
.base_stats = stats(1, 1, 0, 0, 0), \
.sprite_offset = 72, \
.update_callback = &skeletonAncientUpdate, \
.on_collision_enter = &checkCollision, \
.die_callback = &skeletonAncientKill, \
.calculate_damage_callback = &skeletonAncientCalculateDamage, \
.dodge_callback = &skeletonAncientTryDodge \
}) \
#define _SKELETON_ANCIENT_ENTITY_(X, Y) \
entityReload((Entity){ \
.position = newIVec2(X << _POSITION_FIXED_SCALAR_, Y << _POSITION_FIXED_SCALAR_), \
\
.layer = ENEMY, \
.base_stats = statsInit(1, 1, 0, 0, 0), \
.sprite_offset = 72, \
.update_callback = &skeletonAncientUpdate, \
.on_collision_enter = &checkCollision, \
.die_callback = &skeletonAncientKill, \
.calculate_damage_callback = &skeletonAncientCalculateDamage, \
.dodge_callback = &skeletonAncientTryDodge \
}) \

// Macros for creating necromancer entity
#define _NECROMANCER_ENTITY_(X, Y) \
entityReload((Entity){ \
.position = newIVec2(X << POSITION_FIXED_SCALAR, Y << POSITION_FIXED_SCALAR), \
\
.layer = ENEMY, \
.base_stats = stats(2, 1, 1, 0, 0), \
.sprite_offset = 96, \
.update_callback = &necromancerUpdate, \
.on_collision_enter = &checkCollision, \
.die_callback = &necromancerKill, \
.calculate_damage_callback = &necromancerCalculateDamage, \
.dodge_callback = &necromancerTryDodge \
}) \
#define _NECROMANCER_ENTITY_(X, Y) \
entityReload((Entity){ \
.position = newIVec2(X << _POSITION_FIXED_SCALAR_, Y << _POSITION_FIXED_SCALAR_), \
\
.layer = ENEMY, \
.base_stats = statsInit(2, 1, 1, 0, 0), \
.sprite_offset = 96, \
.update_callback = &necromancerUpdate, \
.on_collision_enter = &checkCollision, \
.die_callback = &necromancerKill, \
.calculate_damage_callback = &necromancerCalculateDamage, \
.dodge_callback = &necromancerTryDodge \
}) \

#endif
6 changes: 3 additions & 3 deletions include/entity/prototypes/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "../../world/world.h"

/* Max amount of health shown in one row */
#define HEALTH_PER_ROW 7
#define _HEALTH_PER_ROW_ 7

// Enum for storing existing classes
typedef enum Class {
Expand Down Expand Up @@ -57,7 +57,7 @@ typedef struct PlayerSpecData {
* @param _entity Existing player
* @param _pspec Allocated player specs
* @param _ui UI
* @param chosenClass class
* @param _chosenClass class
*/
void initPlayerSpec(Sprite* _sprites, i32* _next_sprite_index, Entity* _entity, PlayerSpecData* _pspec, Class _chosenClass);

Expand Down Expand Up @@ -92,6 +92,6 @@ void killPlayer(Entity* _self);
* @param _world existing world
* @param _room existing room
*/
void player_update(Entity* _self, World* _world, Room* _room);
void playerUpdate(Entity* _self, World* _world, Room* _room);

#endif
2 changes: 1 addition & 1 deletion include/entity/prototypes/projectile.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "../../utils/types.h"
#include "../../world/world.h"

#include "../../utils/logger.h"
#define _PROJECTILE_SPEED_ 6

/**
* Initialize projectile
Expand Down
2 changes: 1 addition & 1 deletion include/entity/rotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ typedef enum Facing {
* @param facing Facing side
* @return Opposite facing side
*/
Facing getOppositeFacing(Facing facing);
Facing getOppositeFacing(Facing _facing);

#endif
12 changes: 1 addition & 11 deletions include/entity/statblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,6 @@ typedef struct Statblock {
* @param _armor Armor stat
* @return Instance of the new stat block
*/
Statblock stats(stattype _stamina, stattype _agility, stattype _intellect, stattype _strength, stattype _armor);


/**
* Sums up to stat blocks
*
* @param _a First stat block
* @param _b Second stat block
* @return Instance of the new stat block
*/
Statblock sumStatblock(Statblock _a, Statblock _b);
Statblock statsInit(stattype _stamina, stattype _agility, stattype _intellect, stattype _strength, stattype _armor);

#endif
36 changes: 18 additions & 18 deletions include/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,29 @@ void itemDropUnloadSprite(ItemDrop *_itemDrop);
Item itemInit(Statblock _stat, u32 _sprite_offset, ItemType _type);

/* Macros for all items in the game */
#define _IRON_CHESTPLATE_ITEM_ itemInit(stats(0, 0, 0, 0, 1), 112, ARMOR)
#define _GOLDEN_CHESTPLATE_ITEM_ itemInit(stats(1, 0, 0, 0, 2), 136, ARMOR)
#define _DIAMOND_CHESTPLATE_ITEM_ itemInit(stats(2, 0, 0, 0, 3), 160, ARMOR)
#define _IRON_CHESTPLATE_ITEM_ itemInit(statsInit(0, 0, 0, 0, 1), 112, ARMOR)
#define _GOLDEN_CHESTPLATE_ITEM_ itemInit(statsInit(1, 0, 0, 0, 2), 136, ARMOR)
#define _DIAMOND_CHESTPLATE_ITEM_ itemInit(statsInit(2, 0, 0, 0, 3), 160, ARMOR)

#define _SHORT_SWORD_ITEM_ itemInit(stats(0, 0, 0, 1, 0), 184, WEAPON)
#define _DARK_CLAYMORE_ITEM_ itemInit(stats(0, 0, 0, 2, 0), 208, WEAPON)
#define _ICE_SWORD_ITEM_ itemInit(stats(0, 1, 0, 1, 0), 232, WEAPON)
#define _SHORT_SWORD_ITEM_ itemInit(statsInit(0, 0, 0, 1, 0), 184, WEAPON)
#define _DARK_CLAYMORE_ITEM_ itemInit(statsInit(0, 0, 0, 2, 0), 208, WEAPON)
#define _ICE_SWORD_ITEM_ itemInit(statsInit(0, 1, 0, 1, 0), 232, WEAPON)

#define _PURPLE_MAGE_ARMOR_ITEM_ itemInit(stats(0, 0, 0, 0, 1), 336, ARMOR)
#define _RED_MAGE_ARMOR_ITEM_ itemInit(stats(0, 0, 0, 0, 1), 360, ARMOR)
#define _ENCHANTER_MAGE_ARMOR_ITEM_ itemInit(stats(0, 0, 0, 0, 1), 384, ARMOR)
#define _PURPLE_MAGE_ARMOR_ITEM_ itemInit(statsInit(0, 0, 0, 0, 1), 336, ARMOR)
#define _RED_MAGE_ARMOR_ITEM_ itemInit(statsInit(1, 0, 1, 0, 1), 360, ARMOR)
#define _ENCHANTER_MAGE_ARMOR_ITEM_ itemInit(statsInit(2, 0, 1, 0, 2), 384, ARMOR)

#define _ARCHER_IRON_ARMOR_ITEM_ itemInit(stats(0, 0, 0, 0, 1), 768, ARMOR)
#define _ARCHER_GOLDEN_ARMOR_ITEM_ itemInit(stats(0, 0, 0, 0, 1), 768, ARMOR)
#define _ARCHER_DIAMOND_ARMOR_ITEM_ itemInit(stats(0, 0, 0, 0, 1), 768, ARMOR)
#define _ARCHER_IRON_ARMOR_ITEM_ itemInit(statsInit(0, 0, 0, 0, 1), 768, ARMOR)
#define _ARCHER_GOLDEN_ARMOR_ITEM_ itemInit(statsInit(1, 1, 0, 0, 1), 768, ARMOR)
#define _ARCHER_DIAMOND_ARMOR_ITEM_ itemInit(statsInit(2, 1, 0, 0, 2), 768, ARMOR)

#define _GEM_STAFF_ITEM_ itemInit(stats(0, 0, 0, 0, 1), 408, WEAPON)
#define _ICE_STAFF_ITEM_ itemInit(stats(0, 0, 0, 0, 1), 432, WEAPON)
#define _FIRE_STAFF_ITEM_ itemInit(stats(0, 0, 0, 0, 1), 456, WEAPON)
#define _GEM_STAFF_ITEM_ itemInit(statsInit(0, 0, 1, 0, 0), 408, WEAPON)
#define _ICE_STAFF_ITEM_ itemInit(statsInit(0, 0, 2, 0, 0), 432, WEAPON)
#define _FIRE_STAFF_ITEM_ itemInit(statsInit(0, 0, 3, 0, 0), 456, WEAPON)

#define _WOODEN_BOW_ITEM_ itemInit(stats(0, 0, 0, 0, 1), 480, WEAPON)
#define _GOLDEN_BOW_ITEM_ itemInit(stats(0, 0, 0, 0, 1), 504, WEAPON)
#define _AQUA_BOW_ITEM_ itemInit(stats(0, 0, 0, 0, 1), 528, WEAPON)
#define _WOODEN_BOW_ITEM_ itemInit(statsInit(0, 1, 0, 0, 0), 480, WEAPON)
#define _GOLDEN_BOW_ITEM_ itemInit(statsInit(0, 2, 0, 0, 0), 504, WEAPON)
#define _AQUA_BOW_ITEM_ itemInit(statsInit(0, 3, 0, 0, 0), 528, WEAPON)

/* Macros for all item drops in the game */
#define _IRON_CHESTPLATE_ITEM_DROP_(X, Y) itemDropInit(newIVec2(X, Y), _IRON_CHESTPLATE_ITEM_, 280)
Expand Down
5 changes: 5 additions & 0 deletions include/light.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
*/
inline void setLightLayer(i32 _light);

/**
* Light reloading
*/
void reloadLight();

/* Macro used to render shadow circle */
#define SHADOW_BULB(dest, x , y) \
dest[(x - 1) + (32*(y - 1))] = 0x17; \
Expand Down
34 changes: 17 additions & 17 deletions include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef _MAIN_H_
#define _MAIN_H_

#define MAIN_MENU_OPTION_COUNT 2
#define _MAIN_MENU_OPTION_COUNT_ 2

#include "utils/types.h"
#include "text/text.h"
Expand Down Expand Up @@ -91,7 +91,7 @@ typedef enum ActiveScene {
*/

/* Transition between scenes speed */
#define TRANSITION_SPEED 500
#define _TRANSITION_SPEED_ 500

/* Macro used to initialize all sprites for main menu */
#define _INIT_MAIN_MENU_SPRITES_ \
Expand All @@ -113,9 +113,9 @@ typedef enum ActiveScene {
/* Macro used to render choose square on provided layer */
#define _RENDER_CHOOSE_SQUARE_(layer, X_OFFSET, Y_OFFSET) \
{ \
int i; \
int x; \
int y; \
i32 i; \
i32 x; \
i32 y; \
\
for(i = 1; i <= 4; ++i) \
layer[X_OFFSET+ i + (Y_OFFSET * 32)] = 21 + 64 + 2; \
Expand Down Expand Up @@ -163,33 +163,33 @@ typedef enum ActiveScene {
/* Macro used to render size shadows on provided layer */
#define _RENDER_SIDE_SHADOW_(layer) \
{ \
int x; \
int y; \
i32 x; \
i32 y; \
for(x = 0; x < 30; ++x) { \
for(y = 0; y < 30; ++y) { \
if(x == 0 || x == 29) \
layer[x + y *32] = 0x17; \
layer[x + y * 32] = 0x17; \
\
if(x == 1 || x == 28) \
layer[x + y *32] = 0x18; \
layer[x + y * 32] = 0x18; \
\
if(x == 2 || x == 27) \
layer[x + y *32] = 0x19; \
layer[x + y * 32] = 0x19; \
\
if(x == 3 || x == 26) \
layer[x + y *32] = 0x1A; \
layer[x + y * 32] = 0x1A; \
\
if(x == 4 || x == 25) \
layer[x + y *32] = 0x1B; \
layer[x + y * 32] = 0x1B; \
\
if(x == 5 || x == 24) \
layer[x + y *32] = 0x1C; \
layer[x + y * 32] = 0x1C; \
\
if(x == 6 || x == 23) \
layer[x + y *32] = 0x1D; \
layer[x + y * 32] = 0x1D; \
\
if(x == 7 || x == 22) \
layer[x + y *32] = 0x1E; \
layer[x + y * 32] = 0x1E; \
} \
} \
} \
Expand All @@ -198,8 +198,8 @@ typedef enum ActiveScene {
#define _RENDER_CHOOSE_SCREEN_ \
_RENDER_SIDE_SHADOW_(lightLayer) \
\
{ int x; \
int y; \
{ i32 x; \
i32 y; \
for(x = 0; x < 16; ++x) { \
lightLayer[7 + x + (2 * 32)] = 0xC1 + x;\
lightLayer[7 + x + (3 * 32)] = 0xE1 + x;\
Expand Down
13 changes: 0 additions & 13 deletions include/sound/interruption.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,6 @@

// Interruption bites
#define _INT_VBLANK_ 0x0001
#define _INT_HBLANK_ 0x0002
#define _INT_VCOUNT_ 0x0004
#define _INT_TIMER_0_ 0x0008
#define _INT_TIMER_1_ 0x0010
#define _INT_TIMER_2_ 0x0020
#define _INT_TIMER_3_ 0x0040
#define _INT_COM_ 0x0080
#define _INT_DMA_0_ 0x0100
#define _INT_DMA_1_ 0x0200
#define _INT_DMA_2_ 0x0400
#define _INT_DMA_3_ 0x0800
#define _INT_BUTTON_ 0x1000
#define _INT_CART_ 0x2000

/**
* Initialize interruption
Expand Down
9 changes: 0 additions & 9 deletions include/sound/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,6 @@ typedef enum {
*/
void soundInit(u32 _output_vol, u32 _sound1_vol, u32 _decay, u32 _max_step_time);

/**
* Function, that gets sound rate of the given note
*
* @param _note note from ESoundNoteId
* @param _octave octave
* @return Sound rate
*/
u32 getSoundRate(u32 _note, u32 _octave);

/**
* Function, that plays notes
*
Expand Down
Loading