Log hits, kills and misses

This commit is contained in:
Linus Probert 2017-12-21 08:31:25 +01:00
parent 2899bb76f1
commit ca7249e954
4 changed files with 26 additions and 9 deletions

View File

@ -45,7 +45,7 @@ before_build:
%DEPENDS% copy SDL2_ttf-2.0.14\%ARCH%\bin\*.dll %PREFIX%\lib > nul
# Lua
- ps: (new-object System.Net.WebClient).Downloadfile("https://sourceforge.net/projects/luabinaries/files/5.3.4/Windows%20Libraries/Static/lua-5.3.4_Win32_vc14_lib.zip/download", "c:\lua\lua-5.3.4_Win32_vc14_lib.zip")
- ps: (New-Object Net.WebClient).DownloadFile("https://sourceforge.net/projects/luabinaries/files/5.3.4/Windows%20Libraries/Static/lua-5.3.4_Win32_vc14_lib.zip/download", "c:\lua\lua-5.3.4_Win32_vc14_lib.zip")
- |-
%DEPENDS% 7z x "c:\lua\lua-5.3.4_Win32_vc14_lib.zip" -o"c:\lua" > nul
%DEPENDS% copy c:\lua\include\* %PREFIX%\include > nul

View File

@ -8,8 +8,8 @@ x Move "clip" from texture to sprite
x Hitting enemies
x Nicer enemy hits (Text textures, healthbars?)
- This could need some love later on.
- Add hits to stats
- Player hits
x Add hits to stats
x Player hits
x Moving enemies
x Stupid roaming enemies
x Smart agressive enemies
@ -20,6 +20,8 @@ x Moving enemies
o XP
- Some xp amount logic
- Level threshholds
- Statistics
- More stuff to count
- gui
- Items
- More gui

View File

@ -31,8 +31,14 @@ has_collided(Player *player, RoomMatrix *matrix)
&space->monster->stats);
monster_hit(space->monster, hit);
if (hit > 0)
player->hits += 1;
else
player->misses += 1;
if (space->monster->stats.hp <= 0) {
// TODO(Linus): This needs some love later on.
player->kills += 1;
player->xp += 10;
}
}
@ -151,6 +157,9 @@ player_create(class_t class, SDL_Renderer *renderer)
player->total_steps = 0;
player->steps = 0;
player->xp = 0;
player->hits = 0;
player->kills = 0;
player->misses = 0;
char asset[100];
switch (class) {
@ -217,9 +226,12 @@ player_print(Player *p)
printf("\n");
printf("--------=== <[ Player Stats ]> ===--------\n");
printf("HP: %d\n", p->stats.hp);
printf("Level: %u XP: %u\n", p->stats.lvl, p->xp);
printf("Pos: %dx%d RoomPos: %dx%d\n", pos.x, pos.y, roomPos.x, roomPos.y);
printf("Level: %u\tXP:\t%u\n", p->stats.lvl, p->xp);
printf("Hits: %u\tMisses:\t%u\n", p->hits, p->misses);
printf("Kills: %u\n", p->kills);
printf("Steps: %u\n", p->total_steps);
printf("Pos: %dx%d\tRoomPos: %dx%d\n", pos.x, pos.y,
roomPos.x, roomPos.y);
printf("------------------------------------------\n");
}

View File

@ -18,6 +18,9 @@ typedef struct Player_t {
unsigned int xp;
unsigned int total_steps;
unsigned int steps;
unsigned int hits;
unsigned int kills;
unsigned int misses;
void (*handle_event)(struct Player_t*, RoomMatrix*, SDL_Event*);
} Player;