src="fishladder.c"
target="fishladder"
lib="-I. -L./lib -L./"
-libs="-lGL -lglfw -lX11 -lXxf86vm -lXrandr -lm -lpthread -lXi -ldl -l:steam/libsteam_api.so"
+libs="-lGL -lglfw -lX11 -lXxf86vm -lXrandr -lm -lpthread -lXi -ldl"
+steam_part="-l:steam/libsteam_api.so"
flags="-fsanitize=address -ggdb3 -Wno-unused-function"
build_dir="build.linux"
steam_api="libsteam_api.so"
echo "Operating system is not GNU/Linux, windows will be assumed."
target="fishladder.exe"
- libs="-lglfw3 -lopengl32 -lm -mwindows -l:steam/steam_api.dll"
+ libs="-lglfw3 -lopengl32 -lm -mwindows"
flags="-ggdb3 -Wno-unused-function"
build_dir="build.win32"
steam_api="steam_api.dll"
run_after=true
echo "& Run"
;;
+ -s|--no-steam)
+ steam_part=""
+ defines="-DNO_STEAM"
+ echo "no-steam"
+ ;;
-n|--nobuild)
do_build=false
echo "no-build"
if [ "$compile_tools" = true ]; then
echo "Building tools"
mkdir tools -p
- gcc -Wall -Wstrict-aliasing=3 $lib $flags mdlcomp.c gl/glad.c -o tools/mdlcomp $libs -Wl,-rpath=./ $defines
- gcc -Wall -Wstrict-aliasing=3 $lib $flags fontcomp.c gl/glad.c -o tools/fontcomp $libs -Wl,-rpath=./ $defines
+ gcc -Wall -Wstrict-aliasing=3 $lib $flags mdlcomp.c gl/glad.c -o tools/mdlcomp $libs $steam_part -Wl,-rpath=./ $defines
+ gcc -Wall -Wstrict-aliasing=3 $lib $flags fontcomp.c gl/glad.c -o tools/fontcomp $libs $steam_part -Wl,-rpath=./ $defines
gcc $lib qoiconv.c -std=c99 -O3 -o tools/qoiconv
fi
# Main build
if [ "$do_build" = true ]; then
- gcc -Wall -Wstrict-aliasing=3 $lib $flags $src gl/glad.c -o $target $libs -Wl,-rpath=./ $defines
+ gcc -Wall -Wstrict-aliasing=3 $lib $flags $src gl/glad.c -o $target $libs $steam_part -Wl,-rpath=./ $defines
if [ $? -ne 0 ]; then
echo "GCC build failed"
// Copyright (C) 2021 Harry Godden (hgn) - All Rights Reserved
//#define VG_CAPTURE_MODE
-#define VG_STEAM
+//#define VG_STEAM
#define VG_STEAM_APPID 1218140U
#include "vg/vg.h"
#include "fishladder_resources.h"
static int cell_interactive( v2i co );
void vg_update(void);
-void leaderboard_found( LeaderboardFindResult_t *pCallback );
-void leaderboard_downloaded( LeaderboardScoresDownloaded_t *pCallback );
-
static void render_tiles( v2i start, v2i end, v4f const regular_colour, v4f const selected_colour );
void vg_render(void);
// Leaderboard stuff
// -----------------
+#ifdef STEAM_LEADERBOARDS
void leaderboard_set_score( struct cmp_level *cmp_level, u32 score );
void leaderboard_dispatch_score(void);
void leaderboard_found( LeaderboardFindResult_t *pCallback );
void leaderboard_downloaded( LeaderboardScoresDownloaded_t *pCallback );
void leaderboard_set_score( struct cmp_level *cmp_level, u32 score );
+#endif
+
+// Console commands
+// ----------------
static int console_credits( int argc, char const *argv[] );
static int console_save_map( int argc, char const *argv[] );
static int console_load_map( int argc, char const *argv[] );
{
if( score < lvl->completed_score || lvl->completed_score == 0 )
{
+ #ifdef VG_STEAM
if( !lvl->is_tutorial && upload )
leaderboard_set_score( lvl, score );
-
+ #endif
+
lvl->completed_score = score;
}
if( lvl->unlock ) career_unlock_level( lvl->unlock );
+ #ifdef VG_STEAM
if( lvl->achievement )
{
sw_set_achievement( lvl->achievement );
}
-
+
// Check ALL maps to trigger master engineer
for( int i = 0; i < vg_list_size( career_serializable ); i ++ )
{
}
sw_set_achievement( "MASTER_ENGINEER" );
+ #endif
}
}
if( cell_entry->config == k_cell_type_con_r || cell_entry->config == k_cell_type_con_u
|| cell_entry->config == k_cell_type_con_l || cell_entry->config == k_cell_type_con_d )
{
+ #ifdef VG_STEAM
sw_set_achievement( "CAN_DO_THAT" );
-
+ #endif
+
fish->state = k_fish_state_soon_alive;
fish->dir[0] = 0;
if( collide_next_frame || collide_this_frame )
{
+ #ifdef VG_STEAM
sw_set_achievement( "BANG" );
-
+ #endif
+
// Shatter death (+0.5s)
float death_time = world.sim_internal_time + ( collide_this_frame? 0.0f: 0.5f );
}
else
{
+ #ifdef VG_STEAM
if( world.sim_run > 0 )
sw_set_achievement( "GOOD_ENOUGH" );
-
+ #endif
+
vg_error( "Level failed :(\n" );
}
}
}
-void leaderboard_found( LeaderboardFindResult_t *pCallback );
-void leaderboard_downloaded( LeaderboardScoresDownloaded_t *pCallback );
-
static void render_tiles( v2i start, v2i end, v4f const regular_colour, v4f const selected_colour )
{
v2i full_start = { 0,0 };
glUniformMatrix3fv( SHADER_UNIFORM( shader_tile_main, "uPv" ), 1, GL_FALSE, (float *)vg_pv );
glUniform1f( SHADER_UNIFORM( shader_tile_main, "uGhost" ), 0.0f );
glUniform1f( SHADER_UNIFORM( shader_tile_main, "uForeground" ), 0.0f );
+ //glUniform1f( SHADER_UNIFORM( shader_tile_main, "uVisibility" ), sinf( vg_time ) + 1.0f );
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
void vg_ui(void) {}
+#if STEAM_LEADERBOARDS
void leaderboard_dispatch_score(void)
{
-#if STEAM_LEADERBOARDS
sw_upload_leaderboard_score(
ui_data.upload_request.level->steam_leaderboard,
k_ELeaderboardUploadScoreMethodKeepBest,
ui_data.upload_request.is_waiting = 0;
vg_success( "Dispatched leaderboard score\n" );
-#endif
}
void leaderboard_found( LeaderboardFindResult_t *pCallback )
{
-#ifdef STEAM_LEADERBOARDS
if( !pCallback->m_bLeaderboardFound )
{
vg_error( "Leaderboard could not be found\n" );
}
}
}
-#endif
}
void leaderboard_downloaded( LeaderboardScoresDownloaded_t *pCallback )
{
-#ifdef STEAM_LEADERBOARDS
// Update UI if this leaderboard matches what we currently have in view
if( ui_data.level_selected->steam_leaderboard == pCallback->m_hSteamLeaderboard )
{
ui_data.leaderboard_show = 0;
}
else vg_warn( "Downloaded leaderboard does not match requested!\n" );
-#endif
}
void leaderboard_set_score( struct cmp_level *cmp_level, u32 score )
{
-#ifdef STEAM_LEADERBOARDS
if( ui_data.upload_request.is_waiting )
vg_warn( "You are uploading leaderboard entries too quickly!\n" );
leaderboard_dispatch_score();
else
sw_find_leaderboard( cmp_level->map_name );
-#endif
}
+#endif
// CONSOLE COMMANDS
// ===========================================================================================================
void vg_free(void)
{
+#ifdef VG_STEAM
sw_free_opengl();
+#endif
+
console_save_map( 0, NULL );
career_serialize();
"uniform vec4 uOffset;" // Tile x/y, uv x/y
"uniform mat3 uPv;"
"uniform mat2 uSubTransform;"
+ //"uniform float uVisibility;"
""
"out vec4 aTexCoords;"
"out vec2 aWorldCoords;"
""
"void main()"
"{"
+ "vec2 hash_val = hash22(uOffset.xy);"
+ //"float scaling_factor = smoothstep( hash_val.x, hash_val.x+1.0, uVisibility );"
+
// Vertex transform
"vec2 subtransform = uSubTransform * (a_co-0.5) + 0.5;"
"vec3 worldpos = vec3( subtransform + uOffset.xy, 1.0 );"
"gl_Position = vec4( uPv * worldpos, 1.0 );"
// Create texture coords
- "vec2 random_offset = floor(hash22(uOffset.xy) * 4.0) * 0.25;"
+ "vec2 random_offset = floor(hash_val * 4.0) * 0.25;"
"vec2 edge_safe_coords = a_co * 0.98 + 0.01;"
"aTexCoords = vec4((edge_safe_coords + uOffset.zw) * 0.25, edge_safe_coords * 0.25 + random_offset );"
"aWorldCoords = worldpos.xy;"
"FragColor = mix( output_regular, output_ghost, uGhost ) * uColour;"
"}"
,
- UNIFORMS({ "uPv", "uOffset", "uTexGlyphs", "uTexWood", "uSubTransform", "uGhost", "uMousePos", "uColour", "uForeground" })
+ UNIFORMS({ "uPv", "uOffset", "uTexGlyphs", "uTexWood", "uSubTransform", "uGhost", "uMousePos", "uColour", "uForeground", "uVisibility" })
)
SHADER_DEFINE( shader_background,
int serial_id;
int is_tutorial;
-
+
+ #ifdef VG_STEAM
SteamLeaderboard_t steam_leaderboard;
+ #endif
};
static struct cmp_level cmp_levels_tutorials[] =