playtime.cam.position = cam_reset_position;
}
+ if (IsKeyReleased(KEY_F4))
+ {
+ const int success = save_game(playtime);
+ }
+
+ if (IsKeyReleased(KEY_F5))
+ {
+ const int success = load_game();
+ }
+
if (IsKeyReleased(KEY_ONE))
orb_target_color = SKYBLUE;
if (IsKeyReleased(KEY_TWO))
player_collision = GetRayCollisionMesh(player_collide_ray, barrow_model.meshes[0U], barrow_mat);
playtime.player_rotation = player_rotation;
- if (false && player_collision.hit && player_collision.distance < 1.30f)
+ if (player_collision.hit && player_collision.distance < 1.30f)
{
+
playtime.player_velocity.x *= -1.05;
}
else
lumWeights = vec4(1.0f) * lumWeight;
lumWeights *= dot(finalColor, lumWeights);
- //lighting_color = vec4(mix(orb_color.rgb * candle_weight, lumWeights.rgb, 0.2f), 1.0f);
+ lighting_color = vec4(mix(orb_color.rgb * candle_weight, lumWeights.rgb, 0.2f), 1.0f);
//lighting_color = vec4(mix(candle_color.rgb * candle_weight, lumWeights.rgb, 0.4f), 1.0f);
- //finalColor = finalColor * lighting_color;
+ finalColor = finalColor * lighting_color;
float factor = 35.0;
finalColor.r = round((finalColor.r) * factor) / factor;
// All single color channel variations with this looks cool as FUCK
// turns this into three levels going b-r-g
//finalColor.b = 0.0f;
-
- finalColor.a = 0.5f;
}
//int generate_rd(int worker_count, RD_Opts active_opt, FVec2 **grid_buffer, IVec2 pgrid_size);
void* generate_rd(void* args);
+int save_game(PlaytimeData playtime);
+int load_game();
#endif //__RD_STRUCTS__
#warning "TODO: I think these are only posix, check for alt platform replacements"
#include <sys/param.h>
+#include <errno.h>
+#include <sys/stat.h>
#include <time.h>
#include "structs.h"
return 0;
}
+int save_game(PlaytimeData playtime)
+{
+ int success = -1;
+ success = mkdir("./save", 0755);
+
+ if ((success == 0) || (errno == EEXIST))
+ {
+
+ FILE* save_file = fopen("./save/save.dat", "w");
+ char buf[sizeof(PlaytimeData)];
+
+ memcpy(buf, (char*)&playtime, sizeof(PlaytimeData));
+
+ if (save_file)
+ {
+ success = fwrite(buf, sizeof(PlaytimeData), 1U, save_file);
+ }
+
+ success = fclose(save_file);
+ }
+
+ return success;
+}
+
+int load_game()
+{
+
+ int success = -1;
+
+ FILE* save_file = fopen("./save/save.dat", "r");
+
+ if (save_file)
+ {
+ char buf[sizeof(PlaytimeData)];
+ const size_t bytes_read = fread(buf, 1U, sizeof(PlaytimeData), save_file);
+
+ if (bytes_read == sizeof(PlaytimeData))
+ {
+ memcpy((char*)&playtime, buf, sizeof(PlaytimeData));
+ success = fclose(save_file);
+ }
+ }
+
+ return success;
+}
+