Merge branch 'master' of github.com:liquidityc/breakhack
This commit is contained in:
commit
1ee7b92be8
|
@ -1,4 +1,6 @@
|
||||||
-DDEBUG
|
-DDEBUG
|
||||||
|
-DSTEAM_BUILD
|
||||||
|
-include ./steamworks_c_api/sdk/public/steam/steam_api.h
|
||||||
-I./steamworks_c_api/src/
|
-I./steamworks_c_api/src/
|
||||||
-I./src/steam/
|
-I./src/steam/
|
||||||
-I./build/config.h
|
-I./build/config.h
|
||||||
|
|
3
.vimrc
3
.vimrc
|
@ -5,4 +5,5 @@ nnoremap <F4> :ter ++close ./_build/breakhack<cr>
|
||||||
|
|
||||||
packadd termdebug
|
packadd termdebug
|
||||||
let g:termdebug_wide = 1
|
let g:termdebug_wide = 1
|
||||||
let g:syntastic_c_include_dirs = [ '_build', '/usr/include/SDL2', 'steamworks_c_wrapper/src', 'steamworks_c_wrapper/sdk/public/steam' ]
|
let g:syntastic_c_include_dirs = [ '_build', '/usr/include/SDL2', 'steamworks_c_wrapper/src' ]
|
||||||
|
let g:syntastic_cpp_include_dirs = [ 'steamworks_c_wrapper/sdk/public/steam' ]
|
||||||
|
|
|
@ -7,7 +7,7 @@ project(breakhack C)
|
||||||
set(breakhack_GAME_TITLE "BreakHack")
|
set(breakhack_GAME_TITLE "BreakHack")
|
||||||
set(breakhack_MAJOR_VERSION 1)
|
set(breakhack_MAJOR_VERSION 1)
|
||||||
set(breakhack_MINOR_VERSION 0)
|
set(breakhack_MINOR_VERSION 0)
|
||||||
set(breakhack_PATCH_VERSION 2)
|
set(breakhack_PATCH_VERSION 4)
|
||||||
set(breakhack_RELEASE_TYPE "")
|
set(breakhack_RELEASE_TYPE "")
|
||||||
|
|
||||||
include(FindLua)
|
include(FindLua)
|
||||||
|
|
|
@ -258,6 +258,20 @@ bosses[1] = concat({ texturePaths.dog0, texturePaths.dog1 }, bosses[1])
|
||||||
bosses[2] = concat({ texturePaths.humanoid0, texturePaths.humanoid1 }, bosses[2])
|
bosses[2] = concat({ texturePaths.humanoid0, texturePaths.humanoid1 }, bosses[2])
|
||||||
bosses[3] = concat({ texturePaths.undead0, texturePaths.undead1 }, bosses[3])
|
bosses[3] = concat({ texturePaths.undead0, texturePaths.undead1 }, bosses[3])
|
||||||
|
|
||||||
|
local eastereggs = {
|
||||||
|
{ stats.misc, 6*16, 1*16, "Linus, the Developer", behaviour.passive },
|
||||||
|
{ stats.misc, 4*16, 1*16, "Scanlan, the Bard", behaviour.passive },
|
||||||
|
{ stats.misc, 2*16, 4*16, "Vax, the Twin", behaviour.passive },
|
||||||
|
{ stats.misc, 2*16, 3*16, "Vex, the Twin", behaviour.passive },
|
||||||
|
{ stats.misc, 0*16,10*16, "Grog, the Barbarian", behaviour.passive },
|
||||||
|
{ stats.misc, 3*16, 4*16, "Percy, the Gunslinger", behaviour.passive },
|
||||||
|
{ stats.misc, 4*16, 0*16, "Pike, the Cleric", behaviour.passive },
|
||||||
|
{ stats.misc, 6*16, 7*16, "Keyleth, the Druid", behaviour.passive },
|
||||||
|
}
|
||||||
|
for i=1,#eastereggs do
|
||||||
|
eastereggs[i] = concat({ texturePaths.player0, texturePaths.player1 }, eastereggs[i])
|
||||||
|
end
|
||||||
|
|
||||||
local platino = {
|
local platino = {
|
||||||
{
|
{
|
||||||
texturePaths.reptile0,
|
texturePaths.reptile0,
|
||||||
|
@ -313,6 +327,10 @@ if(CURRENT_LEVEL > 0) then
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if random(100) == 1 then
|
||||||
|
enemies[#enemies+1] = eastereggs[random(#eastereggs)]
|
||||||
|
end
|
||||||
|
|
||||||
if random(100) == 1 then
|
if random(100) == 1 then
|
||||||
enemies = concat(enemies, platino)
|
enemies = concat(enemies, platino)
|
||||||
end
|
end
|
||||||
|
|
|
@ -116,13 +116,14 @@ create_treasure(int current_level)
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
|
|
||||||
amt = (unsigned int) 1 + get_random(5*current_level) % 40;
|
amt = (unsigned int) 1 + get_random(5*current_level) % 40;
|
||||||
|
amt = amt == 0 ? 1 : amt;
|
||||||
|
|
||||||
if (current_level > 9) {
|
if (current_level > 9) {
|
||||||
highest_treasure = TREASURE_COUNT;
|
|
||||||
} else if (current_level > 3) {
|
|
||||||
highest_treasure = PLATINUM;
|
highest_treasure = PLATINUM;
|
||||||
} else {
|
} else if (current_level > 3) {
|
||||||
highest_treasure = GOLD;
|
highest_treasure = GOLD;
|
||||||
|
} else {
|
||||||
|
highest_treasure = SILVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = get_random(highest_treasure);
|
value = get_random(highest_treasure);
|
||||||
|
|
|
@ -894,8 +894,9 @@ run_game(void)
|
||||||
createInGameGameOverMenu();
|
createInGameGameOverMenu();
|
||||||
hiscore_register(gPlayer, cLevel);
|
hiscore_register(gPlayer, cLevel);
|
||||||
#ifdef STEAM_BUILD
|
#ifdef STEAM_BUILD
|
||||||
steam_register_score((int)hiscore_get_top_gold());
|
uint8_t details[4] = { (uint8_t) gPlayer->stats.lvl, (uint8_t) cLevel, 0, 0 };
|
||||||
steam_register_kills((int) gPlayer->stat_data.kills);
|
steam_register_score((int) gPlayer->gold, (int32_t*) &details, 1);
|
||||||
|
steam_register_kills((int) gPlayer->stat_data.kills, (int32_t*) &details, 1);
|
||||||
#endif // STEAM_BUILD
|
#endif // STEAM_BUILD
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
34
src/player.c
34
src/player.c
|
@ -105,12 +105,6 @@ action_spent(Player *p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
player_step(Player *p)
|
|
||||||
{
|
|
||||||
action_spent(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_monster_collision(Player *player,
|
on_monster_collision(Player *player,
|
||||||
Monster *monster,
|
Monster *monster,
|
||||||
|
@ -267,7 +261,7 @@ move(Player *player, RoomMatrix *matrix, Vector2d direction)
|
||||||
player->sprite->pos.y += TILE_DIMENSION * (int) direction.y;
|
player->sprite->pos.y += TILE_DIMENSION * (int) direction.y;
|
||||||
|
|
||||||
if (!has_collided(player, matrix, direction)) {
|
if (!has_collided(player, matrix, direction)) {
|
||||||
player_step(player);
|
action_spent(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +334,7 @@ use_skill(Skill *skill, SkillData *skillData)
|
||||||
skill->active = false;
|
skill->active = false;
|
||||||
skill->use(skill, skillData);
|
skill->use(skill, skillData);
|
||||||
if (skill->actionRequired)
|
if (skill->actionRequired)
|
||||||
player_step(skillData->player);
|
action_spent(skillData->player);
|
||||||
skill->resetCountdown = skill->resetTime;
|
skill->resetCountdown = skill->resetTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,17 +512,6 @@ player_monster_kill_check(Player *player, Monster *monster)
|
||||||
if (!monster)
|
if (!monster)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef STEAM_BUILD
|
|
||||||
if (strcmp("The Shadow", monster->label) == 0)
|
|
||||||
steam_set_achievement(LIGHTS_ON);
|
|
||||||
else if (strcmp("The Hell Hound", monster->label) == 0)
|
|
||||||
steam_set_achievement(BAD_DOG);
|
|
||||||
else if (strcmp("Platino", monster->label) == 0)
|
|
||||||
steam_set_achievement(DRAGON_SLAYER);
|
|
||||||
else if (strcmp("The Cleric", monster->label) == 0)
|
|
||||||
steam_set_achievement(THE_DOCTOR_IS_OUT);
|
|
||||||
#endif // STEAM_BUILD
|
|
||||||
|
|
||||||
if (monster->stats.hp <= 0) {
|
if (monster->stats.hp <= 0) {
|
||||||
unsigned int gained_xp = 5 * monster->stats.lvl;
|
unsigned int gained_xp = 5 * monster->stats.lvl;
|
||||||
player->stat_data.kills += 1;
|
player->stat_data.kills += 1;
|
||||||
|
@ -536,6 +519,19 @@ player_monster_kill_check(Player *player, Monster *monster)
|
||||||
gui_log("You killed %s and gained %d xp",
|
gui_log("You killed %s and gained %d xp",
|
||||||
monster->lclabel, gained_xp);
|
monster->lclabel, gained_xp);
|
||||||
player_gain_xp(player, gained_xp);
|
player_gain_xp(player, gained_xp);
|
||||||
|
|
||||||
|
#ifdef STEAM_BUILD
|
||||||
|
if (strcmp("The Shadow", monster->label) == 0)
|
||||||
|
steam_set_achievement(LIGHTS_ON);
|
||||||
|
else if (strcmp("The Hell Hound", monster->label) == 0)
|
||||||
|
steam_set_achievement(BAD_DOG);
|
||||||
|
else if (strcmp("Platino", monster->label) == 0)
|
||||||
|
steam_set_achievement(DRAGON_SLAYER);
|
||||||
|
else if (strcmp("The Cleric", monster->label) == 0)
|
||||||
|
steam_set_achievement(THE_DOCTOR_IS_OUT);
|
||||||
|
else if (strcmp("Linus, the Developer", monster->label) == 0)
|
||||||
|
steam_set_achievement(BUGGFIXER);
|
||||||
|
#endif // STEAM_BUILD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,16 +111,16 @@ void steam_set_achievement(EAchievement eAch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void steam_register_score(Sint32 nScore)
|
void steam_register_score(Sint32 nScore, const int32_t *details, int32_t nDetails)
|
||||||
{
|
{
|
||||||
if (!m_hHighscoreLeaderboard)
|
if (!m_hHighscoreLeaderboard)
|
||||||
return;
|
return;
|
||||||
c_SteamUserStats_UploadLeaderboardScore(m_hHighscoreLeaderboard, nScore);
|
c_SteamUserStats_UploadLeaderboardScore(m_hHighscoreLeaderboard, nScore, details, nDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
void steam_register_kills(Sint32 nKills)
|
void steam_register_kills(Sint32 nKills, const int32_t *details, int32_t nDetails)
|
||||||
{
|
{
|
||||||
if (!m_hKillsLeaderboard)
|
if (!m_hKillsLeaderboard)
|
||||||
return;
|
return;
|
||||||
c_SteamUserStats_UploadLeaderboardScore(m_hKillsLeaderboard, nKills);
|
c_SteamUserStats_UploadLeaderboardScore(m_hKillsLeaderboard, nKills, details, nDetails);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,8 @@ typedef enum EAchievement
|
||||||
THE_DOCTOR_IS_OUT = 1,
|
THE_DOCTOR_IS_OUT = 1,
|
||||||
LIGHTS_ON = 2,
|
LIGHTS_ON = 2,
|
||||||
BACK_TO_WORK = 5,
|
BACK_TO_WORK = 5,
|
||||||
DRAGON_SLAYER = 6
|
DRAGON_SLAYER = 6,
|
||||||
|
BUGGFIXER = 7
|
||||||
} EAchievement;
|
} EAchievement;
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,6 +32,6 @@ void steam_run_callbacks(void);
|
||||||
|
|
||||||
void steam_set_achievement(EAchievement eAch);
|
void steam_set_achievement(EAchievement eAch);
|
||||||
|
|
||||||
void steam_register_score(Sint32 nScore);
|
void steam_register_score(Sint32 nScore, const int32_t *details, int32_t nDetails);
|
||||||
|
|
||||||
void steam_register_kills(Sint32 nKills);
|
void steam_register_kills(Sint32 nKills, const int32_t *details, int32_t nDetails);
|
||||||
|
|
|
@ -35,6 +35,7 @@ else ()
|
||||||
SHARED
|
SHARED
|
||||||
src/steamworks_c_wrapper
|
src/steamworks_c_wrapper
|
||||||
src/CallbackHandler
|
src/CallbackHandler
|
||||||
|
src/CSteamLeaderboard
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include "CSteamLeaderboard.h"
|
||||||
|
|
||||||
|
CSteamLeaderboard::CSteamLeaderboard() : m_hCurrentLeaderboard(0)
|
||||||
|
{
|
||||||
|
// Nothing yet
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CSteamLeaderboard::SetCurrent(SteamLeaderboard_t hCurrentLeaderboard)
|
||||||
|
{
|
||||||
|
m_hCurrentLeaderboard = hCurrentLeaderboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CSteamLeaderboard::FindLeaderboard(const char *pchLeaderboardName )
|
||||||
|
{
|
||||||
|
|
||||||
|
SteamAPICall_t hSteamAPICall = SteamUserStats()->FindLeaderboard(pchLeaderboardName);
|
||||||
|
m_callResultFindLeaderboard.Set(hSteamAPICall,
|
||||||
|
this,
|
||||||
|
&CSteamLeaderboard::OnFindLeaderboard);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CSteamLeaderboard::UploadScore(int score, const int *details, int nDetails)
|
||||||
|
{
|
||||||
|
if (!m_hCurrentLeaderboard)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
SteamAPICall_t hSteamAPICall = SteamUserStats()->UploadLeaderboardScore(m_hCurrentLeaderboard,
|
||||||
|
k_ELeaderboardUploadScoreMethodKeepBest,
|
||||||
|
score,
|
||||||
|
details,
|
||||||
|
nDetails);
|
||||||
|
m_callResultUploadScore.Set(hSteamAPICall, this, &CSteamLeaderboard::OnUploadScore);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CSteamLeaderboard::DownloadScores()
|
||||||
|
{
|
||||||
|
if (!m_hCurrentLeaderboard) return false;
|
||||||
|
SteamAPICall_t hSteamAPICall = SteamUserStats()->DownloadLeaderboardEntries( m_hCurrentLeaderboard,
|
||||||
|
k_ELeaderboardDataRequestGlobalAroundUser,
|
||||||
|
-4,
|
||||||
|
5);
|
||||||
|
|
||||||
|
m_callResultDownloadScores.Set(hSteamAPICall, this, &CSteamLeaderboard::OnDownloadScores);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CSteamLeaderboard::OnFindLeaderboard(LeaderboardFindResult_t *pCallback, bool bIOFailiure)
|
||||||
|
{
|
||||||
|
if (!pCallback->m_bLeaderboardFound || bIOFailiure) {
|
||||||
|
std::cerr << "Leaderboard could not be found" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_hCurrentLeaderboard = pCallback->m_hSteamLeaderboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CSteamLeaderboard::OnUploadScore(LeaderboardScoreUploaded_t *pCallback, bool bIOFailiure)
|
||||||
|
{
|
||||||
|
if (!pCallback->m_bSuccess || bIOFailiure)
|
||||||
|
std::cerr << "Score could not be uploaded" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CSteamLeaderboard::OnDownloadScores(LeaderboardScoresDownloaded_t *pCallback, bool bIOFailiure)
|
||||||
|
{
|
||||||
|
if (!bIOFailiure) {
|
||||||
|
m_nLeaderboardEntries = std::min(pCallback->m_cEntryCount, 10);
|
||||||
|
for (int index = 0; index < m_nLeaderboardEntries; index++) {
|
||||||
|
SteamUserStats()->GetDownloadedLeaderboardEntry( pCallback->m_hSteamLeaderboardEntries,
|
||||||
|
index,
|
||||||
|
&m_leaderboardEntries[index],
|
||||||
|
NULL,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <steam_api.h>
|
||||||
|
|
||||||
|
class CSteamLeaderboard
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
SteamLeaderboard_t m_hCurrentLeaderboard;
|
||||||
|
LeaderboardEntry_t m_leaderboardEntries[10];
|
||||||
|
int m_nLeaderboardEntries = 0;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CSteamLeaderboard();
|
||||||
|
|
||||||
|
void SetCurrent(SteamLeaderboard_t hCurrentLeaderboard);
|
||||||
|
|
||||||
|
void FindLeaderboard(const char *pchLeaderboardName );
|
||||||
|
bool UploadScore(int score, const int *details, int nDetails);
|
||||||
|
bool DownloadScores();
|
||||||
|
|
||||||
|
void OnFindLeaderboard(LeaderboardFindResult_t *pCallback, bool bIOFailiure);
|
||||||
|
CCallResult<CSteamLeaderboard, LeaderboardFindResult_t> m_callResultFindLeaderboard;
|
||||||
|
|
||||||
|
void OnUploadScore(LeaderboardScoreUploaded_t *pCallback, bool bIOFailiure);
|
||||||
|
CCallResult<CSteamLeaderboard, LeaderboardScoreUploaded_t> m_callResultUploadScore;
|
||||||
|
|
||||||
|
void OnDownloadScores(LeaderboardScoresDownloaded_t *pCallback, bool bIOFailiure);
|
||||||
|
CCallResult<CSteamLeaderboard, LeaderboardScoresDownloaded_t> m_callResultDownloadScores;
|
||||||
|
};
|
|
@ -98,10 +98,10 @@ c_SteamUserStats_FindLeaderboard(const char * name)
|
||||||
m_CallbackHandler->m_FindLeaderboardCallResult.Set(hSteamAPICall, m_CallbackHandler, &CallbackHandler::OnFindLeaderboard);
|
m_CallbackHandler->m_FindLeaderboardCallResult.Set(hSteamAPICall, m_CallbackHandler, &CallbackHandler::OnFindLeaderboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void c_SteamUserStats_UploadLeaderboardScore(int64_t hLeaderboard, int32_t nScore)
|
extern "C" void c_SteamUserStats_UploadLeaderboardScore(int64_t hLeaderboard, int32_t nScore, const int32_t *details, int32_t nDetails)
|
||||||
{
|
{
|
||||||
if (!hLeaderboard || !m_Initiated)
|
if (!hLeaderboard || !m_Initiated)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SteamUserStats()->UploadLeaderboardScore(hLeaderboard, k_ELeaderboardUploadScoreMethodKeepBest, nScore, nullptr, 0);
|
SteamUserStats()->UploadLeaderboardScore(hLeaderboard, k_ELeaderboardUploadScoreMethodKeepBest, nScore, details, nDetails);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ void
|
||||||
c_SteamUserStats_FindLeaderboard(const char *name);
|
c_SteamUserStats_FindLeaderboard(const char *name);
|
||||||
|
|
||||||
void
|
void
|
||||||
c_SteamUserStats_UploadLeaderboardScore(int64_t hLeaderboard, int32_t nScore);
|
c_SteamUserStats_UploadLeaderboardScore(int64_t hLeaderboard, int32_t nScore, const int32_t *details, int32_t nDetails);
|
||||||
|
|
||||||
void
|
void
|
||||||
c_SteamAPI_Shutdown(void);
|
c_SteamAPI_Shutdown(void);
|
Loading…
Reference in New Issue